[backport from gcc-4.7.1 r187496, the bug is unconfirmed on 4.6 branch ] gcc/ 2012-05-15 Bin Cheng Backport r187139 from mainline. 2012-05-04 Bin Cheng PR rtl-optimization/52804 * reload1.c (reload_reg_reaches_end_p): Check whether successor reload with type RELOAD_FOR_INPUT_ADDRESS kills reload register of current one with type RELOAD_FOR_INPADDR_ADDRESS. Same stands for reloads with type RELOAD_FOR_OUTPUT_ADDRESS and RELOAD_FOR_OUTADDR_ADDRESS. --- gcc-4.6.3/gcc/reload1.c.~1~ 2011-11-01 19:38:42.000000000 +0100 +++ gcc-4.6.3/gcc/reload1.c 2012-06-10 11:24:17.000000000 +0200 @@ -5350,6 +5350,13 @@ reload_reg_reaches_end_p (unsigned int r if (TEST_HARD_REG_BIT (reload_reg_used_in_input[i], regno)) return 0; + /* Reload register of reload with type RELOAD_FOR_INPADDR_ADDRESS + could be killed if the register is also used by reload with type + RELOAD_FOR_INPUT_ADDRESS, so check it. */ + if (type == RELOAD_FOR_INPADDR_ADDRESS + && TEST_HARD_REG_BIT (reload_reg_used_in_input_addr[opnum], regno)) + return 0; + for (i = opnum + 1; i < reload_n_operands; i++) if (TEST_HARD_REG_BIT (reload_reg_used_in_input_addr[i], regno) || TEST_HARD_REG_BIT (reload_reg_used_in_inpaddr_addr[i], regno)) @@ -5424,6 +5431,13 @@ reload_reg_reaches_end_p (unsigned int r || TEST_HARD_REG_BIT (reload_reg_used_in_outaddr_addr[i], regno)) return 0; + /* Reload register of reload with type RELOAD_FOR_OUTADDR_ADDRESS + could be killed if the register is also used by reload with type + RELOAD_FOR_OUTPUT_ADDRESS, so check it. */ + if (type == RELOAD_FOR_OUTADDR_ADDRESS + && TEST_HARD_REG_BIT (reload_reg_used_in_outaddr_addr[opnum], regno)) + return 0; + return 1; default: