https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81065
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code Status|UNCONFIRMED |NEW Last reconfirmed| |2017-06-12 Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Thanks for reporting these bugs, they are all latent wrong-code even w/o UBSAN. .original w/o ubsan: ;; Function foo (null) ;; enabled by -tree-original { return (int) x * 14165900 + -77663775; } and as usual, it's extract_muldiv ... (gdb) p debug_generic_expr (op0) (int) x * 1652 + -9057 $1 = void (gdb) p debug_generic_expr (op1) 8575 turning that into (int) x * 14165900 + -77663775 it really means that this kind of distribution is never safe unless we rewrite the inner multiplication into unsigned arithmetic (given the cast of x we do have an idea about the value range of the other operand so we could handle some cases -- but I'd rather not do that in extract_muldiv but in a match.pd pattern). I'd love to say bye-bye to extract_muldiv in it's current state...