sched_macro_fuse_insns uses the value in condreg1 without
checking the return value of targetm.fixed_condition_code_regs.  As
this variables
is not initialized anywhere, this leads to constructing cc_reg_1 with
an undefined value,
and then using that in reg_referenced_p, if TARGET_FIXED_CONDITION_CODE_REGS
has the default value as defined in target.def (hook_bool_uintp_uintp_false).

The attached patch fixes this by checking the return value of
targetm.fixed_condition_code_regs.  Bootstrapped & regtested on
x86_64-pc-linux-gnu .
2019-04-04  Joern Rennecke  <joern.renne...@embecosm.com>

        * sched-deps.c (sched_macro_fuse_insns): Check return value of
        targetm.fixed_condition_code_regs.

Index: sched-deps.c
===================================================================
--- sched-deps.c        (revision 270146)
+++ sched-deps.c        (working copy)
@@ -2857,14 +2857,16 @@ sched_macro_fuse_insns (rtx_insn *insn)
     {
       unsigned int condreg1, condreg2;
       rtx cc_reg_1;
-      targetm.fixed_condition_code_regs (&condreg1, &condreg2);
-      cc_reg_1 = gen_rtx_REG (CCmode, condreg1);
-      if (reg_referenced_p (cc_reg_1, PATTERN (insn))
-         && modified_in_p (cc_reg_1, prev))
+      if (targetm.fixed_condition_code_regs (&condreg1, &condreg2))
        {
-         if (targetm.sched.macro_fusion_pair_p (prev, insn))
-           SCHED_GROUP_P (insn) = 1;
-         return;
+         cc_reg_1 = gen_rtx_REG (CCmode, condreg1);
+         if (reg_referenced_p (cc_reg_1, PATTERN (insn))
+             && modified_in_p (cc_reg_1, prev))
+           {
+             if (targetm.sched.macro_fusion_pair_p (prev, insn))
+               SCHED_GROUP_P (insn) = 1;
+             return;
+           }
        }
     }
 

Reply via email to