http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56899
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code --- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> 2013-04-10 08:01:22 UTC --- We fold (1 - v) * 214748365 to v * -214748365 + 214748365 which is wrong as it may introduce undefined overflow: /* The last case is if we are a multiply. In that case, we can apply the distributive law to commute the multiply and addition if the multiplication of the constants doesn't overflow. */ if (code == MULT_EXPR) return fold_build2 (tcode, ctype, fold_build2 (code, ctype, fold_convert (ctype, op0), fold_convert (ctype, c)), op1); misses the fact that the multiplication of the non-constant part can also overflow. I think the case has to be removed completely.