On Sun, Nov 23, 2025 at 10:54 PM Andrew Pinski <[email protected]> wrote: > > This moves the `(pointer_diff (pointer_plus @0 @2) (pointer_plus @1 @2))` > pattern > to right below the `(pointer_diff (pointer_plus @0 @1) (pointer_plus @0 @2))` > pattern > to make easier to see both versions are supported. > > Bootstrapped and tested on x86_64-linux-gnu.
OK. > gcc/ChangeLog: > > * match.pd (`(ptr_diff (ptr_plus @0 @2) (ptr_plus @1 @2))`): Move > pattern > earlier to the other `(ptr_diff (ptr_plus) (ptr_plus))` pattern. > > Signed-off-by: Andrew Pinski <[email protected]> > --- > gcc/match.pd | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/gcc/match.pd b/gcc/match.pd > index 5618f729637..36d8f2f7275 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -2860,6 +2860,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > (pointer_diff (pointer_plus @0 @1) (pointer_plus @0 @2)) > (if (TYPE_OVERFLOW_WRAPS (TREE_TYPE (@1))) > (convert (minus @1 @2)))) > +(simplify > + (pointer_diff (pointer_plus @0 @2) (pointer_plus @1 @2)) > + (pointer_diff @0 @1)) > > /* X - Z < Y - Z is the same as X < Y when there is no overflow. */ > (for op (lt le ge gt) > @@ -4651,9 +4654,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > && TREE_CODE (@2) == INTEGER_CST > && tree_int_cst_sign_bit (@2) == 0)) > (minus (convert @1) (convert @2))))) > - (simplify > - (pointer_diff (pointer_plus @0 @2) (pointer_plus @1 @2)) > - (pointer_diff @0 @1)) > (simplify > (pointer_diff (pointer_plus @@0 @1) (pointer_plus @0 @2)) > /* The second argument of pointer_plus must be interpreted as signed, and > -- > 2.43.0 >
