public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR68956, committed] Fix constants used for boolean vectors
@ 2015-12-18  9:37 Ilya Enkovich
  0 siblings, 0 replies; only message in thread
From: Ilya Enkovich @ 2015-12-18  9:37 UTC (permalink / raw)
  To: gcc-patches

Hi,

Here is a trivial patch to fix boolean vector invariants.  Bootstrapped and tested on x86_64-pc-linux-gnu.  Applied to trunk.

Thanks,
Ilya
--
gcc/

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

	PR tree-optimization/68956
	* tree-vect-stmts.c (vect_init_vector): Fix constants
	used for boolean vectors.

gcc/testsuite

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

	PR tree-optimization/68956
	* gcc.target/i386/pr68956.c: New test.


diff --git a/gcc/testsuite/gcc.target/i386/pr68956.c b/gcc/testsuite/gcc.target/i386/pr68956.c
new file mode 100644
index 0000000..4fb2ced
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr68956.c
@@ -0,0 +1,67 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ffast-math -mfpmath=sse -mavx2 -ftree-vectorize" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+extern void abort (void);
+
+int l;
+
+static void __attribute__((noclone,noinline))
+test1 (double *in1, double *in2, double *out,
+       int l1, int l2, int *n)
+{
+  double sum;
+  int na = n[0];
+  int nb = n[1];
+  int i;
+  _Bool ic, jc;
+
+  jc = (l > na) && (l > nb);
+  for (int i = 0; i < l2; i++)
+    {
+      ic = (i <= na) && (i <= nb);
+      sum = 0;
+      if (ic && jc)
+	sum = in1[i] + in2[i];
+      out[i] = sum;
+    }
+}
+
+static void
+avx2_test (void)
+{
+  double in1[40], in2[40], out[40], sum;
+  int n[2],l1,l2,i,na,nb;
+  _Bool ic, jc;
+
+  l = 0;
+  l1 = 8;
+  l2 = 40;
+  n[0] = 14;
+  n[1] = 13;
+
+  for (i = 0; i < l2; i++)
+    {
+      in1[i] = i;
+      in2[i] = i;
+      out[i] = 0;
+    }
+
+  test1 (in1, in2, out, l1, l2, n);
+
+  na = n[0];
+  nb = n[1];
+
+  jc = (l > na) && (l > nb);
+  for (int i = 0; i < l2; i++)
+    {
+      ic = (i <= na) && (i <= nb);
+      sum = 0;
+      if (ic && jc)
+	sum = in1[i] + in2[i];
+      if (out[i] != sum)
+	abort ();
+    }
+}
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index b1342fb..7c6fa73 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -1304,8 +1304,8 @@ vect_init_vector (gimple *stmt, tree val, tree type, gimple_stmt_iterator *gsi)
 	     all zeros or all ones value before building a vector.  */
 	  if (VECTOR_BOOLEAN_TYPE_P (type))
 	    {
-	      tree true_val = build_zero_cst (TREE_TYPE (type));
-	      tree false_val = build_all_ones_cst (TREE_TYPE (type));
+	      tree true_val = build_all_ones_cst (TREE_TYPE (type));
+	      tree false_val = build_zero_cst (TREE_TYPE (type));
 
 	      if (CONSTANT_CLASS_P (val))
 		val = integer_zerop (val) ? false_val : true_val;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-12-18  9:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-18  9:37 [PATCH, PR68956, committed] Fix constants used for boolean vectors Ilya Enkovich

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