http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57702
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Another example: unsigned int foo (unsigned int x, unsigned int y) { x += y; x += y; x += y; x += y; x += y; return x; } Seems for the x += 7 * y; x += 12 * y; case it is undistribute_ops_list that performs this optimization. For non-wrapping integers we give up very early, can_reassociate_p returns false and we don't try anything, perhaps with care we could try at least undistribution, provided that we are very careful not to reorder anything, only undistribute adjacent operations. For unsigned integers, we give up because we never consider an SSA_NAME to be 1 * SSA_NAME for the purposes of undistribution.