On Wed, Jun 15, 2016 at 9:57 PM, Jakub Jelinek <ja...@redhat.com> wrote: > Hi! > > On the builtin-arith-overflow-p-1{2,3}.c testcases (posted earlier today) > i?86 miscompiles e.g. t111_4mul function. Before peephole2 we have: > (insn 9 6 50 2 (parallel [ > (set (reg:CCO 17 flags) > (eq:CCO (mult:DI (sign_extend:DI (reg/v:SI 0 ax [orig:90 x ] > [90])) > (const_int -1073741824 [0xffffffffc0000000])) > (sign_extend:DI (mult:SI (reg/v:SI 0 ax [orig:90 x ] [90]) > (const_int -1073741824 [0xffffffffc0000000]))))) > (set (reg:SI 1 dx [91]) > (mult:SI (reg/v:SI 0 ax [orig:90 x ] [90]) > (const_int -1073741824 [0xffffffffc0000000]))) > ]) builtin-arith-overflow-p-12.i:35 326 {*mulvsi4_1} > (expr_list:REG_UNUSED (reg:SI 1 dx [91]) > (nil))) > > (insn 50 9 51 2 (set (reg:QI 1 dx [orig:89 _5+4 ] [89]) > (eq:QI (reg:CCO 17 flags) > (const_int 0 [0]))) builtin-arith-overflow-p-12.i:35 631 > {*setcc_qi} > (expr_list:REG_DEAD (reg:CCO 17 flags) > (nil))) > > (insn 51 50 16 2 (set (reg:SI 1 dx [orig:89 _5+4 ] [89]) > (zero_extend:SI (reg:QI 1 dx [orig:89 _5+4 ] [89]))) > builtin-arith-overflow-p-12.i:35 130 {*zero_extendqisi2} > (nil)) > > and the setcc+movzbl peephole ignores the dx = ax * -1073741824 > SET in the PARALLEL, because it isn't a CLOBBER and thus initializes > %edx before insn 9, then insn 9 overwrites it and later on we store > the QImode part, assuming the rest is zero. > Fixed by using reg_set_p, to actually test if the operands[3] REG > is SET or CLOBBERed. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Please also change similar peephole2 pattern (that does a zext with an and insn) a couple of patterns below the one you are changing. The patch is OK for mainline and also release branches. Thanks, Uros.