diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-06-26 11:46:10 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-06-26 11:46:10 +0000 |
commit | 09a46fc9eb184a90df506a1ab3cae3d3a3ba0dba (patch) | |
tree | 39a6e9aae96a81662462559c08946dd9651006c3 | |
parent | 43ad8df852a2855b76df2bcd712e786348684fe3 (diff) |
PR target/86314
* config/i386/i386.md (setcc + movzbl to xor + setcc peephole2s):
Check reg_overlap_mentioned_p in addition to reg_set_p with the same
operands.
* gcc.dg/pr86314.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@262142 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/config/i386/i386.md | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr86314.c | 20 |
4 files changed, 36 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8e7f31b32d13..faa476cf9296 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-06-26 Jakub Jelinek <jakub@redhat.com> + + PR target/86314 + * config/i386/i386.md (setcc + movzbl to xor + setcc peephole2s): + Check reg_overlap_mentioned_p in addition to reg_set_p with the same + operands. + 2018-06-25 Michael Meissner <meissner@linux.ibm.com> Back port from trunk diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 46e50b98a0dd..db2b4d9bf134 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -12481,6 +12481,7 @@ "(peep2_reg_dead_p (3, operands[1]) || operands_match_p (operands[1], operands[3])) && ! reg_overlap_mentioned_p (operands[3], operands[0]) + && ! reg_overlap_mentioned_p (operands[3], operands[4]) && ! reg_set_p (operands[3], operands[4]) && peep2_regno_dead_p (0, FLAGS_REG)" [(parallel [(set (match_dup 5) (match_dup 0)) @@ -12506,6 +12507,7 @@ || operands_match_p (operands[2], operands[4])) && ! reg_overlap_mentioned_p (operands[4], operands[0]) && ! reg_overlap_mentioned_p (operands[4], operands[1]) + && ! reg_overlap_mentioned_p (operands[4], operands[5]) && ! reg_set_p (operands[4], operands[5]) && refers_to_regno_p (FLAGS_REG, operands[1], (rtx *)NULL) && peep2_regno_dead_p (0, FLAGS_REG)" @@ -12555,6 +12557,7 @@ "(peep2_reg_dead_p (3, operands[1]) || operands_match_p (operands[1], operands[3])) && ! reg_overlap_mentioned_p (operands[3], operands[0]) + && ! reg_overlap_mentioned_p (operands[3], operands[4]) && ! reg_set_p (operands[3], operands[4]) && peep2_regno_dead_p (0, FLAGS_REG)" [(parallel [(set (match_dup 5) (match_dup 0)) @@ -12581,6 +12584,7 @@ || operands_match_p (operands[2], operands[4])) && ! reg_overlap_mentioned_p (operands[4], operands[0]) && ! reg_overlap_mentioned_p (operands[4], operands[1]) + && ! reg_overlap_mentioned_p (operands[4], operands[5]) && ! reg_set_p (operands[4], operands[5]) && refers_to_regno_p (FLAGS_REG, operands[1], (rtx *)NULL) && peep2_regno_dead_p (0, FLAGS_REG)" diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4341a2358208..848bd94b5b23 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-06-26 Jakub Jelinek <jakub@redhat.com> + + PR target/86314 + * gcc.dg/pr86314.c: New test. + 2018-06-25 Fritz Reese <fritzoreese@gmail.com> PR fortran/82972 diff --git a/gcc/testsuite/gcc.dg/pr86314.c b/gcc/testsuite/gcc.dg/pr86314.c new file mode 100644 index 000000000000..8962a3cf2ff7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr86314.c @@ -0,0 +1,20 @@ +// PR target/86314 +// { dg-do run { target sync_int_long } } +// { dg-options "-O2" } + +__attribute__((noinline, noclone)) unsigned long +foo (unsigned long *p) +{ + unsigned long m = 1UL << ((*p & 1) ? 1 : 0); + unsigned long n = __atomic_fetch_or (p, m, __ATOMIC_SEQ_CST); + return (n & m) == 0; +} + +int +main () +{ + unsigned long v = 1; + if (foo (&v) != 1) + __builtin_abort (); + return 0; +} |