From d6da226a1e2931d818dc70602715c8bce7dddb01 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Thu, 22 Sep 2016 16:34:09 +0200 Subject: [PATCH] * regcprop.c (copyprop_hardreg_forward_1): Remove noop moves. From-SVN: r240365 --- gcc/ChangeLog | 4 ++++ gcc/regcprop.c | 24 +++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0262329ec89..21284824048 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2016-09-22 Jan Hubicka + + * regcprop.c (copyprop_hardreg_forward_1): Remove noop moves. + 2016-09-22 Trevor Saunders * emit-rtl.c (next_cc0_user): Make argument type rtx_insn *. diff --git a/gcc/regcprop.c b/gcc/regcprop.c index 14983001c5d..d1c1f8bdb11 100644 --- a/gcc/regcprop.c +++ b/gcc/regcprop.c @@ -771,6 +771,26 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd) } set = single_set (insn); + + /* Detect noop sets and remove them before processing side effects. */ + if (set && REG_P (SET_DEST (set)) && REG_P (SET_SRC (set))) + { + unsigned int regno = REGNO (SET_SRC (set)); + rtx r1 = find_oldest_value_reg (REGNO_REG_CLASS (regno), + SET_DEST (set), vd); + rtx r2 = find_oldest_value_reg (REGNO_REG_CLASS (regno), + SET_SRC (set), vd); + if (rtx_equal_p (r1 ? r1 : SET_DEST (set), r2 ? r2 : SET_SRC (set))) + { + bool last = insn == BB_END (bb); + fprintf (stderr, "Bingo\n"); + delete_insn (insn); + if (last) + break; + continue; + } + } + extract_constrain_insn (insn); preprocess_constraints (insn); const operand_alternative *op_alt = which_op_alt (); @@ -860,7 +880,9 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd) register in the same class. */ if (REG_P (SET_DEST (set))) { - new_rtx = find_oldest_value_reg (REGNO_REG_CLASS (regno), src, vd); + new_rtx = find_oldest_value_reg (REGNO_REG_CLASS (regno), + src, vd); + if (new_rtx && validate_change (insn, &SET_SRC (set), new_rtx, 0)) { if (dump_file) -- 2.30.2