flow.c (split_edge): Take looping structure into account when determining where to...
authorJeffrey A Law <law@cygnus.com>
Thu, 18 Nov 1999 06:45:55 +0000 (06:45 +0000)
committerJeff Law <law@gcc.gnu.org>
Thu, 18 Nov 1999 06:45:55 +0000 (23:45 -0700)
* flow.c (split_edge): Take looping structure into account when
determining where to put the new block note.

From-SVN: r30567

gcc/ChangeLog
gcc/flow.c

index d3668cecb6aee25e0ca674ddef5a8666f87863af..baa083cb1ac78bd01fdf3ceedfcfa4f0decb454f 100644 (file)
@@ -1,3 +1,8 @@
+Wed Nov 17 23:46:14 1999  Jeffrey A Law  (law@cygnus.com)
+
+       * flow.c (split_edge): Take looping structure into account when
+       determining where to put the new block note.
+
 Wed Nov 17 20:42:43 1999  Jeff Holcomb  <jeffh@cygnus.com>
 
        * Makefile.in (ggc-none.o): Provide host specific version if
index fee2f551fc66a88bee6f13465e14ff9f6de821bd..837837222885136ecbbf252ed66752fb291fbfd5 100644 (file)
@@ -1422,8 +1422,31 @@ split_edge (edge_in)
   BASIC_BLOCK (i) = bb;
   bb->index = i;
 
-  /* Create the basic block note.  */
-  if (old_succ != EXIT_BLOCK_PTR)
+  /* Create the basic block note. 
+
+     Where we place the note can have a noticable impact on the generated
+     code.  Consider this cfg: 
+       
+
+                       E
+                       |
+                       0
+                      / \
+                  +->1-->2--->E
+                   |  |
+                  +--+
+
+      If we need to insert an insn on the edge from block 0 to block 1,
+      we want to ensure the instructions we insert are outside of any
+      loop notes that physically sit between block 0 and block 1.  Otherwise
+      we confuse the loop optimizer into thinking the loop is a phony.  */
+  if (old_succ != EXIT_BLOCK_PTR
+      && PREV_INSN (old_succ->head)
+      && GET_CODE (PREV_INSN (old_succ->head)) == NOTE
+      && NOTE_LINE_NUMBER (PREV_INSN (old_succ->head)) == NOTE_INSN_LOOP_BEG)
+    bb_note = emit_note_before (NOTE_INSN_BASIC_BLOCK,
+                               PREV_INSN (old_succ->head));
+  else if (old_succ != EXIT_BLOCK_PTR)
     bb_note = emit_note_before (NOTE_INSN_BASIC_BLOCK, old_succ->head);
   else
     bb_note = emit_note_after (NOTE_INSN_BASIC_BLOCK, get_last_insn ());