As promised here is a simple patch to keep the vectorizer from
making virtual SSA form out-of-date in 99% of all cases and thus
avoid an update_ssa call.  99% in that this survives vect.exp
testing with the TODO_update_ssa removed from both the loop and
basic-block vectorization passes.  Still the patch isn't designed
to 100% make sure this won't be ever needed.

Bootstrapped and tested on x86_64-unknown-linux-gnu, will apply
shortly.  Btw, I considered first adding this kind of magic
to gsi_insert_*, but backed off because that seems to be a too
high-level operation for this kind of routines.

Thanks,
Richard.

2012-08-23  Richard Guenther  <rguent...@suse.de>

        * tree-vect-stmts.c (vect_finish_stmt_generation): Update
        virtual SSA form.

Index: gcc/tree-vect-stmts.c
===================================================================
*** gcc/tree-vect-stmts.c       (revision 190613)
--- gcc/tree-vect-stmts.c       (working copy)
*************** vect_finish_stmt_generation (gimple stmt
*** 1600,1605 ****
--- 1600,1631 ----
  
    gcc_assert (gimple_code (stmt) != GIMPLE_LABEL);
  
+   if (!gsi_end_p (*gsi)
+       && gimple_has_mem_ops (vec_stmt))
+     {
+       gimple at_stmt = gsi_stmt (*gsi);
+       tree vuse = gimple_vuse (at_stmt);
+       if (vuse && TREE_CODE (vuse) == SSA_NAME)
+       {
+         tree vdef = gimple_vdef (at_stmt);
+         gimple_set_vuse (vec_stmt, gimple_vuse (at_stmt));
+         /* If we have an SSA vuse and insert a store, update virtual
+            SSA form to avoid triggering the renamer.  Do so only
+            if we can easily see all uses - which is what almost always
+            happens with the way vectorized stmts are inserted.  */
+         if ((vdef && TREE_CODE (vdef) == SSA_NAME)
+             && ((is_gimple_assign (vec_stmt)
+                  && !is_gimple_reg (gimple_assign_lhs (vec_stmt)))
+                 || (is_gimple_call (vec_stmt)
+                     && !(gimple_call_flags (vec_stmt)
+                          & (ECF_CONST|ECF_PURE|ECF_NOVOPS)))))
+           {
+             tree new_vdef = copy_ssa_name (vuse, vec_stmt);
+             gimple_set_vdef (vec_stmt, new_vdef);
+             SET_USE (gimple_vuse_op (at_stmt), new_vdef);
+           }
+       }
+     }
    gsi_insert_before (gsi, vec_stmt, GSI_SAME_STMT);
  
    set_vinfo_for_stmt (vec_stmt, new_stmt_vec_info (vec_stmt, loop_vinfo,

Reply via email to