* regcprop.c (copyprop_hardreg_forward_1): Remove noop moves.
authorJan Hubicka <hubicka@ucw.cz>
Thu, 22 Sep 2016 14:34:09 +0000 (16:34 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Thu, 22 Sep 2016 14:34:09 +0000 (14:34 +0000)
From-SVN: r240365

gcc/ChangeLog
gcc/regcprop.c

index 0262329..2128482 100644 (file)
@@ -1,3 +1,7 @@
+2016-09-22  Jan Hubicka  <hubicka@ucw.cz>
+
+       * regcprop.c (copyprop_hardreg_forward_1): Remove noop moves.
+
 2016-09-22  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
 
        * emit-rtl.c (next_cc0_user): Make argument type rtx_insn *.
index 1498300..d1c1f8b 100644 (file)
@@ -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)