I'd like for combine to perform the following simplification:
(insn 14 13 16 0 /home/hp/combined/combined/gcc/config/cris/arit.c:228
(parallel [
(set (reg/v:SI 27 [ b.67 ])
(abs:SI (reg/v:SI 47 [ b ])))
(clobber (reg:CC 19 dccr))
]) 158 {abssi2} (insn_list:REG_DEP_TRUE 7 (nil))
(expr_list:REG_UNUSED (reg:CC 19 dccr)
(nil)))
(jump_insn 17 16 19 0 /home/hp/combined/combined/gcc/config/cris/arit.c:178
(parallel [
(set (pc)
(if_then_else (ge (abs:SI (reg/v:SI 47 [ b ]))
(const_int 0 [0x0]))
(label_ref 24)
(pc)))
(clobber (reg:CC 19 dccr))
]) 1 {cris_cbranchsi4} (insn_list:REG_DEP_TRUE 14 (nil))
(expr_list:REG_UNUSED (reg:CC 19 dccr)
(expr_list:REG_BR_PROB (const_int 7900 [0x1edc])
(nil))))
into:
(insn 14 13 16 0 /home/hp/combined/combined/gcc/config/cris/arit.c:228
(parallel [
(set (reg/v:SI 27 [ b.67 ])
(abs:SI (reg/v:SI 47 [ b ])))
(clobber (reg:CC 19 dccr))
]) 158 {abssi2} (insn_list:REG_DEP_TRUE 7 (nil))
(expr_list:REG_UNUSED (reg:CC 19 dccr)
(nil)))
(jump_insn 17 16 19 0 /home/hp/combined/combined/gcc/config/cris/arit.c:178
(set (pc) (label_ref 24)) 1 {jump}
(insn_list:REG_DEP_TRUE 14 (nil)))
(beware, edited RTL.) However, it doesn't, as trading two for
two-with-a-lesser-cost is currently not done; comments mention
fear of recursion or oscillation. That shouldn't happen if the
rtx cost is considered and is nearly sane.
If you think this optimization is misplaced, I see no pass
*after* combine, that is expected to this perform
simplification. Maybe the SSA optimizations before this pass
should cover it, but they don't, at least not with 108225
compiling libgcc/_divsi3.o for cris-axis-linux-gnu (there's an
abs in a caller, with a < 0 test in an inlined function). This
function is the top pessimized for my non-cc0 CRIS wip. Anyway,
arguments like "no, do it in SSA" miss the point and will be
ignored; things have different shape at the RTL level and may
not be apparent in SSA. (Yes, SSA might have a flow exposed
here, if so, it should probably be fixed *too*.)
Note also that the cc0-equivalent of the above is simplified by
combine:
(insn 14 13 16 0 /home/hp/combined/combined/gcc/config/cris/arit.c:228 (set
(reg/v:SI 27 [ b.67 ])
(abs:SI (reg/v:SI 47 [ b ]))) 148 {abssi2} (insn_list:REG_DEP_TRUE 7
(nil))
(nil))
(insn 17 16 18 0 /home/hp/combined/combined/gcc/config/cris/arit.c:178 (set
(cc0)
(reg/v:SI 27 [ b.67 ])) 1 {tstsi} (insn_list:REG_DEP_TRUE 14 (nil))
(nil))
(jump_insn 18 17 20 0 /home/hp/combined/combined/gcc/config/cris/arit.c:178
(set (pc)
(if_then_else (ge (abs:SI (reg/v:SI 47 [ b ]))
(const_int 0 [0x0]))
(label_ref 26)
(pc))) 162 {bge} (nil)
(expr_list:REG_BR_PROB (const_int 7900 [0x1edc])
(nil)))
is simplified to:
(insn 14 13 16 0 /home/hp/combined/combined/gcc/config/cris/arit.c:228 (set
(reg/v:SI 27 [ b.67 ])
(abs:SI (reg/v:SI 47 [ b ]))) 148 {abssi2} (insn_list:REG_DEP_TRUE 7
(nil))
(nil))
(jump_insn 18 17 20 0 /home/hp/combined/combined/gcc/config/cris/arit.c:178
(set (pc)
(label_ref 26)) 162 {bge} (nil)
(expr_list:REG_BR_PROB (const_int 7900 [0x1edc])
(nil)))
(right after substitutions) and combine allows this, being a
three-for-two (with-lesser-cost) transformation.
The actual code should be simple; I just want to check that
there's consensus on the actual change before doing it.
Thoughts?
brgds, H-P