re PR target/86314 (GCC 7.x and 8.x zero out "eax" before using "rax" in "lock bts")

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.

From-SVN: r262141
This commit is contained in:
Jakub Jelinek 2018-06-26 13:35:52 +02:00 committed by Jakub Jelinek
parent f03915116b
commit d37a91e5c5
4 changed files with 34 additions and 0 deletions

View file

@ -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-26 Richard Biener <rguenther@suse.de>
PR tree-optimization/86287

View file

@ -12761,6 +12761,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))
@ -12786,6 +12787,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)"
@ -12835,6 +12837,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))
@ -12861,6 +12864,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)"

View file

@ -1,5 +1,8 @@
2018-06-26 Jakub Jelinek <jakub@redhat.com>
PR target/86314
* gcc.dg/pr86314.c: New test.
PR debug/86257
* gcc.target/i386/pr86257.c: Add -mtls-dialect=gnu to dg-options.

View file

@ -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;
}