https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109610
--- Comment #3 from Hongtao.liu <crazylht at gmail dot com> ---
>
> And after my commit, RA take best scenario when preferred reg_class is
> unkown, which make cost of MEM:0,0 of r117 same as VSX_REGS:0,0, and
> allocate r117 as VSX_REGS, which create an extra move and failed the
> testcase.
The extra move normally can be eliminated by reload if both src and dest have
same reg_class, but here src is VSX_REGS and dest is GENERAL_REGS.
Maybe we should add a little bit extra cost to best scenario to make RA handle
such redundancy but not relies on pass_reload for that.
@@ -1580,7 +1580,7 @@ scan_one_insn (rtx_insn *insn)
int num = COST_INDEX (REGNO (reg));
COSTS (costs, num)->mem_cost
- -= ira_memory_move_cost[GET_MODE (reg)][cl][1] * frequency;
+ -= (ira_memory_move_cost[GET_MODE (reg)][cl][1] + 1) * frequency;
1 unit cost is aligned with what's did in recog_reg_class
/* If the alternative actually allows memory, make
things a bit cheaper since we won't need an extra
insn to load it. */
pp->mem_cost
= ((out_p ? ira_memory_move_cost[mode][op_class][0] : 0)
+ (in_p ? ira_memory_move_cost[mode][op_class][1] : 0)
- allows_mem[i]) * frequency;