public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tamar Christina <tnfchris@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-6038] slp: check that the operation we're combing is a boolean operation [PR103741]
Date: Fri, 17 Dec 2021 11:00:36 +0000 (GMT)	[thread overview]
Message-ID: <20211217110036.8B5DC3858410@sourceware.org> (raw)

https://gcc.gnu.org/g:411ac94611f164fac7ec1cd5953549c0a56cf43a

commit r12-6038-g411ac94611f164fac7ec1cd5953549c0a56cf43a
Author: Tamar Christina <tamar.christina@arm.com>
Date:   Fri Dec 17 10:59:25 2021 +0000

    slp: check that the operation we're combing is a boolean operation [PR103741]
    
    It seems I forgot to check that the operation we're combing when masking the
    predicated together are actually predicates types.
    
    Without it we end up accidentally trying to combine a value and a mask.
    
    gcc/ChangeLog:
    
            PR tree-optimization/103741
            * tree-vect-stmts.c (vectorizable_operation): Check for boolean.
    
    gcc/testsuite/ChangeLog:
    
            PR tree-optimization/103741
            * gcc.target/aarch64/pr103741.c: New test.

Diff:
---
 gcc/testsuite/gcc.target/aarch64/pr103741.c | 26 ++++++++++++++++++++++++++
 gcc/tree-vect-stmts.c                       |  4 +++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/aarch64/pr103741.c b/gcc/testsuite/gcc.target/aarch64/pr103741.c
new file mode 100644
index 00000000000..ef3ae66ebe5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr103741.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-march=armv8-a+sve -O1" } */
+
+long int m, n;
+
+int
+qux (int z)
+{
+  return 4 >> z ? z : 0;
+}
+
+int
+bar (long int y)
+{
+  return y ? 3 : 2;
+}
+
+__attribute__ ((simd)) int
+foo (int x)
+{
+  long int a = x & m;
+  int b = bar (x) / n;
+
+  return qux (b) == a;
+}
+
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 8c427174b37..ad90cdb0473 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -6361,7 +6361,9 @@ vectorizable_operation (vec_info *vinfo,
 	  /* When combining two masks check if either of them is elsewhere
 	     combined with a loop mask, if that's the case we can mark that the
 	     new combined mask doesn't need to be combined with a loop mask.  */
-	  if (masked_loop_p && code == BIT_AND_EXPR)
+	  if (masked_loop_p
+	      && code == BIT_AND_EXPR
+	      && VECTOR_BOOLEAN_TYPE_P (vectype))
 	    {
 	      if (loop_vinfo->scalar_cond_masked_set.contains ({ op0,
 								 ncopies}))


                 reply	other threads:[~2021-12-17 11:00 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=20211217110036.8B5DC3858410@sourceware.org \
    --to=tnfchris@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).