Bootstrapped and tested on x86_64-unknmown-linux-gnu, applied.

Richard.

2016-05-25  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/71264
        * tree-vect-stmts.c (vect_init_vector): Properly deal with
        vector type val.

        * gcc.dg/vect/pr71264.c: New testcase.

Index: gcc/tree-vect-stmts.c
===================================================================
*** gcc/tree-vect-stmts.c       (revision 236689)
--- gcc/tree-vect-stmts.c       (working copy)
*************** vect_init_vector (gimple *stmt, tree val
*** 1256,1265 ****
    gimple *init_stmt;
    tree new_temp;
  
!   if (TREE_CODE (type) == VECTOR_TYPE
!       && TREE_CODE (TREE_TYPE (val)) != VECTOR_TYPE)
      {
!       if (!types_compatible_p (TREE_TYPE (type), TREE_TYPE (val)))
        {
          /* Scalar boolean value should be transformed into
             all zeros or all ones value before building a vector.  */
--- 1256,1266 ----
    gimple *init_stmt;
    tree new_temp;
  
!   /* We abuse this function to push sth to a SSA name with initial 'val'.  */
!   if (! useless_type_conversion_p (type, TREE_TYPE (val)))
      {
!       gcc_assert (TREE_CODE (type) == VECTOR_TYPE);
!       if (! types_compatible_p (TREE_TYPE (type), TREE_TYPE (val)))
        {
          /* Scalar boolean value should be transformed into
             all zeros or all ones value before building a vector.  */
*************** vect_init_vector (gimple *stmt, tree val
*** 1284,1290 ****
          else
            {
              new_temp = make_ssa_name (TREE_TYPE (type));
!             init_stmt = gimple_build_assign (new_temp, NOP_EXPR, val);
              vect_init_vector_1 (stmt, init_stmt, gsi);
              val = new_temp;
            }
--- 1285,1297 ----
          else
            {
              new_temp = make_ssa_name (TREE_TYPE (type));
!             if (! INTEGRAL_TYPE_P (TREE_TYPE (val)))
!               init_stmt = gimple_build_assign (new_temp,
!                                                fold_build1 (VIEW_CONVERT_EXPR,
!                                                             TREE_TYPE (type),
!                                                             val));
!             else
!               init_stmt = gimple_build_assign (new_temp, NOP_EXPR, val);
              vect_init_vector_1 (stmt, init_stmt, gsi);
              val = new_temp;
            }
Index: gcc/testsuite/gcc.dg/vect/pr71264.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/pr71264.c (revision 0)
--- gcc/testsuite/gcc.dg/vect/pr71264.c (working copy)
***************
*** 0 ****
--- 1,20 ----
+ /* { dg-do compile } */
+ /* { dg-require-effective-target vect_int } */
+ 
+ typedef unsigned char uint8_t;
+ typedef uint8_t footype __attribute__((vector_size(4)));
+ 
+ void test(uint8_t *ptr, uint8_t *mask)
+ {
+   footype mv;
+   __builtin_memcpy(&mv, mask, sizeof(mv));
+   for (unsigned i = 0; i < 16; i += 4)
+     {
+       footype temp;
+       __builtin_memcpy(&temp, &ptr[i], sizeof(temp));
+       temp ^= mv;
+       __builtin_memcpy(&ptr[i], &temp, sizeof(temp));
+     }
+ }
+ 
+ /* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */

Reply via email to