* flow.c (split_edge): Take looping structure into account when
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Nov 1999 06:45:55 +0000 (06:45 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Nov 1999 06:45:55 +0000 (06:45 +0000)
determining where to put the new block note.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@30567 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/flow.c

index d3668ce..baa083c 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 fee2f55..8378372 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 ());