https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97997
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- unsigned short f1 (unsigned short x) { return x * 10 / 10; } unsigned short f2 (unsigned short x) { int a = x; int b = 10; int c = 10; return a * b / c; } unsigned short f3 (unsigned short x) { return x * 10U / 10; } unsigned short f4 (unsigned short x) { unsigned a = x; unsigned b = 10; unsigned c = 10; return a * b / c; } For f1 we fold it already during generic folding, f2 we fold during ccp using the /* Simplify (t * 2) / 2) -> t. */ (for div (trunc_div ceil_div floor_div round_div exact_div) (simplify (div (mult:c @0 @1) @1) (if (ANY_INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_UNDEFINED (type)) @0))) rule.