]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Update virtual SSA form manually where easily possible in phiprop
authorRichard Biener <rguenther@suse.de>
Tue, 20 Jun 2023 07:51:40 +0000 (09:51 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 20 Jun 2023 10:48:23 +0000 (12:48 +0200)
This keeps virtual SSA form up-to-date in phiprop when easily possible.
Only when we deal with aggregate copies the work would be too
heavy-handed in general.

* tree-ssa-phiprop.cc (phiprop_insert_phi): For simple loads
keep the virtual SSA form up-to-date.

gcc/tree-ssa-phiprop.cc

index 5dc505df420889feec51349df0722630e3209cb1..21a349a25e245f7bc69214d5a56874144e2f8942 100644 (file)
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple-iterator.h"
 #include "stor-layout.h"
 #include "tree-ssa-loop.h"
+#include "tree-cfg.h"
 
 /* This pass propagates indirect loads through the PHI node for its
    address to make the load source possibly non-addressable and to
@@ -153,6 +154,8 @@ phiprop_insert_phi (basic_block bb, gphi *phi, gimple *use_stmt,
       print_gimple_stmt (dump_file, use_stmt, 0);
     }
 
+  gphi *vphi = get_virtual_phi (bb);
+
   /* Add PHI arguments for each edge inserting loads of the
      addressable operands.  */
   FOR_EACH_EDGE (e, ei, bb->preds)
@@ -190,9 +193,20 @@ phiprop_insert_phi (basic_block bb, gphi *phi, gimple *use_stmt,
        {
          tree rhs = gimple_assign_rhs1 (use_stmt);
          gcc_assert (TREE_CODE (old_arg) == ADDR_EXPR);
+         tree vuse = NULL_TREE;
          if (TREE_CODE (res) == SSA_NAME)
-           new_var = make_ssa_name (TREE_TYPE (rhs));
+           {
+             new_var = make_ssa_name (TREE_TYPE (rhs));
+             if (vphi)
+               vuse = PHI_ARG_DEF_FROM_EDGE (vphi, e);
+             else
+               vuse = gimple_vuse (use_stmt);
+           }
          else
+           /* For the aggregate copy case updating virtual operands
+              we'd have to possibly insert a virtual PHI and we have
+              to split the existing VUSE lifetime.  Leave that to
+              the generic SSA updating.  */
            new_var = unshare_expr (res);
          if (!is_gimple_min_invariant (old_arg))
            old_arg = PHI_ARG_DEF_FROM_EDGE (phi, e);
@@ -203,6 +217,8 @@ phiprop_insert_phi (basic_block bb, gphi *phi, gimple *use_stmt,
                                                  old_arg,
                                                  TREE_OPERAND (rhs, 1)));
          gimple_set_location (tmp, locus);
+         if (vuse)
+           gimple_set_vuse (tmp, vuse);
 
          gsi_insert_on_edge (e, tmp);
          update_stmt (tmp);