diff options
author | uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-05-14 15:53:58 +0000 |
---|---|---|
committer | uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-05-14 15:53:58 +0000 |
commit | 29026d0ef977d1297bb7f6c38046305f6ad0236c (patch) | |
tree | e01d8b22bf6a56b33c93e5ee0f9722121e54ff3d | |
parent | 687ee9a7c3a01184c88e7b8a052223c8562058d5 (diff) |
PR target/85756
* config/i386/i386.md: Disallow non-commutative arithmetics in
last twpeephole for mem {+,-,&,|,^}= x; mem != 0 after cmpelim
optimization. Use COMMUTATIVE_ARITH_P test rather than != MINUS
in the peephole2 before it.
testsuite/ChangeLog:
* gcc.c-torture/execute/pr85756.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@260231 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/config/i386/i386.md | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr85756.c | 50 |
4 files changed, 65 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a2121a995583..879fdbb87e89 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2018-05-14 Jakub Jelinek <jakub@redhat.com> + + PR target/85756 + * config/i386/i386.md: Disallow non-commutative arithmetics in + last twpeephole for mem {+,-,&,|,^}= x; mem != 0 after cmpelim + optimization. Use COMMUTATIVE_ARITH_P test rather than != MINUS + in the peephole2 before it. + 2018-05-14 Sebastian Peryt <sebastian.peryt@intel.com> * common/config/i386/i386-common.c (OPTION_MASK_ISA_CLDEMOTE_SET, diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 302ccc524bb3..9c54131bf3ab 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -19370,7 +19370,7 @@ (set (match_dup 1) (match_dup 0)) (set (reg FLAGS_REG) (compare (match_dup 0) (const_int 0)))] "(TARGET_READ_MODIFY_WRITE || optimize_insn_for_size_p ()) - && GET_CODE (operands[2]) != MINUS + && COMMUTATIVE_ARITH_P (operands[2]) && peep2_reg_dead_p (3, operands[0]) && !reg_overlap_mentioned_p (operands[0], operands[1]) && ix86_match_ccmode (peep2_next_insn (2), @@ -19400,11 +19400,11 @@ (set (match_dup 0) (match_dup 2))]) (set (match_dup 1) (match_dup 0))] "(TARGET_READ_MODIFY_WRITE || optimize_insn_for_size_p ()) + && COMMUTATIVE_ARITH_P (operands[2]) && peep2_reg_dead_p (2, operands[0]) && !reg_overlap_mentioned_p (operands[0], operands[1]) && ix86_match_ccmode (peep2_next_insn (0), - (GET_CODE (operands[2]) == PLUS - || GET_CODE (operands[2]) == MINUS) + GET_CODE (operands[2]) == PLUS ? CCGOCmode : CCNOmode)" [(parallel [(set (match_dup 3) (match_dup 5)) (set (match_dup 1) (match_dup 4))])] diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a256329e8657..6aae7355f044 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-05-14 Jakub Jelinek <jakub@redhat.com> + + * gcc.c-torture/execute/pr85756.c: New test. + 2018-05-14 Sebastian Peryt <sebastian.peryt@intel.com> * gcc.target/i386/cldemote-1.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr85756.c b/gcc/testsuite/gcc.c-torture/execute/pr85756.c new file mode 100644 index 000000000000..8c9596601430 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr85756.c @@ -0,0 +1,50 @@ +/* PR target/85756 */ + +#if __CHAR_BIT__ == 8 && __SIZEOF_SHORT__ == 2 && __SIZEOF_INT__ == 4 +int a, c, *e, f, h = 10; +short b; +unsigned int p; + +__attribute__((noipa)) void +bar (int a) +{ + asm volatile ("" : : "r" (a) : "memory"); +} + +void +foo () +{ + unsigned j = 1, m = 430523; + int k, n = 1, *l = &h; +lab: + p = m; + m = -((~65535U | j) - n); + f = b << ~(n - 8); + n = (m || b) ^ f; + j = p; + if (p < m) + *l = k < 3; + if (!n) + l = &k; + if (c) + { + bar (a); + goto lab; + } + if (!*l) + *e = 1; +} + +int +main () +{ + foo (); + return 0; +} +#else +int +main () +{ + return 0; +} +#endif |