Index: gcc/config/rs6000/rs6000.opt =================================================================== --- gcc/config/rs6000/rs6000.opt (revision 197925) +++ gcc/config/rs6000/rs6000.opt (working copy) @@ -522,3 +522,7 @@ Control whether we save the TOC in the p mvsx-timode Target Undocumented Mask(VSX_TIMODE) Var(rs6000_isa_flags) ; Allow/disallow TImode in VSX registers + +mconstrain-regs +Target Undocumented Mask(CONSTRAIN_REGS) Var(rs6000_isa_flags) +; Only allow ints of certain modes to go in SPRs Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 197925) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -1608,6 +1608,18 @@ rs6000_hard_regno_mode_ok (int regno, en if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode)) return 1; + /* See if we need to be stricter about what goes into the special + registers (LR, CTR, VSAVE, VSCR). */ + if (TARGET_CONSTRAIN_REGS) + { + if (regno == LR_REGNO || regno == CTR_REGNO) + return (GET_MODE_CLASS (mode) == MODE_INT + && rs6000_hard_regno_nregs[mode][regno] == 1); + + if (regno == VRSAVE_REGNO || regno == VSCR_REGNO) + return (mode == SImode); + } + /* We cannot put non-VSX TImode or PTImode anywhere except general register and it must be able to fit within the register set. */ @@ -2054,6 +2066,9 @@ rs6000_debug_reg_global (void) if (targetm.lra_p ()) fprintf (stderr, DEBUG_FMT_S, "lra", "true"); + if (TARGET_CONSTRAIN_REGS) + fprintf (stderr, DEBUG_FMT_S, "constrain-regs", "true"); + fprintf (stderr, DEBUG_FMT_S, "plt-format", TARGET_SECURE_PLT ? "secure" : "bss"); fprintf (stderr, DEBUG_FMT_S, "struct-return", @@ -2945,6 +2960,12 @@ rs6000_option_override_internal (bool gl } } + /* If we are using the LRA register allocator, constrain the SPRs to only + have integer modes, and not modes like CC. */ + if ((rs6000_isa_flags_explicit & OPTION_MASK_CONSTRAIN_REGS) == 0 + && targetm.lra_p ()) + rs6000_isa_flags |= OPTION_MASK_CONSTRAIN_REGS; + /* Place FP constants in the constant pool instead of TOC if section anchors enabled. */ if (flag_section_anchors) Index: gcc/lra.c =================================================================== --- gcc/lra.c (revision 197925) +++ gcc/lra.c (working copy) @@ -1996,7 +1996,8 @@ check_rtl (bool final_p) if (final_p) { extract_insn (insn); - lra_assert (constrain_operands (1)); + if (!constrain_operands (1)) + fatal_insn_not_found (insn); continue; } if (insn_invalid_p (insn, false))