https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68595

--- Comment #7 from Ilya Enkovich <ienkovich at gcc dot gnu.org> ---
Right, scalar value needs to be adjusted before building a vector.  This patch
should resolve the issue:

diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 687f982..6e4b046 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -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
            {

Reply via email to