summaryrefslogtreecommitdiff
path: root/gcc/final.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/final.c')
-rw-r--r--gcc/final.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/final.c b/gcc/final.c
index 37dc89dc6a4..2647bbe08f5 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -2902,9 +2902,15 @@ alter_subreg (x)
register rtx x;
{
register rtx y = SUBREG_REG (x);
+
if (GET_CODE (y) == SUBREG)
y = alter_subreg (y);
+ /* If reload is operating, we may be replacing inside this SUBREG.
+ Check for that and make a new one if so. */
+ if (reload_in_progress && find_replacement (&SUBREG_REG (x)) != 0)
+ x = copy_rtx (x);
+
if (GET_CODE (y) == REG)
{
/* If the word size is larger than the size of this register,