init_regs_for_mode iterates over all hard regs for the machine to test
if the reg is OK for the mode, but an arithmetic overflow can lead to
testing elements beyond the end of the arrays allocated for fixed and
global registers. Clearly, if a mode requiring multiple hard regs needs
one beyond the hard reg set, it can't be valid for that mode.
gcc:
PR rtl-optimization/100311
* sel-sched.c (init_regs_for_mode): Skip iteration if multiple hard
regs are needed and they extend beyond the hard reg set.
OK for master? What about back-ports?
R.
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 3e0265daf28..5e68fd5fda5 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -1076,6 +1076,9 @@ init_regs_for_mode (machine_mode mode)
nregs = hard_regno_nregs (cur_reg, mode);
+ if (cur_reg + nregs - 1 >= FIRST_PSEUDO_REGISTER)
+ continue;
+
for (i = nregs - 1; i >= 0; --i)
if (fixed_regs[cur_reg + i]
|| global_regs[cur_reg + i]