https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71170
--- Comment #8 from kugan at gcc dot gnu.org --- My patch is not going to work. At tree-ssa-reassoc.c:3897, we have: stmt: _15 = _4 + c_7(D); oe->op def_stmt: _17 = c_7(D) * 3; <bb 2>: a1_6 = s_5(D) * 2; _1 = (long int) a1_6; x1_8 = _1 + c_7(D); a2_9 = s_5(D) * 4; _2 = (long int) a2_9; a3_11 = s_5(D) * 6; _3 = (long int) a3_11; _16 = x1_8 + c_7(D); _18 = _1 + _2; _4 = _16 + _2; _15 = _4 + c_7(D); _17 = c_7(D) * 3; x_13 = _15 + _3; return x_13; The root cause of this the place in which we are adding (_17 = c_7(D) * 3). Finding the right place is not always straightforward as this case shows. We could try Martin Liška's approach.