https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101024
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #7) > After https://gcc.gnu.org/pipermail/gcc-patches/2023-May/617758.html, these > are testcases that fail if we remove minmax_replacement : > FAIL: gcc.dg/tree-ssa/phi-opt-20.c scan-tree-dump-times phiopt1 "MAX_EXPR" 2 > FAIL: gcc.dg/tree-ssa/phi-opt-20.c scan-tree-dump-times phiopt1 "MIN_EXPR" 2 > > phiopt match-simplify trying: > num_2(D) != 0 ? num_2(D) : 1 > num_2(D) != 4294967295 ? num_2(D) : 4294967294 > num_2(D) != -2147483648 ? num_2(D) : -2147483647 > num_2(D) != 2147483647 ? num_2(D) : 2147483646 > > This should be reasonable to handle minmax_from_comparison and handle eq/ne > for the cases where that is called. I have a patch which also handles when we know the range of non-constant. Like this: ``` int f(int num) { if (num < 3) __builtin_unreachable(); return num != 3 ? num : 4; } ``` That should get a MAX_EXPR(num, 4);