When analyzing PR55334 further I noticed that when vectorizing
an invariant load we still create a regular (but dead) vector
load and an associated pointer induction variable.  That's of
course pointless.

Fix is simple.

Bootstrapped (with -O3) and tested on x86_64-unknown-linux-gnu, applied to 
trunk.

Richard.

2013-01-02  Richard Biener  <rguent...@suse.de>

        * tree-vect-stmts.c (vectorizable_load): When vectorizing an
        invariant load do not generate a vector load from the scalar
        location.

Index: gcc/tree-vect-stmts.c
===================================================================
*** gcc/tree-vect-stmts.c       (revision 194787)
--- gcc/tree-vect-stmts.c       (working copy)
*************** vectorizable_load (gimple stmt, gimple_s
*** 4988,4993 ****
--- 4988,5006 ----
          /* Record the mapping between SSA_NAMEs and statements.  */
          vect_record_grouped_load_vectors (stmt, dr_chain);
        }
+       /* Handle invariant-load.  */
+       else if (inv_p && !bb_vinfo)
+       {
+         gimple_stmt_iterator gsi2 = *gsi;
+         gcc_assert (!grouped_load && !slp_perm);
+         gsi_next (&gsi2);
+         new_temp = vect_init_vector (stmt, scalar_dest,
+                                      vectype, &gsi2);
+         new_stmt = SSA_NAME_DEF_STMT (new_temp);
+         /* Store vector loads in the corresponding SLP_NODE.  */
+         if (slp)
+           SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt);
+       }
        else
        {
          for (i = 0; i < vec_num; i++)
*************** vectorizable_load (gimple stmt, gimple_s
*** 5135,5151 ****
                    }
                }
  
-             /* 4. Handle invariant-load.  */
-             if (inv_p && !bb_vinfo)
-               {
-                 gimple_stmt_iterator gsi2 = *gsi;
-                 gcc_assert (!grouped_load);
-                 gsi_next (&gsi2);
-                 new_temp = vect_init_vector (stmt, scalar_dest,
-                                              vectype, &gsi2);
-                 new_stmt = SSA_NAME_DEF_STMT (new_temp);
-               }
- 
              if (negative)
                {
                  tree perm_mask = perm_mask_for_reverse (vectype);
--- 5148,5153 ----

Reply via email to