aboutsummaryrefslogtreecommitdiff
path: root/gcc/cprop.c
diff options
context:
space:
mode:
authorGeorg-Johann Lay <avr@gjlay.de>2011-11-05 13:08:54 +0000
committerGeorg-Johann Lay <gjl@gcc.gnu.org>2011-11-05 13:08:54 +0000
commit8eee318f0af514cb4b508af91ec5a3825e1960b3 (patch)
treea331961dfbbbf7f51ca223c101df3b92b6b10894 /gcc/cprop.c
parent69e596afa446722c8c19a7d0275fd53c4cd167c1 (diff)
downloadgcc-8eee318f0af514cb4b508af91ec5a3825e1960b3.zip
gcc-8eee318f0af514cb4b508af91ec5a3825e1960b3.tar.gz
gcc-8eee318f0af514cb4b508af91ec5a3825e1960b3.tar.bz2
re PR rtl-optimization/50448 (Missed optimization accessing struct component with integer address)
PR rtl-optimization/50448 * cprop.c (try_replace_reg): Also try to replace uses of FROM that appear in SET_DEST. From-SVN: r181011
Diffstat (limited to 'gcc/cprop.c')
-rw-r--r--gcc/cprop.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/cprop.c b/gcc/cprop.c
index 584ffd2..d90f769 100644
--- a/gcc/cprop.c
+++ b/gcc/cprop.c
@@ -712,8 +712,8 @@ find_used_regs (rtx *xptr, void *data ATTRIBUTE_UNUSED)
}
}
-/* Try to replace all non-SET_DEST occurrences of FROM in INSN with TO.
- Returns nonzero is successful. */
+/* Try to replace all uses of FROM in INSN with TO.
+ Return nonzero if successful. */
static int
try_replace_reg (rtx from, rtx to, rtx insn)
@@ -764,6 +764,18 @@ try_replace_reg (rtx from, rtx to, rtx insn)
note = set_unique_reg_note (insn, REG_EQUAL, copy_rtx (src));
}
+ if (set && MEM_P (SET_DEST (set)) && reg_mentioned_p (from, SET_DEST (set)))
+ {
+ /* Registers can also appear as uses in SET_DEST if it is a MEM.
+ We could perhaps try this for multiple SETs, but it probably
+ won't buy us anything. */
+ rtx dest = simplify_replace_rtx (SET_DEST (set), from, to);
+
+ if (!rtx_equal_p (dest, SET_DEST (set))
+ && validate_change (insn, &SET_DEST (set), dest, 0))
+ success = 1;
+ }
+
/* REG_EQUAL may get simplified into register.
We don't allow that. Remove that note. This code ought
not to happen, because previous code ought to synthesize