https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101179
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- But here are two other functions which all should have the same code gen as the original two: int f3(int y) { const bool x = y % 100 == 0; return (x ? y%16 : y%4) == 0; } int f4(int y) { const bool x = y % 100 == 0; return (x ? (y%16) == 0 : (y%4) == 0); } Only the last one produces the best code.