On Fri, Sep 18, 2020 at 01:13:18PM -0500, Segher Boessenkool wrote: > Thanks (to both of you). Interesting! Which of these unrelated changes > does this come from?
Most of the changes I saw in code generation (not in spec, I didn't look there, but in gcc) came down to this change to the cost for SETs, and "rs6000_rtx_costs multi-insn constants". I expect they were the changes that made most difference to spec results, with this patch likely resulting in more if-conversion. So here is the patch again, this time without any distracting other changes. With a further revised comment. * config/rs6000/rs6000.c (rs6000_rtx_costs): Reduce cost of SET operands. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 8969baa4dcf..2d770afd8fe 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -21599,6 +21599,35 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code, } break; + case SET: + /* On entry the value in *TOTAL is the number of general purpose + regs being set, multiplied by COSTS_N_INSNS (1). Handle + costing of set operands specially since in most cases we have + an instruction rather than just a piece of RTL and should + return a cost comparable to insn_cost. That's a little + complicated because in some cases the cost of SET operands is + non-zero, see point 5 above and cost of PLUS for example, and + in others it is zero, for example for (set (reg) (reg)). + But (set (reg) (reg)) has the same insn_cost as + (set (reg) (plus (reg) (reg))). Hack around this by + subtracting COSTS_N_INSNS (1) from the operand cost in cases + were we add at least COSTS_N_INSNS (1) for some operation. + However, don't do so for constants. Constants might cost + more than zero when they require more than one instruction, + and we do want the cost of extra instructions. */ + { + rtx_code src_code = GET_CODE (SET_SRC (x)); + if (src_code == CONST_INT + || src_code == CONST_DOUBLE + || src_code == CONST_WIDE_INT) + return false; + int set_cost = (rtx_cost (SET_SRC (x), mode, SET, 1, speed) + + rtx_cost (SET_DEST (x), mode, SET, 0, speed)); + if (set_cost >= COSTS_N_INSNS (1)) + *total += set_cost - COSTS_N_INSNS (1); + return true; + } + default: break; } -- Alan Modra Australia Development Lab, IBM