&& (int) REGNO (original) >= new_regno_start
&& (INSN_UID (curr_insn) >= new_insn_uid_start
|| ira_former_scratch_p (REGNO (original)))
- && in_class_p (original, rclass, &new_class, true))
+ && in_class_p (original, rclass, &new_class, true)
+ && (exclude_start_hard_regs == nullptr
+ || hard_reg_set_intersect_p (
+ ~lra_reg_info[REGNO (original)].exclude_start_hard_regs,
+ ~*exclude_start_hard_regs)))
{
unsigned int regno = REGNO (original);
if (lra_dump_file != NULL)
lra_change_class (regno, new_class, ", change to", false);
if (lra_dump_file != NULL)
fprintf (lra_dump_file, "\n");
+ if (exclude_start_hard_regs)
+ lra_reg_info[regno].exclude_start_hard_regs
+ |= *exclude_start_hard_regs;
*result_reg = original;
return false;
}
if (reg == NULL_RTX || GET_CODE (reg) != SUBREG)
continue;
}
+ /* If the existing reload and this have no start hard register in
+ common, then skip. Otherwise update exclude_start_hard_regs. */
+ if (exclude_start_hard_regs
+ && ! hard_reg_set_empty_p (*exclude_start_hard_regs))
+ {
+ HARD_REG_SET r = lra_reg_info[regno].exclude_start_hard_regs
+ | *exclude_start_hard_regs;
+ if (hard_reg_set_empty_p (~r))
+ continue;
+ else
+ lra_reg_info[regno].exclude_start_hard_regs = r;
+ }
*result_reg = reg;
if (lra_dump_file != NULL)
{
--- /dev/null
+/* { dg-do compile { target s390*-*-* x86_64-*-* } } */
+/* { dg-options "-O2" } */
+
+/* Ensure that if the reload register for operand 2 is resued for operand 3,
+ that exclude start hard regs coming from operand 3 are taken into account.
+ Otherwise a different register than r8 may be chosen rendering the insn
+ after LRA unsatisfiable. */
+
+long
+test ()
+{
+ long x;
+ __asm__ ("" : "=r" (x) : "0" (1000), "r" (0l), "{r8}" (0l));
+ return x;
+}