bfin.c (find_prev_insn_start): New function.
authorBernd Schmidt <bernd.schmidt@analog.com>
Fri, 13 Feb 2009 11:41:22 +0000 (11:41 +0000)
committerBernd Schmidt <bernds@gcc.gnu.org>
Fri, 13 Feb 2009 11:41:22 +0000 (11:41 +0000)
* config/bfin/bfin.c (find_prev_insn_start): New function.
(bfin_optimize_loop): Use it in some cases instead of PREV_INSN.
(find_next_insn_start): Move.

From-SVN: r144153

gcc/ChangeLog
gcc/config/bfin/bfin.c

index 53bb0b0ed3b77809e0f5e81b6d1d85f0b5bc7b3f..ee937fc9aea9bd51112f338a3cfd17449ebc4bf0 100644 (file)
@@ -3,6 +3,10 @@
        * loop-iv.c (implies_p): In the final case, test that operands 0
        of the two comparisons match.
 
+       * config/bfin/bfin.c (find_prev_insn_start): New function.
+       (bfin_optimize_loop): Use it in some cases instead of PREV_INSN.
+       (find_next_insn_start): Move.
+
 2009-02-13  Richard Guenther  <rguenther@suse.de>
 
        * configure.ac: Enable LFS.
index 949ceaca0157d457855dc31c98e88b2d85d0401f..dcfbd1f00338b25a92c55542c8f4dc9ce19f7c25 100644 (file)
@@ -3554,7 +3554,36 @@ bfin_adjust_cost (rtx insn, rtx link, rtx dep_insn, int cost)
 
   return cost;
 }
+\f
+/* This function acts like NEXT_INSN, but is aware of three-insn bundles and
+   skips all subsequent parallel instructions if INSN is the start of such
+   a group.  */
+static rtx
+find_next_insn_start (rtx insn)
+{
+  if (GET_MODE (insn) == SImode)
+    {
+      while (GET_MODE (insn) != QImode)
+       insn = NEXT_INSN (insn);
+    }
+  return NEXT_INSN (insn);
+}
 
+/* This function acts like PREV_INSN, but is aware of three-insn bundles and
+   skips all subsequent parallel instructions if INSN is the start of such
+   a group.  */
+static rtx
+find_prev_insn_start (rtx insn)
+{
+  insn = PREV_INSN (insn);
+  gcc_assert (GET_MODE (insn) != SImode);
+  if (GET_MODE (insn) == QImode)
+    {
+      while (GET_MODE (PREV_INSN (insn)) == SImode)
+       insn = PREV_INSN (insn);
+    }
+  return insn;
+}
 \f
 /* Increment the counter for the number of loop instructions in the
    current function.  */
@@ -3932,16 +3961,16 @@ bfin_optimize_loop (loop_info loop)
      - Returns (RTS, RTN, etc.)  */
 
   bb = loop->tail;
-  last_insn = PREV_INSN (loop->loop_end);
+  last_insn = find_prev_insn_start (loop->loop_end);
 
   while (1)
     {
-      for (; last_insn != PREV_INSN (BB_HEAD (bb));
-          last_insn = PREV_INSN (last_insn))
+      for (; last_insn != BB_HEAD (bb);
+          last_insn = find_prev_insn_start (last_insn))
        if (INSN_P (last_insn))
          break;
 
-      if (last_insn != PREV_INSN (BB_HEAD (bb)))
+      if (last_insn != BB_HEAD (bb))
        break;
 
       if (single_pred_p (bb)
@@ -4888,20 +4917,6 @@ trapping_loads_p (rtx insn)
     return may_trap_p (SET_SRC (single_set (insn)));
 }
 
-/* This function acts like NEXT_INSN, but is aware of three-insn bundles and
-   skips all subsequent parallel instructions if INSN is the start of such
-   a group.  */
-static rtx
-find_next_insn_start (rtx insn)
-{
-  if (GET_MODE (insn) == SImode)
-    {
-      while (GET_MODE (insn) != QImode)
-       insn = NEXT_INSN (insn);
-    }
-  return NEXT_INSN (insn);
-}
-
 /* Return INSN if it is of TYPE_MCLD.  Alternatively, if INSN is the start of
    a three-insn bundle, see if one of them is a load and return that if so.
    Return NULL_RTX if the insn does not contain loads.  */