bfin.c (bfin_discover_loops): Delete empty loops.
authorBernd Schmidt <bernd.schmidt@analog.com>
Fri, 16 May 2008 11:03:23 +0000 (11:03 +0000)
committerBernd Schmidt <bernds@gcc.gnu.org>
Fri, 16 May 2008 11:03:23 +0000 (11:03 +0000)
* config/bfin/bfin.c (bfin_discover_loops): Delete empty loops.

From-SVN: r135414

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

index e0c5c3549643d47904f3883fa570d7474fbef81a..5cd0d1fa52e3a417eaad8f26c5bbe6c009b6ce4b 100644 (file)
@@ -1,5 +1,7 @@
 2008-05-16  Bernd Schmidt  <bernd.schmidt@analog.com>
 
+       * config/bfin/bfin.c (bfin_discover_loops): Delete empty loops.
+
        From Jie Zhang  <jie.zhang@analog.com>
         * config/bfin/t-bfin-elf (MULTILIB_OPTIONS, MULTILIB_DIRNAMES,
        MULTILIB_MATCHES, MULTILIB_EXCEPTIONS): Remove mcpu=bf532-0.3,
index d24570f707ef760d1cce33163a0afbd1f34a0bfe..d6506b6e09bfb347b9e7c2d37a27e24a7a406b75 100644 (file)
@@ -4218,8 +4218,23 @@ bfin_discover_loops (bitmap_obstack *stack, FILE *dump_file)
 
       if (INSN_P (tail) && recog_memoized (tail) == CODE_FOR_loop_end)
        {
+         rtx insn;
          /* A possible loop end */
 
+         /* There's a degenerate case we can handle - an empty loop consisting
+            of only a back branch.  Handle that by deleting the branch.  */
+         insn = BB_HEAD (BRANCH_EDGE (bb)->dest);
+         if (next_real_insn (insn) == tail)
+           {
+             if (dump_file)
+               {
+                 fprintf (dump_file, ";; degenerate loop ending at\n");
+                 print_rtl_single (dump_file, tail);
+               }
+             delete_insn_and_edges (tail);
+             continue;
+           }
+
          loop = XNEW (struct loop_info);
          loop->next = loops;
          loops = loop;