loop.c (find_and_verify_loops): When attempting to move insns from inside the loop...
authorJeffrey A Law <law@cygnus.com>
Sat, 17 Jan 1998 21:50:05 +0000 (21:50 +0000)
committerJeff Law <law@gcc.gnu.org>
Sat, 17 Jan 1998 21:50:05 +0000 (14:50 -0700)
        * loop.c (find_and_verify_loops): When attempting to move insns from
        inside the loop outside the loop, create a BARRIER if no suitable
        one was found.

From-SVN: r17399

gcc/ChangeLog
gcc/loop.c

index 7a660ffad31f515b64096b7e82efc212cc60ca9e..299297dba0978fa42569b05e2a6923a44a2afd9c 100644 (file)
@@ -23,6 +23,10 @@ Sat Jan 17 21:24:16 1998  David T. McWherter <dtm@waterw.com>
 
 Sat Jan 17 21:16:19 1998  Jeffrey A Law  (law@cygnus.com)
 
+       * loop.c (find_and_verify_loops): When attempting to move insns from
+       inside the loop outside the loop, create a BARRIER if no suitable
+       one was found.
+
        * jump.c (jump_optimize): Remove Dec 17, 1997 chance in
        favor of an equivalent change from gcc-2.8.
 
index 222620171fb32f59844e567965a1c70b3073bc25..0fa3b4f0d2ba899c0d54369d482445f462f6e233 100644 (file)
@@ -2531,6 +2531,27 @@ find_and_verify_loops (f)
                     {
                       rtx q, r;
 
+                      /* If no suitable BARRIER was found, create a suitable
+                         one before TARGET.  Since TARGET is a fall through
+                         path, we'll need to insert an jump around our block
+                         and a add a BARRIER before TARGET.
+
+                         This creates an extra unconditional jump outside
+                         the loop.  However, the benefits of removing rarely
+                         executed instructions from inside the loop usually
+                         outweighs the cost of the extra unconditional jump
+                         outside the loop.  */
+                      if (loc == 0)
+                        {
+                          rtx temp;
+
+                          temp = gen_jump (JUMP_LABEL (insn));
+                          temp = emit_jump_insn_before (temp, target);
+                          JUMP_LABEL (temp) = JUMP_LABEL (insn);
+                          LABEL_NUSES (JUMP_LABEL (insn))++;
+                          loc = emit_barrier_before (target);
+                        }
+
                       /* Include the BARRIER after INSN and copy the
                          block after LOC.  */
                       new_label = squeeze_notes (new_label, NEXT_INSN (insn));