re PR middle-end/68595 (ice in const_vector_mask_from_tree at expr.c:11455)
authorIlya Enkovich <enkovich.gnu@gmail.com>
Tue, 1 Dec 2015 11:04:06 +0000 (11:04 +0000)
committerIlya Enkovich <ienkovich@gcc.gnu.org>
Tue, 1 Dec 2015 11:04:06 +0000 (11:04 +0000)
gcc/

PR middle-end/68595
* tree-vect-stmts.c (vect_init_vector): Cast boolean
scalars to a proper value before building a vector.

gcc/testsuite/

PR middle-end/68595
* gcc.dg/pr68595.c: New test.

From-SVN: r231106

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr68595.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

index 4dd84c73e74cdd8b01afa6b4445b76c6bbaa674f..48256e9ca85fd36ea19ad0a6b93a306c8a0f5e4d 100644 (file)
@@ -1,3 +1,9 @@
+2015-12-01  Ilya Enkovich  <enkovich.gnu@gmail.com>
+
+       PR middle-end/68595
+       * tree-vect-stmts.c (vect_init_vector): Cast boolean
+       scalars to a proper value before building a vector.
+
 2015-12-01  Richard Sandiford  <richard.sandiford@arm.com>
 
        * genattrtab.c (check_attr_test): Take an attr_desc instead of
index e79db4e8a79c7a3c00c8327f62a682e3f507773e..07a9e521dfc8a4ccc554829316c0cfbc1c3c3cee 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-01  Ilya Enkovich  <enkovich.gnu@gmail.com>
+
+       PR middle-end/68595
+       * gcc.dg/pr68595.c: New test.
+
 2015-12-01  Christian Bruel  <christian.bruel@st.com>
 
        * gcc.target/arm/ftest-armv6-thumb.c: Remove NEED_ARM_FEATURE_UNALIGNED.
diff --git a/gcc/testsuite/gcc.dg/pr68595.c b/gcc/testsuite/gcc.dg/pr68595.c
new file mode 100644 (file)
index 0000000..179c6c3
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+int a, b;
+char c;
+void fn1() {
+  b = 30;
+  for (; b <= 32; b++) {
+    c = -17;
+    for (; c <= 56; c++)
+      a -= 0 == (c || b);
+  }
+}
index 3b078da1320631a3ce2d4dd90ae27aa054c2e54f..5bb2289ada08b86433f51ebf7ae740c284b61fc3 100644 (file)
@@ -1300,7 +1300,25 @@ vect_init_vector (gimple *stmt, tree val, tree type, gimple_stmt_iterator *gsi)
     {
       if (!types_compatible_p (TREE_TYPE (type), TREE_TYPE (val)))
        {
-         if (CONSTANT_CLASS_P (val))
+         /* Scalar boolean value should be transformed into
+            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));
+
+             if (CONSTANT_CLASS_P (val))
+               val = integer_zerop (val) ? false_val : true_val;
+             else
+               {
+                 new_temp = make_ssa_name (TREE_TYPE (type));
+                 init_stmt = gimple_build_assign (new_temp, COND_EXPR,
+                                                  val, true_val, false_val);
+                 vect_init_vector_1 (stmt, init_stmt, gsi);
+                 val = new_temp;
+               }
+           }
+         else if (CONSTANT_CLASS_P (val))
            val = fold_convert (TREE_TYPE (type), val);
          else
            {