From 75214935bee043e659ca7172a84451ded10e8987 Mon Sep 17 00:00:00 2001 From: Vladimir Makarov Date: Thu, 7 Dec 2017 17:50:54 +0000 Subject: [PATCH] re PR target/83252 (Wrong code with "-march=skylake-avx512 -O3") 2017-12-07 Vladimir Makarov PR target/83252 PR rtl-optimization/80818 * lra.c (add_regs_to_insn_regno_info): Make a hard reg in CLOBBER always early clobbered. * lra-lives.c (process_bb_lives): Check input hard regs for early clobbered non-operand hard reg. From-SVN: r255471 --- gcc/ChangeLog | 9 +++++++++ gcc/lra-lives.c | 13 ++++++++++++- gcc/lra.c | 14 +++++--------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 966810f15d5..da13cd5f831 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2017-12-07 Vladimir Makarov + + PR target/83252 + PR rtl-optimization/80818 + * lra.c (add_regs_to_insn_regno_info): Make a hard reg in CLOBBER + always early clobbered. + * lra-lives.c (process_bb_lives): Check input hard regs for early + clobbered non-operand hard reg. + 2017-12-07 Jakub Jelinek PR middle-end/83164 diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c index df7e2537dd0..785e436dc0e 100644 --- a/gcc/lra-lives.c +++ b/gcc/lra-lives.c @@ -928,7 +928,18 @@ process_bb_lives (basic_block bb, int &curr_point, bool dead_insn_p) for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next) if (reg->type == OP_OUT && reg_early_clobber_p (reg, n_alt) && ! reg->subreg_p) - make_hard_regno_dead (reg->regno); + { + struct lra_insn_reg *reg2; + + /* We can have early clobbered non-operand hard reg and + the same hard reg as an insn input. Don't make hard + reg dead before the insns. */ + for (reg2 = curr_id->regs; reg2 != NULL; reg2 = reg2->next) + if (reg2->type != OP_OUT && reg2->regno == reg->regno) + break; + if (reg2 == NULL) + make_hard_regno_dead (reg->regno); + } if (need_curr_point_incr) next_program_point (curr_point, freq); diff --git a/gcc/lra.c b/gcc/lra.c index 0d76eac3f3b..3fd15ee5794 100644 --- a/gcc/lra.c +++ b/gcc/lra.c @@ -1476,15 +1476,11 @@ add_regs_to_insn_regno_info (lra_insn_recog_data_t data, rtx x, add_regs_to_insn_regno_info (data, SET_SRC (x), insn, OP_IN, false, 0); break; case CLOBBER: - { - int code = INSN_CODE (insn); - - /* We treat clobber of non-operand hard registers as early - clobber (the behavior is expected from asm). */ - add_regs_to_insn_regno_info (data, XEXP (x, 0), insn, OP_OUT, - code < 0, code < 0 ? ALL_ALTERNATIVES : 0); - break; - } + /* We treat clobber of non-operand hard registers as early + clobber. */ + add_regs_to_insn_regno_info (data, XEXP (x, 0), insn, OP_OUT, + true, ALL_ALTERNATIVES); + break; case PRE_INC: case PRE_DEC: case POST_INC: case POST_DEC: add_regs_to_insn_regno_info (data, XEXP (x, 0), insn, OP_INOUT, false, 0); break; -- 2.30.2