public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-8625] middle-end: don't lower past veclower [PR106063]
Date: Wed, 27 Jul 2022 09:24:14 +0000 (GMT)	[thread overview]
Message-ID: <20220727092414.56BF2385AC2F@sourceware.org> (raw)

https://gcc.gnu.org/g:13d23c313374e15186f33fa6d57a0c9fd5d8b486

commit r12-8625-g13d23c313374e15186f33fa6d57a0c9fd5d8b486
Author: Tamar Christina <tamar.christina@arm.com>
Date:   Fri Jul 8 08:30:22 2022 +0100

    middle-end: don't lower past veclower [PR106063]
    
    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 unless the target supports
    the operation.  If before veclower do the rewriting as well if the target didn't
    support the original operation either.
    
    gcc/ChangeLog:
    
            PR tree-optimization/106063
            * match.pd: Do not apply pattern after veclower is not supported.
    
    gcc/testsuite/ChangeLog:
    
            PR tree-optimization/106063
            * gcc.dg/pr106063.c: New test.
    
    (cherry picked from commit f7854e2faf7640230062dec3596e71773ca500ed)

Diff:
---
 gcc/match.pd                    | 14 ++++++++++----
 gcc/testsuite/gcc.dg/pr106063.c |  9 +++++++++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index fa59624d66b..e3bb7c9ae4c 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -5789,10 +5789,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    (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 (TYPE_UNSIGNED (TREE_TYPE (@1)))
-       (icmp @0 { csts; })
-       (with { tree utype = unsigned_type_for (TREE_TYPE (@1)); }
-	 (icmp (view_convert:utype @0) { csts; }))))))))
+      (with { auto optab = VECTOR_TYPE_P (TREE_TYPE (@1))
+			 ? optab_vector : optab_default;
+	      tree utype = unsigned_type_for (TREE_TYPE (@1)); }
+       (if (target_supports_op_p (utype, icmp, optab)
+	    || (optimize_vectors_before_lowering_p ()
+		&& (!target_supports_op_p (type, cmp, optab)
+		    || !target_supports_op_p (type, BIT_AND_EXPR, optab))))
+	(if (TYPE_UNSIGNED (TREE_TYPE (@1)))
+	 (icmp @0 { csts; })
+	 (icmp (view_convert:utype @0) { csts; })))))))))
 
 /* When one argument is a constant, overflow detection can be simplified.
    Currently restricted to single use so as not to interfere too much with
diff --git a/gcc/testsuite/gcc.dg/pr106063.c b/gcc/testsuite/gcc.dg/pr106063.c
new file mode 100644
index 00000000000..b23596724f6
--- /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-27  9:24 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=20220727092414.56BF2385AC2F@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@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).