https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38939
Segher Boessenkool <segher at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2015-11-23 CC| |segher at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Segher Boessenkool <segher at gcc dot gnu.org> --- The problem is that expand_mult (in expmed.c) calculates the cost of the reg*0x01010101 as six cycles, namely, two to construct the constant in a register and then four for the reg-reg multiply. The shift sequence is just four cycles, so that is chosen. expand_mult does not realise this is within a loop and the construction of the constant will be hoisted out of the loop. Confirmed.