1 /* Basic block reordering routines for the GNU compiler.
2 Copyright (C) 2000 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
23 "Profile Guided Code Positioning"
24 Pettis and Hanson; PLDI '90.
32 #include "basic-block.h"
33 #include "insn-config.h"
35 #include "hard-reg-set.h"
42 #include "insn-flags.h"
47 /* The contents of the current function definition are allocated
48 in this obstack, and all are freed at the end of the function.
49 For top-level functions, this is temporary_obstack.
50 Separate obstacks are made for nested functions. */
52 extern struct obstack
*function_obstack
;
55 typedef struct reorder_block_def
{
67 static struct reorder_block_def rbd_init
76 NULL_RTX
, /* eff_head */
77 NULL_RTX
/* eff_end */
81 #define REORDER_BLOCK_HEAD 0x1
82 #define REORDER_BLOCK_VISITED 0x2
84 #define REORDER_BLOCK_FLAGS(bb) \
85 ((reorder_block_def) (bb)->aux)->flags
87 #define REORDER_BLOCK_INDEX(bb) \
88 ((reorder_block_def) (bb)->aux)->index
90 #define REORDER_BLOCK_ADD_JUMP(bb) \
91 ((reorder_block_def) (bb)->aux)->add_jump
93 #define REORDER_BLOCK_SUCC(bb) \
94 ((reorder_block_def) (bb)->aux)->succ
96 #define REORDER_BLOCK_OLD_END(bb) \
97 ((reorder_block_def) (bb)->aux)->end
99 #define REORDER_BLOCK_BEGIN(bb) \
100 ((reorder_block_def) (bb)->aux)->block_begin
102 #define REORDER_BLOCK_END(bb) \
103 ((reorder_block_def) (bb)->aux)->block_end
105 #define REORDER_BLOCK_EFF_HEAD(bb) \
106 ((reorder_block_def) (bb)->aux)->eff_head
108 #define REORDER_BLOCK_EFF_END(bb) \
109 ((reorder_block_def) (bb)->aux)->eff_end
112 static int reorder_index
;
113 static basic_block reorder_last_visited
;
115 enum reorder_skip_type
{REORDER_SKIP_BEFORE
, REORDER_SKIP_AFTER
,
116 REORDER_SKIP_BLOCK_END
};
119 /* Local function prototypes. */
120 static rtx skip_insns_between_block
PARAMS ((basic_block
,
121 enum reorder_skip_type
));
122 static basic_block get_common_dest
PARAMS ((basic_block
, basic_block
));
123 static basic_block chain_reorder_blocks
PARAMS ((edge
, basic_block
));
124 static void make_reorder_chain
PARAMS ((basic_block
));
125 static void fixup_reorder_chain
PARAMS ((void));
126 static void verify_insn_chain
PARAMS ((void));
129 /* Skip over insns BEFORE or AFTER BB which are typically associated with
133 skip_insns_between_block (bb
, skip_type
)
135 enum reorder_skip_type skip_type
;
139 if (skip_type
== REORDER_SKIP_BEFORE
)
141 if (bb
== ENTRY_BLOCK_PTR
)
144 last_insn
= bb
->head
;
145 for (insn
= PREV_INSN (bb
->head
);
146 insn
&& insn
!= BASIC_BLOCK (bb
->index
- 1)->end
;
147 last_insn
= insn
, insn
= PREV_INSN (insn
))
149 if (NEXT_INSN (insn
) != last_insn
)
152 if (GET_CODE (insn
) == NOTE
153 && NOTE_LINE_NUMBER (insn
) != NOTE_INSN_LOOP_END
154 && NOTE_LINE_NUMBER (insn
) != NOTE_INSN_BASIC_BLOCK
155 && NOTE_LINE_NUMBER (insn
) != NOTE_INSN_BLOCK_END
)
165 if (bb
== EXIT_BLOCK_PTR
)
168 for (insn
= NEXT_INSN (bb
->end
);
170 last_insn
= insn
, insn
= NEXT_INSN (insn
))
172 if (bb
->index
+ 1 != n_basic_blocks
173 && insn
== BASIC_BLOCK (bb
->index
+ 1)->head
)
176 if (GET_CODE (insn
) == BARRIER
177 || GET_CODE (insn
) == JUMP_INSN
178 || (GET_CODE (insn
) == NOTE
179 && (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_LOOP_END
180 || NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_END
)))
183 if (GET_CODE (insn
) == CODE_LABEL
184 && GET_CODE (NEXT_INSN (insn
)) == JUMP_INSN
185 && (GET_CODE (PATTERN (NEXT_INSN (insn
))) == ADDR_VEC
187 (NEXT_INSN (insn
))) == ADDR_DIFF_VEC
))
189 insn
= NEXT_INSN (insn
);
193 /* Skip to next non-deleted insn. */
194 if (GET_CODE (insn
) == NOTE
195 && (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_DELETED
196 || NOTE_LINE_NUMBER (insn
) == NOTE_INSN_DELETED_LABEL
))
202 if (skip_type
== REORDER_SKIP_BLOCK_END
)
204 int found_block_end
= 0;
206 for (; insn
; last_insn
= insn
, insn
= NEXT_INSN (insn
))
208 if (bb
->index
+ 1 != n_basic_blocks
209 && insn
== BASIC_BLOCK (bb
->index
+ 1)->head
)
212 if (GET_CODE (insn
) == NOTE
213 && NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_END
)
219 if (GET_CODE (insn
) == NOTE
220 && NOTE_LINE_NUMBER (insn
) == NOTE_INSN_DELETED
)
223 if (GET_CODE (insn
) == NOTE
224 && NOTE_LINE_NUMBER (insn
) >= 0
226 && GET_CODE (NEXT_INSN (insn
)) == NOTE
227 && (NOTE_LINE_NUMBER (NEXT_INSN (insn
))
228 == NOTE_INSN_BLOCK_END
))
233 if (! found_block_end
)
242 /* Return common destination for blocks BB0 and BB1. */
245 get_common_dest (bb0
, bb1
)
246 basic_block bb0
, bb1
;
250 for (e0
= bb0
->succ
; e0
; e0
= e0
->succ_next
)
252 for (e1
= bb1
->succ
; e1
; e1
= e1
->succ_next
)
254 if (e0
->dest
== e1
->dest
)
264 /* Move the destination block for edge E after chain end block CEB
265 Adding jumps and labels is deferred until fixup_reorder_chain. */
268 chain_reorder_blocks (e
, ceb
)
272 basic_block sb
= e
->src
;
273 basic_block db
= e
->dest
;
274 rtx cebe_insn
, cebbe_insn
, dbh_insn
, dbe_insn
;
277 enum cond_types
{NO_COND
, PREDICT_THEN_WITH_ELSE
, PREDICT_ELSE
,
278 PREDICT_THEN_NO_ELSE
, PREDICT_NOT_THEN_NO_ELSE
};
279 enum cond_types cond_type
;
280 enum cond_block_types
{NO_COND_BLOCK
, THEN_BLOCK
, ELSE_BLOCK
,
282 enum cond_block_types cond_block_type
;
285 fprintf (rtl_dump_file
,
286 "Edge from basic block %d to basic block %d last visited %d\n",
287 sb
->index
, db
->index
, ceb
->index
);
289 dbh_insn
= REORDER_BLOCK_EFF_HEAD (db
);
290 cebe_insn
= REORDER_BLOCK_EFF_END (ceb
);
291 cebbe_insn
= skip_insns_between_block (ceb
, REORDER_SKIP_BLOCK_END
);
294 int block_begins
= 0;
297 for (insn
= dbh_insn
; insn
&& insn
!= db
->end
; insn
= NEXT_INSN (insn
))
299 if (GET_CODE (insn
) == NOTE
300 && NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_BEG
)
306 REORDER_BLOCK_BEGIN (sb
) = block_begins
;
314 for (insn
= cebe_insn
; insn
; insn
= NEXT_INSN (insn
))
316 if (PREV_INSN (insn
) == cebbe_insn
)
318 if (GET_CODE (insn
) == NOTE
319 && NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_END
)
325 REORDER_BLOCK_END (ceb
) = block_ends
;
328 /* Blocks are in original order. */
329 if (sb
->index
== ceb
->index
330 && ceb
->index
+ 1 == db
->index
&& NEXT_INSN (cebe_insn
))
333 /* Get the type of block and type of condition. */
335 cond_block_type
= NO_COND_BLOCK
;
336 if (GET_CODE (sb
->end
) == JUMP_INSN
&& ! simplejump_p (sb
->end
)
337 && condjump_p (sb
->end
))
339 if (e
->flags
& EDGE_FALLTHRU
)
340 cond_block_type
= THEN_BLOCK
;
341 else if (get_common_dest (sb
->succ
->dest
, sb
))
342 cond_block_type
= NO_ELSE_BLOCK
;
344 cond_block_type
= ELSE_BLOCK
;
346 if (sb
->succ
->succ_next
347 && get_common_dest (sb
->succ
->dest
, sb
))
349 if (cond_block_type
== THEN_BLOCK
)
351 if (! (REORDER_BLOCK_FLAGS (sb
->succ
->succ_next
->dest
)
352 & REORDER_BLOCK_VISITED
))
353 cond_type
= PREDICT_THEN_NO_ELSE
;
355 cond_type
= PREDICT_NOT_THEN_NO_ELSE
;
357 else if (cond_block_type
== NO_ELSE_BLOCK
)
359 if (! (REORDER_BLOCK_FLAGS (sb
->succ
->dest
)
360 & REORDER_BLOCK_VISITED
))
361 cond_type
= PREDICT_NOT_THEN_NO_ELSE
;
363 cond_type
= PREDICT_THEN_NO_ELSE
;
368 if (cond_block_type
== THEN_BLOCK
)
370 if (! (REORDER_BLOCK_FLAGS (sb
->succ
->succ_next
->dest
)
371 & REORDER_BLOCK_VISITED
))
372 cond_type
= PREDICT_THEN_WITH_ELSE
;
374 cond_type
= PREDICT_ELSE
;
376 else if (cond_block_type
== ELSE_BLOCK
377 && sb
->succ
->dest
!= EXIT_BLOCK_PTR
)
379 if (! (REORDER_BLOCK_FLAGS (sb
->succ
->dest
)
380 & REORDER_BLOCK_VISITED
))
381 cond_type
= PREDICT_ELSE
;
383 cond_type
= PREDICT_THEN_WITH_ELSE
;
390 static const char * cond_type_str
[] = {"not cond jump", "predict then",
392 "predict then w/o else",
393 "predict not then w/o else"};
394 static const char * cond_block_type_str
[] = {"not then or else block",
397 "then w/o else block"};
399 fprintf (rtl_dump_file
, " %s (looking at %s)\n",
400 cond_type_str
[(int)cond_type
],
401 cond_block_type_str
[(int)cond_block_type
]);
404 /* Reflect that then block will move and we'll jump to it. */
405 if (cond_block_type
!= THEN_BLOCK
406 && (cond_type
== PREDICT_ELSE
407 || cond_type
== PREDICT_NOT_THEN_NO_ELSE
))
410 fprintf (rtl_dump_file
,
411 " then jump from block %d to block %d\n",
412 sb
->index
, sb
->succ
->dest
->index
);
414 /* Jump to reordered then block. */
415 REORDER_BLOCK_ADD_JUMP (sb
) = sb
->succ
->dest
;
418 /* Reflect that then block will jump back when we have no else. */
419 if (cond_block_type
!= THEN_BLOCK
420 && cond_type
== PREDICT_NOT_THEN_NO_ELSE
)
422 for (ee
= sb
->succ
->dest
->succ
;
423 ee
&& ! (ee
->flags
& EDGE_FALLTHRU
);
427 if (ee
&& ! (GET_CODE (sb
->succ
->dest
->end
) == JUMP_INSN
428 && ! simplejump_p (sb
->succ
->dest
->end
)))
430 REORDER_BLOCK_ADD_JUMP (sb
->succ
->dest
) = ee
->dest
;
434 /* Reflect that else block will jump back. */
435 if (cond_block_type
== ELSE_BLOCK
436 && (cond_type
== PREDICT_THEN_WITH_ELSE
|| cond_type
== PREDICT_ELSE
))
441 && last_edge
->dest
!= EXIT_BLOCK_PTR
442 && GET_CODE (last_edge
->dest
->head
) == CODE_LABEL
443 && ! (GET_CODE (db
->end
) == JUMP_INSN
))
446 fprintf (rtl_dump_file
,
447 " else jump from block %d to block %d\n",
448 db
->index
, last_edge
->dest
->index
);
450 REORDER_BLOCK_ADD_JUMP (db
) = last_edge
->dest
;
454 /* This block's successor has already been reordered. This can happen
455 when we reorder a chain starting at a then or else. */
456 for (last_edge
= db
->succ
;
457 last_edge
&& ! (last_edge
->flags
& EDGE_FALLTHRU
);
458 last_edge
= last_edge
->succ_next
)
462 && last_edge
->dest
!= EXIT_BLOCK_PTR
463 && (REORDER_BLOCK_FLAGS (last_edge
->dest
)
464 & REORDER_BLOCK_VISITED
))
467 fprintf (rtl_dump_file
,
468 " end of chain jump from block %d to block %d\n",
469 db
->index
, last_edge
->dest
->index
);
471 REORDER_BLOCK_ADD_JUMP (db
) = last_edge
->dest
;
474 dbh_insn
= REORDER_BLOCK_EFF_HEAD (db
);
475 cebe_insn
= REORDER_BLOCK_EFF_END (ceb
);
476 dbe_insn
= REORDER_BLOCK_EFF_END (db
);
478 /* Leave behind any lexical block markers. */
479 if (debug_info_level
> DINFO_LEVEL_TERSE
480 && ceb
->index
+ 1 < db
->index
)
482 rtx insn
, last_insn
= get_last_insn ();
483 insn
= NEXT_INSN (ceb
->end
);
485 insn
= REORDER_BLOCK_OLD_END (ceb
);
487 if (NEXT_INSN (cebe_insn
) == 0)
488 set_last_insn (cebe_insn
);
489 for (; insn
&& insn
!= db
->head
/*dbh_insn*/;
490 insn
= NEXT_INSN (insn
))
492 if (GET_CODE (insn
) == NOTE
493 && (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_BEG
))
495 cebe_insn
= emit_note_after (NOTE_INSN_BLOCK_BEG
, cebe_insn
);
498 if (GET_CODE (insn
) == NOTE
499 && (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_END
))
501 cebe_insn
= emit_note_after (NOTE_INSN_BLOCK_END
, cebe_insn
);
505 set_last_insn (last_insn
);
508 /* Rechain predicted block. */
509 NEXT_INSN (cebe_insn
) = dbh_insn
;
510 PREV_INSN (dbh_insn
) = cebe_insn
;
512 REORDER_BLOCK_OLD_END (db
) = NEXT_INSN (dbe_insn
);
513 if (db
->index
!= n_basic_blocks
- 1)
514 NEXT_INSN (dbe_insn
) = 0;
520 /* Reorder blocks starting at block BB. */
523 make_reorder_chain (bb
)
527 basic_block visited_edge
= NULL
;
531 if (bb
== EXIT_BLOCK_PTR
)
534 /* Find the most probable block. */
537 if (GET_CODE (block_end
) == JUMP_INSN
&& condjump_p (block_end
))
539 rtx note
= find_reg_note (block_end
, REG_BR_PROB
, 0);
542 probability
= INTVAL (XEXP (note
, 0));
546 if (probability
>= REG_BR_PROB_BASE
/ 2)
547 e
= bb
->succ
->succ_next
;
550 /* Add chosen successor to chain and recurse on it. */
551 if (e
&& e
->dest
!= EXIT_BLOCK_PTR
553 && (! (REORDER_BLOCK_FLAGS (e
->dest
) & REORDER_BLOCK_VISITED
)
554 || (REORDER_BLOCK_FLAGS (e
->dest
) == REORDER_BLOCK_HEAD
)))
556 if (! (REORDER_BLOCK_FLAGS (bb
) & REORDER_BLOCK_VISITED
))
558 REORDER_BLOCK_FLAGS (bb
) |= REORDER_BLOCK_HEAD
;
559 REORDER_BLOCK_INDEX (bb
) = reorder_index
++;
560 REORDER_BLOCK_FLAGS (bb
) |= REORDER_BLOCK_VISITED
;
563 if (REORDER_BLOCK_FLAGS (e
->dest
) & REORDER_BLOCK_VISITED
)
564 REORDER_BLOCK_FLAGS (e
->dest
) &= ~REORDER_BLOCK_HEAD
;
566 REORDER_BLOCK_SUCC (bb
) = e
;
568 visited_edge
= e
->dest
;
570 reorder_last_visited
= chain_reorder_blocks (e
, bb
);
573 && ! (REORDER_BLOCK_FLAGS (e
->dest
)
574 & REORDER_BLOCK_VISITED
))
575 make_reorder_chain (e
->dest
);
579 if (! (REORDER_BLOCK_FLAGS (bb
) & REORDER_BLOCK_VISITED
))
581 REORDER_BLOCK_INDEX (bb
) = reorder_index
++;
582 REORDER_BLOCK_FLAGS (bb
) |= REORDER_BLOCK_VISITED
;
586 /* Recurse on the successors. */
587 for (e
= bb
->succ
; e
; e
= e
->succ_next
)
589 if (e
->dest
&& e
->dest
== EXIT_BLOCK_PTR
)
594 && e
->dest
!= visited_edge
595 && ! (REORDER_BLOCK_FLAGS (e
->dest
)
596 & REORDER_BLOCK_VISITED
))
599 = chain_reorder_blocks (e
, reorder_last_visited
);
600 make_reorder_chain (e
->dest
);
606 /* Fixup jumps and labels after reordering basic blocks. */
609 fixup_reorder_chain ()
613 int orig_num_blocks
= n_basic_blocks
;
615 /* Set the new last insn. */
619 for (j
= 0; j
< n_basic_blocks
; j
++)
621 int val
= REORDER_BLOCK_INDEX (BASIC_BLOCK (j
));
628 insn
= REORDER_BLOCK_EFF_END (BASIC_BLOCK (max_index
));
629 NEXT_INSN (insn
) = NULL_RTX
;
630 set_last_insn (insn
);
633 /* Add jumps and labels to fixup blocks. */
634 for (i
= 0; i
< orig_num_blocks
; i
++)
637 basic_block bbi
= BASIC_BLOCK (i
);
638 if (REORDER_BLOCK_ADD_JUMP (bbi
))
640 rtx label_insn
, jump_insn
, barrier_insn
;
642 if (GET_CODE (REORDER_BLOCK_ADD_JUMP (bbi
)->head
) == CODE_LABEL
)
643 label_insn
= REORDER_BLOCK_ADD_JUMP (bbi
)->head
;
646 rtx new_label
= gen_label_rtx ();
647 label_insn
= emit_label_before (new_label
,
648 REORDER_BLOCK_ADD_JUMP (bbi
)->head
);
649 REORDER_BLOCK_ADD_JUMP (bbi
)->head
= label_insn
;
652 if (GET_CODE (bbi
->end
) != JUMP_INSN
)
654 jump_insn
= emit_jump_insn_after (gen_jump (label_insn
),
656 bbi
->end
= jump_insn
;
661 jump_insn
= emit_jump_insn_after (gen_jump (label_insn
),
662 REORDER_BLOCK_EFF_END (bbi
));
666 JUMP_LABEL (jump_insn
) = label_insn
;
667 ++LABEL_NUSES (label_insn
);
668 barrier_insn
= emit_barrier_after (jump_insn
);
670 /* Add block for jump. Typically this is when a then is not
671 predicted and we are jumping to the moved then block. */
676 VARRAY_GROW (basic_block_info
, ++n_basic_blocks
);
677 create_basic_block (n_basic_blocks
- 1, jump_insn
,
679 nb
= BASIC_BLOCK (n_basic_blocks
- 1);
680 nb
->global_live_at_start
681 = OBSTACK_ALLOC_REG_SET (function_obstack
);
682 nb
->global_live_at_end
683 = OBSTACK_ALLOC_REG_SET (function_obstack
);
685 COPY_REG_SET (nb
->global_live_at_start
,
686 bbi
->global_live_at_start
);
687 COPY_REG_SET (nb
->global_live_at_end
,
688 bbi
->global_live_at_start
);
689 BASIC_BLOCK (nb
->index
)->local_set
= 0;
691 nb
->aux
= xcalloc (1, sizeof (struct reorder_block_def
));
692 REORDER_BLOCK_INDEX (BASIC_BLOCK (n_basic_blocks
- 1))
693 = REORDER_BLOCK_INDEX (bbi
) + 1;
694 /* Relink to new block. */
695 nb
->succ
= bbi
->succ
;
698 make_edge (NULL
, bbi
, nb
, 0);
700 = bbi
->succ
->succ_next
->succ_next
;
701 nb
->succ
->succ_next
= 0;
702 /* Fix reorder block index to reflect new block. */
703 for (j
= 0; j
< n_basic_blocks
- 1; j
++)
705 basic_block bbj
= BASIC_BLOCK (j
);
706 if (REORDER_BLOCK_INDEX (bbj
)
707 >= REORDER_BLOCK_INDEX (bbi
) + 1)
708 REORDER_BLOCK_INDEX (bbj
)++;
716 /* Perform sanity checks on the insn chain.
717 1. Check that next/prev pointers are consistent in both the forward and
719 2. Count insns in chain, going both directions, and check if equal.
720 3. Check that get_last_insn () returns the actual end of chain. */
733 for (x
= get_insns (); x
; x
= NEXT_INSN (x
))
735 if (PREV_INSN (x
) != prevx
)
737 fprintf (stderr
, "Forward traversal: insn chain corrupt.\n");
738 fprintf (stderr
, "previous insn:\n");
740 fprintf (stderr
, "current insn:\n");
748 if (prevx
!= get_last_insn ())
750 fprintf (stderr
, "last_insn corrupt.\n");
756 for (x
= get_last_insn (); x
; x
= PREV_INSN (x
))
758 if (NEXT_INSN (x
) != nextx
)
760 fprintf (stderr
, "Reverse traversal: insn chain corrupt.\n");
761 fprintf (stderr
, "current insn:\n");
763 fprintf (stderr
, "next insn:\n");
771 if (insn_cnt1
!= insn_cnt2
)
773 fprintf (stderr
, "insn_cnt1 (%d) not equal to insn_cnt2 (%d).\n",
774 insn_cnt1
, insn_cnt2
);
780 /* Reorder basic blocks. */
783 reorder_basic_blocks ()
786 struct loops loops_info
;
789 if (profile_arc_flag
)
792 if (n_basic_blocks
<= 1)
795 /* Exception edges are not currently handled. */
796 for (i
= 0; i
< n_basic_blocks
; i
++)
800 for (e
= BASIC_BLOCK (i
)->succ
; e
&& ! (e
->flags
& EDGE_EH
);
804 if (e
&& (e
->flags
& EDGE_EH
))
810 /* Find natural loops using the CFG. */
811 num_loops
= flow_loops_find (&loops_info
);
813 /* Dump loop information. */
814 flow_loops_dump (&loops_info
, rtl_dump_file
, 0);
816 /* Estimate using heuristics if no profiling info is available. */
817 if (! flag_branch_probabilities
)
818 estimate_probability (&loops_info
);
820 reorder_last_visited
= BASIC_BLOCK (0);
822 for (i
= 0; i
< n_basic_blocks
; i
++)
824 basic_block bbi
= BASIC_BLOCK (i
);
825 bbi
->aux
= xcalloc (1, sizeof (struct reorder_block_def
));
826 *((struct reorder_block_def
*)bbi
->aux
) = rbd_init
;
827 REORDER_BLOCK_EFF_END (bbi
)
828 = skip_insns_between_block (bbi
, REORDER_SKIP_AFTER
);
830 REORDER_BLOCK_EFF_HEAD (bbi
) = get_insns ();
833 rtx prev_eff_end
= REORDER_BLOCK_EFF_END (BASIC_BLOCK (i
- 1));
834 REORDER_BLOCK_EFF_HEAD (bbi
) = NEXT_INSN (prev_eff_end
);
838 make_reorder_chain (BASIC_BLOCK (0));
840 fixup_reorder_chain ();
842 #ifdef ENABLE_CHECKING
843 verify_insn_chain ();
846 /* Put basic_block_info in new order. */
847 for (i
= 0; i
< n_basic_blocks
- 1; i
++)
849 for (j
= i
; i
!= REORDER_BLOCK_INDEX (BASIC_BLOCK (j
)); j
++)
852 if (REORDER_BLOCK_INDEX (BASIC_BLOCK (j
)) == i
857 int rbi
= REORDER_BLOCK_INDEX (BASIC_BLOCK (j
));
859 temprbi
= BASIC_BLOCK (rbi
)->index
;
860 BASIC_BLOCK (rbi
)->index
= BASIC_BLOCK (j
)->index
;
861 BASIC_BLOCK (j
)->index
= temprbi
;
862 tempbb
= BASIC_BLOCK (rbi
);
863 BASIC_BLOCK (rbi
) = BASIC_BLOCK (j
);
864 BASIC_BLOCK (j
) = tempbb
;
868 #ifdef ENABLE_CHECKING
872 for (i
= 0; i
< n_basic_blocks
; i
++)
873 free (BASIC_BLOCK (i
)->aux
);
875 /* Free loop information. */
876 flow_loops_free (&loops_info
);