------- Comment #19 from steven at gcc dot gnu dot org  2010-02-10 23:47 -------
In r118474, cse.c:find_best_addr makes the replacement here:

          if ((addr_folded_cost < addr_cost
               || (addr_folded_cost == addr_cost
                   /* ??? The rtx_cost comparison is left over from an older
                      version of this code.  It is probably no longer
helpful.*/
                   && (rtx_cost (folded, MEM) > rtx_cost (addr, MEM)
                       || approx_reg_cost (folded) < approx_reg_cost (addr))))
              && validate_change (insn, loc, folded, 0))
            addr = folded;

All the costs are the same, except the approx_reg_cost tests:

(gdb) p debug_rtx(addr)
(plus:SI (reg/f:SI 102)
    (const_int 4 [0x4]))
$35 = void
(gdb) p debug_rtx(folded)
(plus:SI (reg/f:SI 25 sfp)
    (const_int -8 [0xfffffffffffffff8]))
$36 = void
(gdb) p approx_reg_cost(addr)
$37 = 1
(gdb) p approx_reg_cost(folded)
$38 = 0
(gdb) 

The cost difference comes from approx_reg_cost_1, which uses CHEAP_REGNO for
regs. CHEAP_REGNO prefers the frame pointer reg over normal pseudos:

/* Compute cost of X, as stored in the `cost' field of a table_elt.  Fixed
   hard registers and pointers into the frame are the cheapest with a cost
   of 0.  Next come pseudos with a cost of one and other hard registers with
   a cost of 2.  Aside from these special cases, call `rtx_cost'.  */

#define CHEAP_REGNO(N)                                                  \
  (REGNO_PTR_FRAME_P(N)                                                 \
   || (HARD_REGISTER_NUM_P (N)                                          \
       && FIXED_REGNO_P (N) && REGNO_REG_CLASS (N) != NO_REGS))

This shouldn't be very difficult to teach fwprop about, too.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39871

Reply via email to