public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] remove duplicate match.pd patterns
Date: Mon, 14 Nov 2022 14:34:57 +0100 (CET)	[thread overview]
Message-ID: <20221114133458.7A9F413A8C@imap2.suse-dmz.suse.de> (raw)

The following merges match.pd patterns that cause genmatch complaints
about duplicates when in-order isn't enforced (you have to edit
genmatch.cc to do a full duplicate check).

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	* match.pd: Remove duplicates.
---
 gcc/match.pd | 63 +++++++++++++++++++++++++---------------------------
 1 file changed, 30 insertions(+), 33 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index 194ba8f5188..4d0898ccdcb 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -1285,8 +1285,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 
 /* ~x | x -> -1 */
 /* ~x ^ x -> -1 */
-/* ~x + x -> -1 */
-(for op (bit_ior bit_xor plus)
+(for op (bit_ior bit_xor)
  (simplify
   (op:c (convert? @0) (convert? (bit_not @0)))
   (convert { build_all_ones_cst (TREE_TYPE (@0)); })))
@@ -2939,9 +2938,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 
   /* ~A + A -> -1 */
   (simplify
-   (plus:c (bit_not @0) @0)
+   (plus:c (convert? (bit_not @0)) (convert? @0))
    (if (!TYPE_OVERFLOW_TRAPS (type))
-    { build_all_ones_cst (type); }))
+    (convert { build_all_ones_cst (TREE_TYPE (@0)); })))
 
   /* ~A + 1 -> -A */
   (simplify
@@ -5103,34 +5102,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    (scmp @0 (bit_not @1)))))
 
 (for cmp (simple_comparison)
- /* Fold (double)float1 CMP (double)float2 into float1 CMP float2.  */
- (simplify
-  (cmp (convert@2 @0) (convert? @1))
-  (if (FLOAT_TYPE_P (TREE_TYPE (@0))
-       && (DECIMAL_FLOAT_TYPE_P (TREE_TYPE (@2))
-	   == DECIMAL_FLOAT_TYPE_P (TREE_TYPE (@0)))
-       && (DECIMAL_FLOAT_TYPE_P (TREE_TYPE (@2))
-	   == DECIMAL_FLOAT_TYPE_P (TREE_TYPE (@1))))
-   (with
-    {
-      tree type1 = TREE_TYPE (@1);
-      if (TREE_CODE (@1) == REAL_CST && !DECIMAL_FLOAT_TYPE_P (type1))
-        {
-	  REAL_VALUE_TYPE orig = TREE_REAL_CST (@1);
-	  if (TYPE_PRECISION (type1) > TYPE_PRECISION (float_type_node)
-	      && exact_real_truncate (TYPE_MODE (float_type_node), &orig))
-	    type1 = float_type_node;
-	  if (TYPE_PRECISION (type1) > TYPE_PRECISION (double_type_node)
-	      && exact_real_truncate (TYPE_MODE (double_type_node), &orig))
-	    type1 = double_type_node;
-        }
-      tree newtype
-        = (TYPE_PRECISION (TREE_TYPE (@0)) > TYPE_PRECISION (type1)
-	   ? TREE_TYPE (@0) : type1);
-    }
-    (if (TYPE_PRECISION (TREE_TYPE (@2)) > TYPE_PRECISION (newtype))
-     (cmp (convert:newtype @0) (convert:newtype @1))))))
-
  (simplify
   (cmp @0 REAL_CST@1)
   /* IEEE doesn't distinguish +0 and -0 in comparisons.  */
@@ -5683,7 +5654,33 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 	  (if (cmp == LT_EXPR || cmp == LE_EXPR)
 	   { constant_boolean_node (above ? true : false, type); }
 	   (if (cmp == GT_EXPR || cmp == GE_EXPR)
-	    { constant_boolean_node (above ? false : true, type); }))))))))))))
+	    { constant_boolean_node (above ? false : true, type); })))))))))
+   /* Fold (double)float1 CMP (double)float2 into float1 CMP float2.  */
+   (if (FLOAT_TYPE_P (TREE_TYPE (@00))
+	&& (DECIMAL_FLOAT_TYPE_P (TREE_TYPE (@0))
+	    == DECIMAL_FLOAT_TYPE_P (TREE_TYPE (@00)))
+	&& (DECIMAL_FLOAT_TYPE_P (TREE_TYPE (@0))
+	    == DECIMAL_FLOAT_TYPE_P (TREE_TYPE (@10))))
+    (with
+     {
+       tree type1 = TREE_TYPE (@10);
+       if (TREE_CODE (@10) == REAL_CST && !DECIMAL_FLOAT_TYPE_P (type1))
+	 {
+	   REAL_VALUE_TYPE orig = TREE_REAL_CST (@10);
+	   if (TYPE_PRECISION (type1) > TYPE_PRECISION (float_type_node)
+	       && exact_real_truncate (TYPE_MODE (float_type_node), &orig))
+	     type1 = float_type_node;
+	   if (TYPE_PRECISION (type1) > TYPE_PRECISION (double_type_node)
+	       && exact_real_truncate (TYPE_MODE (double_type_node), &orig))
+	     type1 = double_type_node;
+	 }
+      tree newtype
+        = (TYPE_PRECISION (TREE_TYPE (@00)) > TYPE_PRECISION (type1)
+	   ? TREE_TYPE (@00) : type1);
+     }
+     (if (TYPE_PRECISION (TREE_TYPE (@0)) > TYPE_PRECISION (newtype))
+      (cmp (convert:newtype @00) (convert:newtype @10))))))))
+
 
 (for cmp (eq ne)
  (simplify
-- 
2.35.3

                 reply	other threads:[~2022-11-14 13:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221114133458.7A9F413A8C@imap2.suse-dmz.suse.de \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).