https://gcc.gnu.org/g:94ae11aca04a83ffa5120a05e69fa1b8ca0cee23
commit r16-5552-g94ae11aca04a83ffa5120a05e69fa1b8ca0cee23 Author: Andrew Pinski <[email protected]> Date: Mon Oct 13 20:42:53 2025 -0700 match: Move `(pointer_diff (pointer_plus @0 @2) (pointer_plus @1 @2))` pattern earlier 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. 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]> Diff: --- gcc/match.pd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 5618f7296376..36d8f2f72750 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
