gcc/
authorienkovich <ienkovich@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Mar 2016 11:17:44 +0000 (11:17 +0000)
committerienkovich <ienkovich@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Mar 2016 11:17:44 +0000 (11:17 +0000)
PR tree-optimization/69956
* tree-vect-stmts.c (supportable_widening_operation): Support
multi-step conversion of boolean vectors.
(supportable_narrowing_operation): Likewise.

gcc/testsuite/

PR tree-optimization/69956
* gcc.dg/pr69956.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233850 138bc75d-0d04-0410-961f-82ee72b054a4

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

index e1975a5..f6ee6dc 100644 (file)
@@ -1,3 +1,10 @@
+2016-03-01  Ilya Enkovich  <enkovich.gnu@gmail.com>
+
+       PR tree-optimization/69956
+       * tree-vect-stmts.c (supportable_widening_operation): Support
+       multi-step conversion of boolean vectors.
+       (supportable_narrowing_operation): Likewise.
+
 2016-03-01  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
 
        * config/s390/s390.c (s390_decompose_address): Don't accept SImode
index 82e538e..c0eaa55 100644 (file)
@@ -1,3 +1,8 @@
+2016-03-01  Ilya Enkovich  <enkovich.gnu@gmail.com>
+
+       PR tree-optimization/69956
+       * gcc.dg/pr69956.c: New test.
+
 2016-02-29  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        PR target/70011
diff --git a/gcc/testsuite/gcc.dg/pr69956.c b/gcc/testsuite/gcc.dg/pr69956.c
new file mode 100644 (file)
index 0000000..37d24d4
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-vectorize" } */
+/* { dg-additional-options "-march=skylake-avx512" { target { i?86-*-* x86_64-*-* } } } */
+
+void
+fn1 (char *b, char *d, int *c, int i)
+{
+  for (; i; i++, d++)
+    if (b[i])
+      *d = c[i];
+}
index 9678d7c..182b277 100644 (file)
@@ -9000,9 +9000,19 @@ supportable_widening_operation (enum tree_code code, gimple *stmt,
   for (i = 0; i < MAX_INTERM_CVT_STEPS; i++)
     {
       intermediate_mode = insn_data[icode1].operand[0].mode;
-      intermediate_type
-       = lang_hooks.types.type_for_mode (intermediate_mode,
-                                         TYPE_UNSIGNED (prev_type));
+      if (VECTOR_BOOLEAN_TYPE_P (prev_type))
+       {
+         intermediate_type
+           = build_truth_vector_type (TYPE_VECTOR_SUBPARTS (prev_type) / 2,
+                                      current_vector_size);
+         if (intermediate_mode != TYPE_MODE (intermediate_type))
+           return false;
+       }
+      else
+       intermediate_type
+         = lang_hooks.types.type_for_mode (intermediate_mode,
+                                           TYPE_UNSIGNED (prev_type));
+
       optab3 = optab_for_tree_code (c1, intermediate_type, optab_default);
       optab4 = optab_for_tree_code (c2, intermediate_type, optab_default);
 
@@ -9065,7 +9075,7 @@ supportable_narrowing_operation (enum tree_code code,
   tree vectype = vectype_in;
   tree narrow_vectype = vectype_out;
   enum tree_code c1;
-  tree intermediate_type;
+  tree intermediate_type, prev_type;
   machine_mode intermediate_mode, prev_mode;
   int i;
   bool uns;
@@ -9111,6 +9121,7 @@ supportable_narrowing_operation (enum tree_code code,
   /* Check if it's a multi-step conversion that can be done using intermediate
      types.  */
   prev_mode = vec_mode;
+  prev_type = vectype;
   if (code == FIX_TRUNC_EXPR)
     uns = TYPE_UNSIGNED (vectype_out);
   else
@@ -9145,8 +9156,17 @@ supportable_narrowing_operation (enum tree_code code,
   for (i = 0; i < MAX_INTERM_CVT_STEPS; i++)
     {
       intermediate_mode = insn_data[icode1].operand[0].mode;
-      intermediate_type
-       = lang_hooks.types.type_for_mode (intermediate_mode, uns);
+      if (VECTOR_BOOLEAN_TYPE_P (prev_type))
+       {
+         intermediate_type
+           = build_truth_vector_type (TYPE_VECTOR_SUBPARTS (prev_type) * 2,
+                                      current_vector_size);
+         if (intermediate_mode != TYPE_MODE (intermediate_type))
+             return false;
+       }
+      else
+       intermediate_type
+         = lang_hooks.types.type_for_mode (intermediate_mode, uns);
       interm_optab
        = optab_for_tree_code (VEC_PACK_TRUNC_EXPR, intermediate_type,
                               optab_default);
@@ -9164,6 +9184,7 @@ supportable_narrowing_operation (enum tree_code code,
        return true;
 
       prev_mode = intermediate_mode;
+      prev_type = intermediate_type;
       optab1 = interm_optab;
     }