[backport from gcc-4.8/trunk r191307 ] gcc/ 2012-09-14 Richard Earnshaw PR target/54516 PR rtl-optimization/54540 * reload.c (find_dummy_reload): Don't use OUT as a reload reg for IN if it overlaps a fixed register. --- gcc-4.7.1/gcc/reload.c.~1~ 2012-01-20 17:29:01.000000000 +0100 +++ gcc-4.7.1/gcc/reload.c 2012-09-15 14:07:38.000000000 +0200 @@ -1982,7 +1982,12 @@ find_dummy_reload (rtx real_in, rtx real However, we only ignore IN in its role as this reload. If the insn uses IN elsewhere and it contains OUT, that counts. We can't be sure it's the "same" operand - so it might not go through this reload. */ + so it might not go through this reload. + + We also need to avoid using OUT if it, or part of it, is a + fixed register. Modifying such registers, even transiently, + may have undefined effects on the machine, such as modifying + the stack pointer. */ saved_rtx = *inloc; *inloc = const0_rtx; @@ -1995,7 +2000,8 @@ find_dummy_reload (rtx real_in, rtx real for (i = 0; i < nwords; i++) if (! TEST_HARD_REG_BIT (reg_class_contents[(int) rclass], - regno + i)) + regno + i) + || fixed_regs[regno + i]) break; if (i == nwords)