public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ilya Enkovich <enkovich.gnu@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH, PR tree-optimization/PR68305] Support masked COND_EXPR in SLP
Date: Thu, 12 Nov 2015 12:04:00 -0000	[thread overview]
Message-ID: <20151112120340.GB51435@msticlxl57.ims.intel.com> (raw)

Hi,

This patch fixes a way operand is chosen by its num for COND_EXPR.  Bootstrapped and regtested on x86_64-unknown-linux-gnu.  OK for trunk?

Thanks,
Ilya
--
gcc/

2015-11-12  Ilya Enkovich  <enkovich.gnu@gmail.com>

	PR tree-optimization/68305
	* tree-vect-slp.c (vect_get_constant_vectors): Support
	COND_EXPR with SSA_NAME as a condition.

gcc/testsuite/

2015-11-12  Ilya Enkovich  <enkovich.gnu@gmail.com>

	PR tree-optimization/68305
	* gcc.dg/vect/pr68305.c: New test.


diff --git a/gcc/testsuite/gcc.dg/vect/pr68305.c b/gcc/testsuite/gcc.dg/vect/pr68305.c
new file mode 100644
index 0000000..fde3db7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr68305.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3" } */
+/* { dg-additional-options "-mavx2" { target avx_runtime } } */
+
+int a, b;
+
+void
+fn1 ()
+{
+  int c, d;
+  for (; b; b++)
+    a = a ^ !c ^ !d;
+}
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 9d97140..9402474 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -2738,18 +2738,20 @@ vect_get_constant_vectors (tree op, slp_tree slp_node,
 	      switch (code)
 		{
 		  case COND_EXPR:
-		    if (op_num == 0 || op_num == 1)
-		      {
-			tree cond = gimple_assign_rhs1 (stmt);
+		    {
+		      tree cond = gimple_assign_rhs1 (stmt);
+		      if (TREE_CODE (cond) == SSA_NAME)
+			op = gimple_op (stmt, op_num + 1);
+		      else if (op_num == 0 || op_num == 1)
 			op = TREE_OPERAND (cond, op_num);
-		      }
-		    else
-		      {
-			if (op_num == 2)
-			  op = gimple_assign_rhs2 (stmt);
-			else
-			  op = gimple_assign_rhs3 (stmt);
-		      }
+		      else
+			{
+			  if (op_num == 2)
+			    op = gimple_assign_rhs2 (stmt);
+			  else
+			    op = gimple_assign_rhs3 (stmt);
+			}
+		    }
 		    break;
 
 		  case CALL_EXPR:

             reply	other threads:[~2015-11-12 12:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12 12:04 Ilya Enkovich [this message]
2015-11-12 12:33 ` Richard Biener
2015-12-18 16:52 ` H.J. Lu

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=20151112120340.GB51435@msticlxl57.ims.intel.com \
    --to=enkovich.gnu@gmail.com \
    --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).