https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78332
amker at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amker at gcc dot gnu.org --- Comment #1 from amker at gcc dot gnu.org --- I think there are two issues here. First is the negative cost. It's because we book saved cost of auto-increment addressing mode to use-cand cost, rather than the candidate itself. Given it only makes sense to use auto-increment candidate for the use why it is created, I think we can change the strategy by booking saved cost to candidate it self. This issue could be improved, but not a bug I think. Second is auto-increment candidate is preferred too much. This is again a cost model issue. A. to how much auto-increment should be preferred; B. should register cost be tightened because currently the effect is only spill cost in loop is considered, cost of epilogue/prologue pop/push of more registers is not handled. Also addressing mode costs returned by backend need to be considered too. I will further investigate this later.