Hi,

this fixes a simple "regression" under the qsort_chk umbrella: sched-deps
analysis has deps->readonly flag, but macro-fusion code does not respect it
and mutates instructions. This breaks an assumption in sel_rank_for_schedule
and manifests as qsort checking error.

Since sched_macro_fuse_insns is only called to set SCHED_GROUP_P on suitable
insns, guard the call with !deps->readonly.

Bootstrapped/regtested on x86_64 with sel-sched active and
--with-cpu=sandybridge to exercise macro-fusion code and verified on aarch64
cross-compiler that the failing testcase given in the PR is fixed.

OK to apply?

Thanks.
Alexander

        PR rtl-optimization/84566
        * sched-deps.c (sched_analyze_insn): Check deps->readonly when invoking
        sched_macro_fuse_insns.

diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
index 9a5cbebea40..120b5f0ddc1 100644
--- a/gcc/sched-deps.c
+++ b/gcc/sched-deps.c
@@ -2897,7 +2897,8 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, 
rtx_insn *insn)
                         && code == SET);
 
   /* Group compare and branch insns for macro-fusion.  */
-  if (targetm.sched.macro_fusion_p
+  if (!deps->readonly
+      && targetm.sched.macro_fusion_p
       && targetm.sched.macro_fusion_p ())
     sched_macro_fuse_insns (insn);
 

Reply via email to