------- Comment #16 from steven at gcc dot gnu dot org 2010-02-10 22:50 ------- In fwprop.c of r118475, we get to propagate_rtx_1 (fwprop.c:334):
/* Copy propagations are always ok. Otherwise check the costs. */ if (!(REG_P (old) && REG_P (new)) && !should_replace_address (op0, new_op0, GET_MODE (x))) return true; At this point the simplified address has been found, but fwprop decides not to substitute the new address: (gdb) p debug_rtx(op0) (plus:SI (reg/f:SI 102) (const_int 4 [0x4])) $58 = void (gdb) p debug_rtx(new_op0) (plus:SI (reg/f:SI 25 sfp) (const_int -8 [0xfffffffffffffff8])) $59 = void (gdb) p should_replace_address(op0,new_op0,SImode) $60 = 0 '\000' The replacement isn't done because fwprop sees no benefit in doing the transformation. Stepping through should_replace_address we get: 202 gain = address_cost (old, mode) - address_cost (new, mode); (gdb) next 208 if (gain == 0) (gdb) p gain $64 = 0 (gdb) next 209 gain = rtx_cost (new, SET) - rtx_cost (old, SET); (gdb) 211 return (gain > 0); (gdb) p gain $65 = 0 Perhaps we should prefer addresses based on the frame pointer over other addresses? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39871