https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105903
--- Comment #2 from luoxhu at gcc dot gnu.org --- diff --git a/gcc/match.pd b/gcc/match.pd index 4a570894b2e..f6b5415a351 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -5718,6 +5718,22 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bit_xor (convert (rshift @0 {shifter;})) @1) (bit_not (bit_xor (convert (rshift @0 {shifter;})) @1))))))) +/* X >= Y ? X > Y : 0 into X > Y. */ +(simplify + (cond (ge @0 @1) (gt @0 @1) integer_zerop) + (if (INTEGRAL_TYPE_P (type) + && POINTER_TYPE_P (TREE_TYPE (@0)) + && POINTER_TYPE_P (TREE_TYPE (@1))) + (gt @0 @1))) + +/* X < Y ? 0 : X > Y into X > Y. */ +(simplify + (cond (lt @0 @1) integer_zerop (gt @0 @1)) + (if (INTEGRAL_TYPE_P (type) + && POINTER_TYPE_P (TREE_TYPE (@0)) + && POINTER_TYPE_P (TREE_TYPE (@1))) + (gt @0 @1))) + The two patterns could fold PHI in phiopt4 for the two greater3way and generate expected results.