]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
match: Move `(pointer_diff (pointer_plus @0 @2) (pointer_plus @1 @2))` pattern earlier
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Tue, 14 Oct 2025 03:42:53 +0000 (20:42 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Mon, 24 Nov 2025 17:07:53 +0000 (09:07 -0800)
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 <andrew.pinski@oss.qualcomm.com>
gcc/match.pd

index 5618f72963761e398e73fac7fc889d7499ab41d0..36d8f2f72750be91f5b8937ce8b3e469f95dfcfb 100644 (file)
@@ -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