Hi,
This is a patch proposed to fix the latent scheduler issue seen in PR123144,
PR80357 and PR94014.
I was not able to generate a test case for this specific scenario. All the test
cases mentioned in this PR mostly compile fine due to changes in gimple passes.
I tried to generate gimple of the optimized and compile using -fgimple, but
there were many parsing issues. Any suggestions on how to test this robustly
would be welcome.
Bootstrapped and regtested on powerpc64le and x86_64 without any regressions.
Also tested on gcc-14 which fixed PR113390. Ok for trunk and release-14?
Thanks and regards,
Avinash Jayakar
A latent issue in haifa scheduler cause ICE sometimes due to
inconsistent register pressure values. PR123144, PR80357 and PR94014
showed how this issue caused ICE.
The problem was in the model_recompute function. During region
scheduling, the ready list may have instruction from multiple basic
blocks, but the model_schedule always has insns within the target_bb.
So when model_recompute is run for instruction that is not in the
model_schedule, the register pressure values would go negative in some
cases leading to assertion error in model_update_limit_points_in_group.
This patch just adds a guard in model_recompute function to not do it
when insn is not in model.
gcc/ChangeLog:
PR 123144
PR 80357
PR 94014
* haifa-sched.cc (model_recompute): Return if insn not in
model_schedule.
---
gcc/haifa-sched.cc | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/gcc/haifa-sched.cc b/gcc/haifa-sched.cc
index 4daa4d7b18a..b641d7a21a2 100644
--- a/gcc/haifa-sched.cc
+++ b/gcc/haifa-sched.cc
@@ -2130,6 +2130,14 @@ model_recompute (rtx_insn *insn)
/* The destinations of INSN were previously live from POINT onwards, but are
now live from model_curr_point onwards. Set up DELTA accordingly. */
point = model_index (insn);
+
+ /* In case if insn is not in the model, no need to recompute.
+ This may happen in region scheduling, where the model schedule only has
insns
+ from the basic block, but scheduled insn may be in a different block in the
+ same region. Recompute in this case would result in inconsistent pressure
+ values. */
+ if (point == model_num_insns)
+ return;
reg_pressure = INSN_REG_PRESSURE (insn);
for (pci = 0; pci < ira_pressure_classes_num; pci++)
{
--
2.51.0