https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112935
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- /* Default RTX cost initializer. */ ... int_mult_si (COSTS_N_INSNS (1)), int_mult_di (COSTS_N_INSNS (1)), That seems wrong. I suspect you will get other improvements when you touch this. E.g. ``` int f(int t) { return t * 17; } ``` Should really be: shift followed by an add. But currently is just a mult. What is interesting is I think -Os cost is the opposite from the -O2 cost ... That is -Os produces the better code generation due to the cost for mult being set to 4: /* RTX costs to use when optimizing for size. */ ... .int_mult_si_ (4) .int_mult_di_ (4)