https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95699
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- As for the difference between the first two functions, that boils down to: unsigned long long f1 (unsigned long long x) { if (x < 0x7fffffffffffffffULL) x = 0x7fffffffffffffffULL; return x; } unsigned long long f2 (unsigned long long x) { if (x < 0x8000000000000000ULL) x = 0x8000000000000000ULL; return x; } where the former is optimized into MAX_EXPR by phiopt1, but the latter is not, because another optimization which transforms such comparison into (long long) x >= 0 stands in a way. Guess we can modify minmax_replacement to virtually undo that.