Makefile.in (OBJS): Remove loop-unswitch.o.
authorRichard Biener <rguenther@suse.de>
Wed, 23 Apr 2014 13:48:12 +0000 (13:48 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 23 Apr 2014 13:48:12 +0000 (13:48 +0000)
2014-04-23  Richard Biener  <rguenther@suse.de>

* Makefile.in (OBJS): Remove loop-unswitch.o.
* loop-unswitch.c: Delete.
* tree-pass.h (make_pass_rtl_unswitch): Remove.
* passes.def (pass_rtl_unswitch): Likewise.
* loop-init.c (gate_rtl_unswitch): Likewise.
(rtl_unswitch): Likewise.
(pass_data_rtl_unswitch): Likewise.
(pass_rtl_unswitch): Likewise.
(make_pass_rtl_unswitch): Likewise.
* rtl.h (reversed_condition): Likewise.
(compare_and_jump_seq): Likewise.
* loop-iv.c (reversed_condition): Move here from loop-unswitch.c
and make static.
* loop-unroll.c (compare_and_jump_seq): Likewise.

From-SVN: r209698

gcc/ChangeLog
gcc/Makefile.in
gcc/loop-init.c
gcc/loop-iv.c
gcc/loop-unroll.c
gcc/passes.def
gcc/rtl.h
gcc/tree-pass.h

index 0a6cb55..c79f26a 100644 (file)
@@ -1,5 +1,22 @@
 2014-04-23  Richard Biener  <rguenther@suse.de>
 
+       * Makefile.in (OBJS): Remove loop-unswitch.o.
+       * loop-unswitch.c: Delete.
+       * tree-pass.h (make_pass_rtl_unswitch): Remove.
+       * passes.def (pass_rtl_unswitch): Likewise.
+       * loop-init.c (gate_rtl_unswitch): Likewise.
+       (rtl_unswitch): Likewise.
+       (pass_data_rtl_unswitch): Likewise.
+       (pass_rtl_unswitch): Likewise.
+       (make_pass_rtl_unswitch): Likewise.
+       * rtl.h (reversed_condition): Likewise.
+       (compare_and_jump_seq): Likewise.
+       * loop-iv.c (reversed_condition): Move here from loop-unswitch.c
+       and make static.
+       * loop-unroll.c (compare_and_jump_seq): Likewise.
+
+2014-04-23  Richard Biener  <rguenther@suse.de>
+
        PR tree-optimization/60903
        * tree-ssa-loop-im.c (analyze_memory_references): Remove
        commented code block.
index d1ab22f..6b46408 100644 (file)
@@ -1294,7 +1294,6 @@ OBJS = \
        loop-invariant.o \
        loop-iv.o \
        loop-unroll.o \
-       loop-unswitch.o \
        lower-subreg.o \
        lra.o \
        lra-assigns.o \
index 59f52d0..b7f8d9c 100644 (file)
@@ -511,49 +511,6 @@ make_pass_rtl_move_loop_invariants (gcc::context *ctxt)
 \f
 namespace {
 
-const pass_data pass_data_rtl_unswitch =
-{
-  RTL_PASS, /* type */
-  "loop2_unswitch", /* name */
-  OPTGROUP_LOOP, /* optinfo_flags */
-  true, /* has_execute */
-  TV_LOOP_UNSWITCH, /* tv_id */
-  0, /* properties_required */
-  0, /* properties_provided */
-  0, /* properties_destroyed */
-  0, /* todo_flags_start */
-  TODO_verify_rtl_sharing, /* todo_flags_finish */
-};
-
-class pass_rtl_unswitch : public rtl_opt_pass
-{
-public:
-  pass_rtl_unswitch (gcc::context *ctxt)
-    : rtl_opt_pass (pass_data_rtl_unswitch, ctxt)
-  {}
-
-  /* opt_pass methods: */
-  virtual bool gate (function *) { return flag_unswitch_loops; }
-  virtual unsigned int execute (function *fun)
-    {
-      if (number_of_loops (fun) > 1)
-       unswitch_loops ();
-      return 0;
-    }
-
-}; // class pass_rtl_unswitch
-
-} // anon namespace
-
-rtl_opt_pass *
-make_pass_rtl_unswitch (gcc::context *ctxt)
-{
-  return new pass_rtl_unswitch (ctxt);
-}
-
-\f
-namespace {
-
 const pass_data pass_data_rtl_unroll_and_peel_loops =
 {
   RTL_PASS, /* type */
index 9091220..42bcb75 100644 (file)
@@ -1732,6 +1732,21 @@ canon_condition (rtx cond)
   return cond;
 }
 
+/* Reverses CONDition; returns NULL if we cannot.  */
+
+static rtx
+reversed_condition (rtx cond)
+{
+  enum rtx_code reversed;
+  reversed = reversed_comparison_code (cond, NULL);
+  if (reversed == UNKNOWN)
+    return NULL_RTX;
+  else
+    return gen_rtx_fmt_ee (reversed,
+                          GET_MODE (cond), XEXP (cond, 0),
+                          XEXP (cond, 1));
+}
+
 /* Tries to use the fact that COND holds to simplify EXPR.  ALTERED is the
    set of altered regs.  */
 
index 4561ce8..f952d9d 100644 (file)
@@ -1060,6 +1060,59 @@ split_edge_and_insert (edge e, rtx insns)
   return bb;
 }
 
+/* Prepare a sequence comparing OP0 with OP1 using COMP and jumping to LABEL if
+   true, with probability PROB.  If CINSN is not NULL, it is the insn to copy
+   in order to create a jump.  */
+
+static rtx
+compare_and_jump_seq (rtx op0, rtx op1, enum rtx_code comp, rtx label, int prob,
+                     rtx cinsn)
+{
+  rtx seq, jump, cond;
+  enum machine_mode mode;
+
+  mode = GET_MODE (op0);
+  if (mode == VOIDmode)
+    mode = GET_MODE (op1);
+
+  start_sequence ();
+  if (GET_MODE_CLASS (mode) == MODE_CC)
+    {
+      /* A hack -- there seems to be no easy generic way how to make a
+        conditional jump from a ccmode comparison.  */
+      gcc_assert (cinsn);
+      cond = XEXP (SET_SRC (pc_set (cinsn)), 0);
+      gcc_assert (GET_CODE (cond) == comp);
+      gcc_assert (rtx_equal_p (op0, XEXP (cond, 0)));
+      gcc_assert (rtx_equal_p (op1, XEXP (cond, 1)));
+      emit_jump_insn (copy_insn (PATTERN (cinsn)));
+      jump = get_last_insn ();
+      gcc_assert (JUMP_P (jump));
+      JUMP_LABEL (jump) = JUMP_LABEL (cinsn);
+      LABEL_NUSES (JUMP_LABEL (jump))++;
+      redirect_jump (jump, label, 0);
+    }
+  else
+    {
+      gcc_assert (!cinsn);
+
+      op0 = force_operand (op0, NULL_RTX);
+      op1 = force_operand (op1, NULL_RTX);
+      do_compare_rtx_and_jump (op0, op1, comp, 0,
+                              mode, NULL_RTX, NULL_RTX, label, -1);
+      jump = get_last_insn ();
+      gcc_assert (JUMP_P (jump));
+      JUMP_LABEL (jump) = label;
+      LABEL_NUSES (label)++;
+    }
+  add_int_reg_note (jump, REG_BR_PROB, prob);
+
+  seq = get_insns ();
+  end_sequence ();
+
+  return seq;
+}
+
 /* Unroll LOOP for which we are able to count number of iterations in runtime
    LOOP->LPT_DECISION.TIMES times.  The transformation does this (with some
    extra care for case n < 0):
index 1ecfb71..506b657 100644 (file)
@@ -341,7 +341,6 @@ along with GCC; see the file COPYING3.  If not see
       PUSH_INSERT_PASSES_WITHIN (pass_loop2)
          NEXT_PASS (pass_rtl_loop_init);
          NEXT_PASS (pass_rtl_move_loop_invariants);
-         NEXT_PASS (pass_rtl_unswitch);
          NEXT_PASS (pass_rtl_unroll_and_peel_loops);
          NEXT_PASS (pass_rtl_doloop);
          NEXT_PASS (pass_rtl_loop_done);
index f1cda4c..3a526a1 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2743,10 +2743,6 @@ extern unsigned int variable_tracking_main (void);
 extern void get_mode_bounds (enum machine_mode, int, enum machine_mode,
                             rtx *, rtx *);
 
-/* In loop-unswitch.c  */
-extern rtx reversed_condition (rtx);
-extern rtx compare_and_jump_seq (rtx, rtx, enum rtx_code, rtx, int, rtx);
-
 /* In loop-iv.c  */
 extern rtx canon_condition (rtx);
 extern void simplify_using_condition (rtx, rtx *, bitmap);
index e63f306..46dc00c 100644 (file)
@@ -509,7 +509,6 @@ extern rtl_opt_pass *make_pass_outof_cfg_layout_mode (gcc::context *ctxt);
 extern rtl_opt_pass *make_pass_loop2 (gcc::context *ctxt);
 extern rtl_opt_pass *make_pass_rtl_loop_init (gcc::context *ctxt);
 extern rtl_opt_pass *make_pass_rtl_move_loop_invariants (gcc::context *ctxt);
-extern rtl_opt_pass *make_pass_rtl_unswitch (gcc::context *ctxt);
 extern rtl_opt_pass *make_pass_rtl_unroll_and_peel_loops (gcc::context *ctxt);
 extern rtl_opt_pass *make_pass_rtl_doloop (gcc::context *ctxt);
 extern rtl_opt_pass *make_pass_rtl_loop_done (gcc::context *ctxt);