http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61017
Bug ID: 61017 Summary: lra aborts on optional match_scratch Product: gcc Version: 4.10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: amylaar at gcc dot gnu.org CC: vmakarov at gcc dot gnu.org lra is still not able to compile libgcc2 for ARC: ./cc1 libgcc2.i -O2 -mlra ../../../../unisrc-209293-arc/libgcc/libgcc2.c:2105:1: internal compiler error: in curr_insn_transform, at lra-constraints.c:3492 The abort happens for the doloop_end_i pattern. It contains (clobber (match_scratch:SI 3 "=X,X,&????r")) and for that, a register is allocated in advance without regard to need: lra.c:remove_scratches 1992ff if (GET_CODE (*id->operand_loc[i]) == SCRATCH && GET_MODE (*id->operand_loc[i]) != VOIDmode) { insn_changed_p = true; *id->operand_loc[i] = reg = lra_create_new_reg (static_id->operand[i].mode, *id->operand_loc[i], ALL_REGS, NULL); As process_alr_operands find that no the alternative uses "X" for that operand, it set this alternative to NO_REGS: lra-constraints.c:process_alt_operands 1608ff if (curr_static_id->operand_alternative[opalt_num].anything_ok) { /* Fast track for no constraints at all. */ curr_alt[nop] = NO_REGS; CLEAR_HARD_REG_SET (curr_alt_set[nop]); curr_alt_win[nop] = true; curr_alt_match_win[nop] = false; curr_alt_offmemok[nop] = false; curr_alt_matches[nop] = -1; continue; } which causes an abort later: lra-constraints.c:curr_insn_transform 3486ff if (REG_P (reg) && (regno = REGNO (reg)) >= FIRST_PSEUDO_REGISTER) { bool ok_p = in_class_p (reg, goal_alt[i], &new_class); if (new_class != NO_REGS && get_reg_class (regno) != new_class) { lra_assert (ok_p); lra_change_class (regno, new_class, " Change to", true); } }