On 04/25/2017 01:31 PM, Jakub Jelinek wrote:
Hi!The following patch is a partial fix for PR80491, an improvement for if-conversion if there is empty else_bb. What we do right now is in that case we only look at the immediately preceeding (non-debug/non-note) instruction before cond_earliest and if it is not the set of x, we just turn it into attempt to use previous value of x rather than whatever it has been initialized to. On the testcases from the PR, we have: (insn 7 4 8 2 (set (reg:DI 97 [ _15+8 ]) (const_int 0 [0])) 81 {*movdi_internal} (nil)) (insn 8 7 9 2 (set (reg:DI 104 [ a_11(D)->low ]) (mem:DI (reg/v/f:DI 101 [ a ]) [2 a_11(D)->low+0 S8 A64])) 81 {*movdi_internal} (nil)) (insn 9 8 10 2 (set (reg:DI 105 [ b_12(D)->low ]) (mem:DI (reg/v/f:DI 102 [ b ]) [2 b_12(D)->low+0 S8 A64])) 81 {*movdi_internal} (nil)) (insn 10 9 11 2 (parallel [ (set (reg:CCC 17 flags) (compare:CCC (plus:DI (reg:DI 104 [ a_11(D)->low ]) (reg:DI 105 [ b_12(D)->low ])) (reg:DI 104 [ a_11(D)->low ]))) (set (reg:DI 103) (plus:DI (reg:DI 104 [ a_11(D)->low ]) (reg:DI 105 [ b_12(D)->low ]))) ]) 316 {*adddi3_cc_overflow_1} (expr_list:REG_DEAD (reg:DI 105 [ b_12(D)->low ]) (expr_list:REG_DEAD (reg:DI 104 [ a_11(D)->low ]) (nil)))) (jump_insn 11 10 14 2 (set (pc) (if_then_else (ltu (reg:CCC 17 flags) (const_int 0 [0])) (label_ref 14) (pc))) 617 {*jcc_1} (expr_list:REG_DEAD (reg:CCC 17 flags) (int_list:REG_BR_PROB 4 (nil))) -> 14) (code_label 14 11 35 3 3 (nil) [1 uses]) (note 35 14 15 3 [bb 3] NOTE_INSN_BASIC_BLOCK) (insn 15 35 16 3 (set (reg:DI 97 [ _15+8 ]) (const_int 1 [0x1])) 81 {*movdi_internal} (nil)) (code_label 16 15 36 4 2 (nil) [0 uses]) If insn 7 would come after insn 9 (which doesn't change the behavior, as insn 8 and insn 9 don't clobber pseudo 97 and const_int 0 is constant), we'd turn that into a setcc pattern, but otherwise we fail. This patch let us search for x's setter earlier in the bb. During testing I found that modified_in_p/modified_in_between_p don't actually take into account calls that could change MEMs, so the patch handles that too. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? During bootstrap/regtest it seems to trigger over 10000 times, but my statistics collection only noted cases where it found an earlier setter and the noce_process_if_block has been successful, has not attempted to check if insn_b/set_b was NULL whether it would otherwise fail (but even in cases where it doesn't fail perhaps with the patch it can generate better code). 2017-04-25 Jakub Jelinek <[email protected]> PR rtl-optimization/80491 * ifcvt.c (noce_process_if_block): When looking for x setter with missing else_bb, don't check only the insn right before cond_earliest, but look for the last insn that x is modified in within the same bb.
OK. jeff
