On Wed, Jun 15, 2016 at 10:44:06PM +0200, Uros Bizjak wrote: > Please also change similar peephole2 pattern (that does a zext with an > and insn) a couple of patterns below the one you are changing.
Here is what I've committed to the trunk and 6.2 after bootstrap/regtest on x86_64-linux and i686-linux. For 5/4.9, this doesn't apply cleanly, as http://gcc.gnu.org/r222592 aka https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01930.html has not been backported. Shall I backport that too, or just not apply to 5/4.9? I guess I should, because: int v; __attribute__ ((noinline, noclone)) void bar (void) { v++; } __attribute__ ((noinline, noclone)) void foo (unsigned int x) { signed int y = ((-__INT_MAX__ - 1) / 2), r; if (__builtin_mul_overflow (x, y, &r)) bar (); } int main () { foo (2); if (v) __builtin_abort (); return 0; } is miscompiled with -m32 -O2 in 5.x (though, 4.9 doesn't support __builtin_*_overflow, so maybe it is not an issue there). 2016-06-16 Jakub Jelinek <ja...@redhat.com> * config/i386/i386.md (setcc + movzbl peephole2): Use reg_set_p. (setcc + and peephole2): Likewise. --- gcc/config/i386/i386.md.jj 2016-06-15 19:09:09.233682173 +0200 +++ gcc/config/i386/i386.md 2016-06-16 09:28:23.725863387 +0200 @@ -11849,8 +11849,7 @@ (define_peephole2 "(peep2_reg_dead_p (3, operands[1]) || operands_match_p (operands[1], operands[3])) && ! reg_overlap_mentioned_p (operands[3], operands[0]) - && ! (GET_CODE (operands[4]) == CLOBBER - && reg_mentioned_p (operands[3], operands[4]))" + && ! reg_set_p (operands[3], operands[4])" [(parallel [(set (match_dup 5) (match_dup 0)) (match_dup 4)]) (set (strict_low_part (match_dup 6)) @@ -11894,8 +11893,7 @@ (define_peephole2 "(peep2_reg_dead_p (3, operands[1]) || operands_match_p (operands[1], operands[3])) && ! reg_overlap_mentioned_p (operands[3], operands[0]) - && ! (GET_CODE (operands[4]) == CLOBBER - && reg_mentioned_p (operands[3], operands[4]))" + && ! reg_set_p (operands[3], operands[4])" [(parallel [(set (match_dup 5) (match_dup 0)) (match_dup 4)]) (set (strict_low_part (match_dup 6)) Jakub