aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-06-30 11:28:11 +0200
committerRichard Biener <rguenth@gcc.gnu.org>2024-06-30 12:55:23 +0200
commitb5c64b413fd5bc03a1a8ef86d005892071e42cbe (patch)
tree3b58e32ac6bd314f399b8b6de042525c109c1c6e /gcc
parentb443d7122ee8013c5af127d3d183a03962967f57 (diff)
downloadgcc-b5c64b413fd5bc03a1a8ef86d005892071e42cbe.zip
gcc-b5c64b413fd5bc03a1a8ef86d005892071e42cbe.tar.gz
gcc-b5c64b413fd5bc03a1a8ef86d005892071e42cbe.tar.bz2
tree-optimization/115701 - factor out maybe_duplicate_ssa_info_at_copy
The following factors out the code that preserves SSA info of the LHS of a SSA copy LHS = RHS when LHS is about to be eliminated to RHS. PR tree-optimization/115701 * tree-ssanames.h (maybe_duplicate_ssa_info_at_copy): Declare. * tree-ssanames.cc (maybe_duplicate_ssa_info_at_copy): New function, split out from ... * tree-ssa-copy.cc (fini_copy_prop): ... here. * tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_stmt): ... and here.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/tree-ssa-copy.cc32
-rw-r--r--gcc/tree-ssa-sccvn.cc21
-rw-r--r--gcc/tree-ssanames.cc28
-rw-r--r--gcc/tree-ssanames.h3
4 files changed, 34 insertions, 50 deletions
diff --git a/gcc/tree-ssa-copy.cc b/gcc/tree-ssa-copy.cc
index bb88472..9c9ec47 100644
--- a/gcc/tree-ssa-copy.cc
+++ b/gcc/tree-ssa-copy.cc
@@ -527,38 +527,10 @@ fini_copy_prop (void)
|| copy_of[i].value == var)
continue;
- /* In theory the points-to solution of all members of the
- copy chain is their intersection. For now we do not bother
- to compute this but only make sure we do not lose points-to
- information completely by setting the points-to solution
- of the representative to the first solution we find if
- it doesn't have one already. */
+ /* Duplicate points-to and range info appropriately. */
if (copy_of[i].value != var
&& TREE_CODE (copy_of[i].value) == SSA_NAME)
- {
- basic_block copy_of_bb
- = gimple_bb (SSA_NAME_DEF_STMT (copy_of[i].value));
- basic_block var_bb = gimple_bb (SSA_NAME_DEF_STMT (var));
- if (POINTER_TYPE_P (TREE_TYPE (var))
- && SSA_NAME_PTR_INFO (var)
- && !SSA_NAME_PTR_INFO (copy_of[i].value))
- {
- duplicate_ssa_name_ptr_info (copy_of[i].value,
- SSA_NAME_PTR_INFO (var));
- /* Points-to information is cfg insensitive,
- but [E]VRP might record context sensitive alignment
- info, non-nullness, etc. So reset context sensitive
- info if the two SSA_NAMEs aren't defined in the same
- basic block. */
- if (var_bb != copy_of_bb)
- reset_flow_sensitive_info (copy_of[i].value);
- }
- else if (!POINTER_TYPE_P (TREE_TYPE (var))
- && SSA_NAME_RANGE_INFO (var)
- && !SSA_NAME_RANGE_INFO (copy_of[i].value)
- && var_bb == copy_of_bb)
- duplicate_ssa_name_range_info (copy_of[i].value, var);
- }
+ maybe_duplicate_ssa_info_at_copy (var, copy_of[i].value);
}
class copy_folder copy_folder;
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index fbbfa55..dc377fa 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -6886,27 +6886,10 @@ eliminate_dom_walker::eliminate_stmt (basic_block b, gimple_stmt_iterator *gsi)
/* If this now constitutes a copy duplicate points-to
and range info appropriately. This is especially
- important for inserted code. See tree-ssa-copy.cc
- for similar code. */
+ important for inserted code. */
if (sprime
&& TREE_CODE (sprime) == SSA_NAME)
- {
- basic_block sprime_b = gimple_bb (SSA_NAME_DEF_STMT (sprime));
- if (POINTER_TYPE_P (TREE_TYPE (lhs))
- && SSA_NAME_PTR_INFO (lhs)
- && ! SSA_NAME_PTR_INFO (sprime))
- {
- duplicate_ssa_name_ptr_info (sprime,
- SSA_NAME_PTR_INFO (lhs));
- if (b != sprime_b)
- reset_flow_sensitive_info (sprime);
- }
- else if (INTEGRAL_TYPE_P (TREE_TYPE (lhs))
- && SSA_NAME_RANGE_INFO (lhs)
- && ! SSA_NAME_RANGE_INFO (sprime)
- && b == sprime_b)
- duplicate_ssa_name_range_info (sprime, lhs);
- }
+ maybe_duplicate_ssa_info_at_copy (lhs, sprime);
/* Inhibit the use of an inserted PHI on a loop header when
the address of the memory reference is a simple induction
diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc
index 411ea84..bb9ed37 100644
--- a/gcc/tree-ssanames.cc
+++ b/gcc/tree-ssanames.cc
@@ -769,6 +769,34 @@ duplicate_ssa_name_range_info (tree name, tree src)
}
}
+/* For a SSA copy DEST = SRC duplicate SSA info present on DEST to SRC
+ to preserve it in case DEST is eliminated to SRC. */
+
+void
+maybe_duplicate_ssa_info_at_copy (tree dest, tree src)
+{
+ if (POINTER_TYPE_P (TREE_TYPE (dest))
+ && SSA_NAME_PTR_INFO (dest)
+ && ! SSA_NAME_PTR_INFO (src))
+ {
+ duplicate_ssa_name_ptr_info (src, SSA_NAME_PTR_INFO (dest));
+ /* Points-to information is cfg insensitive,
+ but VRP might record context sensitive alignment
+ info, non-nullness, etc. So reset context sensitive
+ info if the two SSA_NAMEs aren't defined in the same
+ basic block. */
+ if (gimple_bb (SSA_NAME_DEF_STMT (src))
+ != gimple_bb (SSA_NAME_DEF_STMT (dest)))
+ reset_flow_sensitive_info (src);
+ }
+ else if (INTEGRAL_TYPE_P (TREE_TYPE (dest))
+ && SSA_NAME_RANGE_INFO (dest)
+ && ! SSA_NAME_RANGE_INFO (src)
+ && (gimple_bb (SSA_NAME_DEF_STMT (src))
+ == gimple_bb (SSA_NAME_DEF_STMT (dest))))
+ duplicate_ssa_name_range_info (src, dest);
+}
+
/* Creates a duplicate of a ssa name NAME tobe defined by statement STMT
in function FN. */
diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h
index 824d8c8..731c04f9 100644
--- a/gcc/tree-ssanames.h
+++ b/gcc/tree-ssanames.h
@@ -79,9 +79,10 @@ extern struct ptr_info_def *get_ptr_info (tree);
extern void set_ptr_nonnull (tree);
extern tree copy_ssa_name_fn (struct function *, tree, gimple *);
-extern void duplicate_ssa_name_ptr_info (tree, struct ptr_info_def *);
extern tree duplicate_ssa_name_fn (struct function *, tree, gimple *);
+extern void duplicate_ssa_name_ptr_info (tree, struct ptr_info_def *);
extern void duplicate_ssa_name_range_info (tree dest, tree src);
+extern void maybe_duplicate_ssa_info_at_copy (tree dest, tree src);
extern void reset_flow_sensitive_info (tree);
extern void reset_flow_sensitive_info_in_bb (basic_block);
extern void release_defs (gimple *);