https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101523

--- Comment #26 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So looking into the s390 backend, I notice that s390_address_cost says the
addressing mode `base+index` is slightly more expensive than just `base`:
from s390_address_cost :
  return ad.indx? COSTS_N_INSNS (1) + 1 : COSTS_N_INSNS (1);

BUT then s390_rtx_costs when looking at MEM does not take into account the
addressing for the cost there (it does take into account on the LHS though):
```
    case MEM:
      *total = 0;
      return true;
```

This mismatch does cause some issues. Basically fwprop uses address_cost to
figure out when it is replacing into MEM but combine just uses
insn_cost/rtx_cost .  So while fwprop rejects it as being worse and then
combine comes along and does it.

I suspect if we change the s390 backend just slightly to set the cost when
there is an index to the address to 1 for the MEM, combine won't be acting up
here.
Basically putting in sync the 2 cost methods.

Reply via email to