]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Preserve SSA info for more propagated copy
authorRichard Biener <rguenther@suse.de>
Sun, 30 Jun 2024 09:37:12 +0000 (11:37 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 1 Jul 2024 14:20:41 +0000 (16:20 +0200)
Besides VN and copy-prop also CCP and VRP as well as forwprop
propagate out copies and thus it's worthwhile to try to preserve
range and points-to info there when possible.

Note that this also fixes the testcase from PR115701 but that's
because we do not actually intersect info but only copy info when
there was no info present.

* tree-ssa-forwprop.cc (fwprop_set_lattice_val): Preserve
SSA info.
* tree-ssa-propagate.cc
(substitute_and_fold_dom_walker::before_dom_children): Likewise.

gcc/tree-ssa-forwprop.cc
gcc/tree-ssa-propagate.cc

index abf71f0d3a038399ea4fc876c828e95ecc0b1510..44a6b5d39aa7abc9b2dd9282442e7e2cb720a6b5 100644 (file)
@@ -207,6 +207,10 @@ fwprop_set_lattice_val (tree name, tree val)
          lattice.quick_grow_cleared (num_ssa_names);
        }
       lattice[SSA_NAME_VERSION (name)] = val;
+      /* As this now constitutes a copy duplicate points-to
+        and range info appropriately.  */
+      if (TREE_CODE (val) == SSA_NAME)
+       maybe_duplicate_ssa_info_at_copy (name, val);
     }
 }
 
index a34c7618b559501d54dd640cd8cf4f343f562449..d96d0a9fe19b2df8ba812c05e7cc4378c1e89058 100644 (file)
@@ -789,6 +789,10 @@ substitute_and_fold_dom_walker::before_dom_children (basic_block bb)
                  fprintf (dump_file, "\n");
                }
              bitmap_set_bit (dceworklist, SSA_NAME_VERSION (res));
+             /* As this now constitutes a copy duplicate points-to
+                and range info appropriately.  */
+             if (TREE_CODE (sprime) == SSA_NAME)
+               maybe_duplicate_ssa_info_at_copy (res, sprime);
              continue;
            }
        }
@@ -831,6 +835,10 @@ substitute_and_fold_dom_walker::before_dom_children (basic_block bb)
                  fprintf (dump_file, "\n");
                }
              bitmap_set_bit (dceworklist, SSA_NAME_VERSION (lhs));
+             /* As this now constitutes a copy duplicate points-to
+                and range info appropriately.  */
+             if (TREE_CODE (sprime) == SSA_NAME)
+               maybe_duplicate_ssa_info_at_copy (lhs, sprime);
              continue;
            }
        }