]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
MATCH: Simplify `(X % Y) < Y` pattern.
authorAndrew Pinski <apinski@marvell.com>
Tue, 12 Sep 2023 17:43:23 +0000 (10:43 -0700)
committerAndrew Pinski <apinski@marvell.com>
Wed, 13 Sep 2023 12:03:08 +0000 (05:03 -0700)
This merges the two patterns to catch
`(X % Y) < Y` and `Y > (X % Y)` into one by
using :c on the comparison operator.
It does not change any code generation nor
anything else. It is more to allow for better
maintainability of this pattern.

OK? Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

PR tree-optimization/111345
* match.pd (`Y > (X % Y)`): Merge
into ...
(`(X % Y) < Y`): Pattern by adding `:c`
on the comparison.

gcc/match.pd

index 693638f8ca03dd63f760de7facc229680130495b..0d865d8295f1ebc77a40ef3815c08a2c46d79a2a 100644 (file)
@@ -1486,14 +1486,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 /* X % Y is smaller than Y.  */
 (for cmp (lt ge)
  (simplify
-  (cmp (trunc_mod @0 @1) @1)
+  (cmp:c (trunc_mod @0 @1) @1)
   (if (TYPE_UNSIGNED (TREE_TYPE (@0)))
    { constant_boolean_node (cmp == LT_EXPR, type); })))
-(for cmp (gt le)
- (simplify
-  (cmp @1 (trunc_mod @0 @1))
-  (if (TYPE_UNSIGNED (TREE_TYPE (@0)))
-   { constant_boolean_node (cmp == GT_EXPR, type); })))
 
 /* x | ~0 -> ~0  */
 (simplify