summaryrefslogtreecommitdiff
path: root/gcc/dse.cc
diff options
context:
space:
mode:
authorRichard Earnshaw <rearnsha@arm.com>2022-08-03 10:01:51 +0100
committerRichard Earnshaw <rearnsha@arm.com>2022-08-03 10:07:15 +0100
commit64ce76d940501cb04d14a0d36752b4f93473531c (patch)
tree1c7cb524db411f7625a6a08bad592e476dc1c28d /gcc/dse.cc
parenta6b7fff06c5b27c4ffacf4c84ea1189254b9ad84 (diff)
cselib: add function to check if SET is redundant [PR106187]
A SET operation that writes memory may have the same value as an earlier store but if the alias sets of the new and earlier store do not conflict then the set is not truly redundant. This can happen, for example, if objects of different types share a stack slot. To fix this we define a new function in cselib that first checks for equality and if that is successful then finds the earlier store in the value history and checks the alias sets. The routine is used in two places elsewhere in the compiler: cfgcleanup and postreload. gcc/ChangeLog: PR rtl-optimization/106187 * alias.h (mems_same_for_tbaa_p): Declare. * alias.cc (mems_same_for_tbaa_p): New function. * dse.cc (record_store): Use it instead of open-coding alias check. * cselib.h (cselib_redundant_set_p): Declare. * cselib.cc: Include alias.h (cselib_redundant_set_p): New function. * cfgcleanup.cc: (mark_effect): Use cselib_redundant_set_p instead of rtx_equal_for_cselib_p. * postreload.cc (reload_cse_simplify): Use cselib_redundant_set_p. (reload_cse_noop_set_p): Delete.
Diffstat (limited to 'gcc/dse.cc')
-rw-r--r--gcc/dse.cc7
1 files changed, 1 insertions, 6 deletions
diff --git a/gcc/dse.cc b/gcc/dse.cc
index 90a4c1f22db..0f7b0fb9796 100644
--- a/gcc/dse.cc
+++ b/gcc/dse.cc
@@ -1570,12 +1570,7 @@ record_store (rtx body, bb_info_t bb_info)
width)
/* We can only remove the later store if the earlier aliases
at least all accesses the later one. */
- && ((MEM_ALIAS_SET (mem) == MEM_ALIAS_SET (s_info->mem)
- || alias_set_subset_of (MEM_ALIAS_SET (mem),
- MEM_ALIAS_SET (s_info->mem)))
- && (!MEM_EXPR (s_info->mem)
- || refs_same_for_tbaa_p (MEM_EXPR (s_info->mem),
- MEM_EXPR (mem)))))
+ && mems_same_for_tbaa_p (s_info->mem, mem))
{
if (GET_MODE (mem) == BLKmode)
{