public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tamar Christina <tamar.christina@arm.com>
To: gcc-patches@gcc.gnu.org
Cc: nd@arm.com, rguenther@suse.de
Subject: [PATCH]middle-end: don't lower past veclower [PR106063]
Date: Tue, 5 Jul 2022 16:00:45 +0100	[thread overview]
Message-ID: <patch-15911-tamar@arm.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1743 bytes --]

Hi All,

My previous patch can cause a problem if the pattern matches after veclower
as it may replace the construct with a vector sequence which the target may not
directly support.

As such don't perform the rewriting if after veclower.

Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu
and no issues.

Ok for master? and backport to GCC 12?

Thanks,
Tamar


gcc/ChangeLog:

	PR tree-optimization/106063
	* match.pd: Do not apply pattern after veclower.

gcc/testsuite/ChangeLog:

	PR tree-optimization/106063
	* gcc.dg/pr106063.c: New test.

--- inline copy of patch -- 
diff --git a/gcc/match.pd b/gcc/match.pd
index 40c09bedadb89dabb6622559a8f69df5384e61fd..ba161892a98756c0278dc40fc377d7d0deaacbcf 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -6040,7 +6040,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (simplify
    (cmp (bit_and:c@2 @0 cst@1) integer_zerop)
     (with { tree csts = bitmask_inv_cst_vector_p (@1); }
-     (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2)))
+     (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2))
+	  && optimize_vectors_before_lowering_p ())
       (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
        (icmp @0 { csts; })
        (with { tree utype = unsigned_type_for (TREE_TYPE (@1)); }
diff --git a/gcc/testsuite/gcc.dg/pr106063.c b/gcc/testsuite/gcc.dg/pr106063.c
new file mode 100644
index 0000000000000000000000000000000000000000..b23596724f6bb98c53af2dce77d31509bab10378
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr106063.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-forwprop --disable-tree-evrp" } */
+typedef __int128 __attribute__((__vector_size__ (16))) V;
+
+V
+foo (V v)
+{
+  return (v & (V){15}) == v;
+}




-- 

[-- Attachment #2: rb15911.patch --]
[-- Type: text/plain, Size: 1143 bytes --]

diff --git a/gcc/match.pd b/gcc/match.pd
index 40c09bedadb89dabb6622559a8f69df5384e61fd..ba161892a98756c0278dc40fc377d7d0deaacbcf 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -6040,7 +6040,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (simplify
    (cmp (bit_and:c@2 @0 cst@1) integer_zerop)
     (with { tree csts = bitmask_inv_cst_vector_p (@1); }
-     (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2)))
+     (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2))
+	  && optimize_vectors_before_lowering_p ())
       (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
        (icmp @0 { csts; })
        (with { tree utype = unsigned_type_for (TREE_TYPE (@1)); }
diff --git a/gcc/testsuite/gcc.dg/pr106063.c b/gcc/testsuite/gcc.dg/pr106063.c
new file mode 100644
index 0000000000000000000000000000000000000000..b23596724f6bb98c53af2dce77d31509bab10378
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr106063.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-forwprop --disable-tree-evrp" } */
+typedef __int128 __attribute__((__vector_size__ (16))) V;
+
+V
+foo (V v)
+{
+  return (v & (V){15}) == v;
+}




             reply	other threads:[~2022-07-05 15:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05 15:00 Tamar Christina [this message]
2022-07-06 13:14 ` Jeff Law
2022-07-07  7:18 ` Richard Biener
2022-07-07  7:41   ` Tamar Christina
2022-07-07  7:47     ` Richard Biener
2022-07-08  6:26       ` Tamar Christina
2022-07-08  7:16         ` Richard Biener

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=patch-15911-tamar@arm.com \
    --to=tamar.christina@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=nd@arm.com \
    --cc=rguenther@suse.de \
    /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).