https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70561
Bug ID: 70561 Summary: Crash in recog_for_combine_1 Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: vogt at linux dot vnet.ibm.com CC: krebbel at gcc dot gnu.org Target Milestone: --- Host: s390x Target: s390x This code in recog_for_combine_1 doesn't look right: -- if (num_clobbers_to_add) { rtx newpat = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (GET_CODE (pat) == PARALLEL ? (XVECLEN (pat, 0) + num_clobbers_to_add) : num_clobbers_to_add + 1)); if (GET_CODE (pat) == PARALLEL) for (i = 0; i < XVECLEN (pat, 0); i++) XVECEXP (newpat, 0, i) = XVECEXP (pat, 0, i); else XVECEXP (newpat, 0, 0) = pat; add_clobbers (newpat, insn_code_number); for (i = XVECLEN (newpat, 0) - num_clobbers_to_add; i < XVECLEN (newpat, 0); i++) { if (REG_P (XEXP (XVECEXP (newpat, 0, i), 0)) <=============== crash && ! reg_dead_at_p (XEXP (XVECEXP (newpat, 0, i), 0), insn)) return -1; ... -- For me, there is a crash in the marked line (for some pattern I'm working on) with "i == 1" because "XVECEXP (newpat, 0, 1)" is "(nil)". If "num_clobbers_to_add" is > 0, and the original "pat" is not a parallel, only the first element of newpat is initialised, but the remaining elements are still accessed. There probably should be something like this in the for loop? for (...) { if (XVECEXP (newpat, 0, i)) /* generate clobber from scratch and store it in XVECEXP (newpat, 0, i) */ -- Probably triggered by this splitter: [(parallel [(set (match_operand:GPR 0 "nonimmediate_operand" "") (and:GPR (not:GPR (match_operand:GPR 1 "nonimmediate_operand" "")) (match_operand:GPR 2 "nonimmediate_operand" ""))) (clobber (reg:CC CC_REGNUM))])] ==> [ (parallel [(set (match_dup 3) (and:GPR (match_dup 1) (match_dup 2))) (clobber (reg:CC CC_REGNUM))]) (parallel [(set (match_dup 0) (xor:GPR (match_dup 3) (match_dup 2))) (clobber (reg:CC CC_REGNUM))])]