(replace_regs, case REG): Return copies of SUBREGs, to
authorJim Wilson <wilson@gcc.gnu.org>
Tue, 21 Dec 1993 18:25:26 +0000 (10:25 -0800)
committerJim Wilson <wilson@gcc.gnu.org>
Tue, 21 Dec 1993 18:25:26 +0000 (10:25 -0800)
avoid invalid sharing.

From-SVN: r6253

gcc/rtlanal.c

index 48aa6f9d6887856e9b1b5d4a2cd41a3ae21ec23f..486ef5f8d2247c3daa2667855066dac648bb5945 100644 (file)
@@ -1662,7 +1662,14 @@ replace_regs (x, reg_map, nregs, replace_dest)
     case REG:
       /* Verify that the register has an entry before trying to access it.  */
       if (REGNO (x) < nregs && reg_map[REGNO (x)] != 0)
-       return reg_map[REGNO (x)];
+       {
+         /* SUBREGs can't be shared.  Always return a copy to ensure that if
+            this replacement occurs more than once then each instance will
+            get distinct rtx.  */
+         if (GET_CODE (reg_map[REGNO (x)]) == SUBREG)
+           return copy_rtx (reg_map[REGNO (x)]);
+         return reg_map[REGNO (x)];
+       }
       return x;
 
     case SUBREG: