public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-3921] MATCH: Simplify `(X % Y) < Y` pattern.
@ 2023-09-13 12:04 Andrew Pinski
  0 siblings, 0 replies; only message in thread
From: Andrew Pinski @ 2023-09-13 12:04 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:635a34e2be67d709088c31573732dfdf733e4cec

commit r14-3921-g635a34e2be67d709088c31573732dfdf733e4cec
Author: Andrew Pinski <apinski@marvell.com>
Date:   Tue Sep 12 10:43:23 2023 -0700

    MATCH: Simplify `(X % Y) < Y` pattern.
    
    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.

Diff:
---
 gcc/match.pd | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index 693638f8ca03..0d865d8295f1 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-13 12:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-13 12:04 [gcc r14-3921] MATCH: Simplify `(X % Y) < Y` pattern Andrew Pinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).