===================================================================
@@ -6977,10 +6977,27 @@ choose_reload_regs (struct insn_chain *c
If we succeeded removing some reload and we are doing a preliminary
pass just to remove such reloads, make another pass, since the
removal of one reload might allow us to inherit another one. */
- else if (rld[r].in
+ else if (pass
+ && rld[r].in
&& rld[r].out != rld[r].in
- && remove_address_replacements (rld[r].in) && pass)
+ && remove_address_replacements (rld[r].in))
pass = 2;
+#ifdef SECONDARY_MEMORY_NEEDED
+ else if (pass
+ && rld[r].in
+ && rld[r].out != rld[r].in
+ && (REG_P (rld[r].in)
+ || (GET_CODE (rld[r].in) == SUBREG
+ && REG_P (SUBREG_REG (rld[r].in))))
+ && reg_or_subregno (rld[r].in) < FIRST_PSEUDO_REGISTER
+ && SECONDARY_MEMORY_NEEDED
+ (REGNO_REG_CLASS (reg_or_subregno (rld[r].in)),
+ rld[r].rclass, rld[r].inmode)
+ && remove_address_replacements
+ (get_secondary_mem (rld[r].in, rld[r].inmode,
+ rld[r].opnum, rld[r].when_needed)))
+ pass = 2;
+#endif
}
}