aboutsummaryrefslogtreecommitdiff
path: root/gcc/postreload.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/postreload.cc
parenta6b7fff06c5b27c4ffacf4c84ea1189254b9ad84 (diff)
downloadgcc-64ce76d940501cb04d14a0d36752b4f93473531c.zip
gcc-64ce76d940501cb04d14a0d36752b4f93473531c.tar.gz
gcc-64ce76d940501cb04d14a0d36752b4f93473531c.tar.bz2
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/postreload.cc')
-rw-r--r--gcc/postreload.cc15
1 files changed, 2 insertions, 13 deletions
diff --git a/gcc/postreload.cc b/gcc/postreload.cc
index d1c99fe..41f61d3 100644
--- a/gcc/postreload.cc
+++ b/gcc/postreload.cc
@@ -43,7 +43,6 @@ along with GCC; see the file COPYING3. If not see
#include "function-abi.h"
#include "rtl-iter.h"
-static int reload_cse_noop_set_p (rtx);
static bool reload_cse_simplify (rtx_insn *, rtx);
static void reload_cse_regs_1 (void);
static int reload_cse_simplify_set (rtx, rtx_insn *);
@@ -74,16 +73,6 @@ reload_cse_regs (rtx_insn *first ATTRIBUTE_UNUSED)
}
}
-/* See whether a single set SET is a noop. */
-static int
-reload_cse_noop_set_p (rtx set)
-{
- if (cselib_reg_set_mode (SET_DEST (set)) != GET_MODE (SET_DEST (set)))
- return 0;
-
- return rtx_equal_for_cselib_p (SET_DEST (set), SET_SRC (set));
-}
-
/* Try to simplify INSN. Return true if the CFG may have changed. */
static bool
reload_cse_simplify (rtx_insn *insn, rtx testreg)
@@ -118,7 +107,7 @@ reload_cse_simplify (rtx_insn *insn, rtx testreg)
this out, so it's safer to simplify before we delete. */
count += reload_cse_simplify_set (body, insn);
- if (!count && reload_cse_noop_set_p (body))
+ if (!count && cselib_redundant_set_p (body))
{
if (check_for_inc_dec (insn))
delete_insn_and_edges (insn);
@@ -157,7 +146,7 @@ reload_cse_simplify (rtx_insn *insn, rtx testreg)
rtx part = XVECEXP (body, 0, i);
if (GET_CODE (part) == SET)
{
- if (! reload_cse_noop_set_p (part))
+ if (! cselib_redundant_set_p (part))
break;
if (REG_P (SET_DEST (part))
&& REG_FUNCTION_VALUE_P (SET_DEST (part)))