public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR tree-optimization/PR68305] Support masked COND_EXPR in SLP
@ 2015-11-12 12:04 Ilya Enkovich
  2015-11-12 12:33 ` Richard Biener
  2015-12-18 16:52 ` H.J. Lu
  0 siblings, 2 replies; 3+ messages in thread
From: Ilya Enkovich @ 2015-11-12 12:04 UTC (permalink / raw)
  To: gcc-patches

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:

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH, PR tree-optimization/PR68305] Support masked COND_EXPR in SLP
  2015-11-12 12:04 [PATCH, PR tree-optimization/PR68305] Support masked COND_EXPR in SLP Ilya Enkovich
@ 2015-11-12 12:33 ` Richard Biener
  2015-12-18 16:52 ` H.J. Lu
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Biener @ 2015-11-12 12:33 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: GCC Patches

On Thu, Nov 12, 2015 at 1:03 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> 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?

Ok.

Thanks,
Richard.

> 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:

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH, PR tree-optimization/PR68305] Support masked COND_EXPR in SLP
  2015-11-12 12:04 [PATCH, PR tree-optimization/PR68305] Support masked COND_EXPR in SLP Ilya Enkovich
  2015-11-12 12:33 ` Richard Biener
@ 2015-12-18 16:52 ` H.J. Lu
  1 sibling, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2015-12-18 16:52 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: GCC Patches

On Thu, Nov 12, 2015 at 4:03 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> 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 } } */
> +
>

Since this is a compile test, there is no need for AVX run-time.
I checked in this as an obvious fix.

-- 
H.J.
---
Index: ChangeLog
===================================================================
--- ChangeLog (revision 231819)
+++ ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2015-12-18  H.J. Lu  <hongjiu.lu@intel.com>
+
+ * gcc.dg/vect/pr68305.c (dg-additional-options): Add -mavx2
+ for x86 target.
+
 2015-12-18  Nathan Sidwell  <nathan@acm.org>

  * c-c++-common/attr-simd-3.c: Requires pthreads.
Index: gcc.dg/vect/pr68305.c
===================================================================
--- gcc.dg/vect/pr68305.c (revision 231819)
+++ gcc.dg/vect/pr68305.c (working copy)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-additional-options "-O3" } */
-/* { dg-additional-options "-mavx2" { target avx_runtime } } */
+/* { dg-additional-options "-mavx2" { target { i?86-*-* x86_64-*-* } } } */

 int a, b;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-18 16:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 12:04 [PATCH, PR tree-optimization/PR68305] Support masked COND_EXPR in SLP Ilya Enkovich
2015-11-12 12:33 ` Richard Biener
2015-12-18 16:52 ` H.J. Lu

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).