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 #ifdef ENABLE_CHECKING
127 static void verify_insn_chain
PARAMS ((void));
130 /* Skip over insns BEFORE or AFTER BB which are typically associated with
134 skip_insns_between_block (bb
, skip_type
)
136 enum reorder_skip_type skip_type
;
140 if (skip_type
== REORDER_SKIP_BEFORE
)
142 if (bb
== ENTRY_BLOCK_PTR
)
145 last_insn
= bb
->head
;
146 for (insn
= PREV_INSN (bb
->head
);
147 insn
&& insn
!= BASIC_BLOCK (bb
->index
- 1)->end
;
148 last_insn
= insn
, insn
= PREV_INSN (insn
))
150 if (NEXT_INSN (insn
) != last_insn
)
153 if (GET_CODE (insn
) == NOTE
154 && NOTE_LINE_NUMBER (insn
) != NOTE_INSN_LOOP_END
155 && NOTE_LINE_NUMBER (insn
) != NOTE_INSN_BASIC_BLOCK
156 && NOTE_LINE_NUMBER (insn
) != NOTE_INSN_BLOCK_END
)
166 if (bb
== EXIT_BLOCK_PTR
)
169 for (insn
= NEXT_INSN (bb
->end
);
171 last_insn
= insn
, insn
= NEXT_INSN (insn
))
173 if (bb
->index
+ 1 != n_basic_blocks
174 && insn
== BASIC_BLOCK (bb
->index
+ 1)->head
)
177 if (GET_CODE (insn
) == BARRIER
178 || GET_CODE (insn
) == JUMP_INSN
179 || (GET_CODE (insn
) == NOTE
180 && (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_LOOP_END
181 || NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_END
)))
184 if (GET_CODE (insn
) == CODE_LABEL
185 && GET_CODE (NEXT_INSN (insn
)) == JUMP_INSN
186 && (GET_CODE (PATTERN (NEXT_INSN (insn
))) == ADDR_VEC
188 (NEXT_INSN (insn
))) == ADDR_DIFF_VEC
))
190 insn
= NEXT_INSN (insn
);
194 /* Skip to next non-deleted insn. */
195 if (GET_CODE (insn
) == NOTE
196 && (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_DELETED
197 || NOTE_LINE_NUMBER (insn
) == NOTE_INSN_DELETED_LABEL
))
203 if (skip_type
== REORDER_SKIP_BLOCK_END
)
205 int found_block_end
= 0;
207 for (; insn
; last_insn
= insn
, insn
= NEXT_INSN (insn
))
209 if (bb
->index
+ 1 != n_basic_blocks
210 && insn
== BASIC_BLOCK (bb
->index
+ 1)->head
)
213 if (GET_CODE (insn
) == NOTE
214 && NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_END
)
220 if (GET_CODE (insn
) == NOTE
221 && NOTE_LINE_NUMBER (insn
) == NOTE_INSN_DELETED
)
224 if (GET_CODE (insn
) == NOTE
225 && NOTE_LINE_NUMBER (insn
) >= 0
227 && GET_CODE (NEXT_INSN (insn
)) == NOTE
228 && (NOTE_LINE_NUMBER (NEXT_INSN (insn
))
229 == NOTE_INSN_BLOCK_END
))
234 if (! found_block_end
)
243 /* Return common destination for blocks BB0 and BB1. */
246 get_common_dest (bb0
, bb1
)
247 basic_block bb0
, bb1
;
251 for (e0
= bb0
->succ
; e0
; e0
= e0
->succ_next
)
253 for (e1
= bb1
->succ
; e1
; e1
= e1
->succ_next
)
255 if (e0
->dest
== e1
->dest
)
265 /* Move the destination block for edge E after chain end block CEB
266 Adding jumps and labels is deferred until fixup_reorder_chain. */
269 chain_reorder_blocks (e
, ceb
)
273 basic_block sb
= e
->src
;
274 basic_block db
= e
->dest
;
275 rtx cebe_insn
, cebbe_insn
, dbh_insn
, dbe_insn
;
278 enum cond_types
{NO_COND
, PREDICT_THEN_WITH_ELSE
, PREDICT_ELSE
,
279 PREDICT_THEN_NO_ELSE
, PREDICT_NOT_THEN_NO_ELSE
};
280 enum cond_types cond_type
;
281 enum cond_block_types
{NO_COND_BLOCK
, THEN_BLOCK
, ELSE_BLOCK
,
283 enum cond_block_types cond_block_type
;
286 fprintf (rtl_dump_file
,
287 "Edge from basic block %d to basic block %d last visited %d\n",
288 sb
->index
, db
->index
, ceb
->index
);
290 dbh_insn
= REORDER_BLOCK_EFF_HEAD (db
);
291 cebe_insn
= REORDER_BLOCK_EFF_END (ceb
);
292 cebbe_insn
= skip_insns_between_block (ceb
, REORDER_SKIP_BLOCK_END
);
295 int block_begins
= 0;
298 for (insn
= dbh_insn
; insn
&& insn
!= db
->end
; insn
= NEXT_INSN (insn
))
300 if (GET_CODE (insn
) == NOTE
301 && NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_BEG
)
307 REORDER_BLOCK_BEGIN (sb
) = block_begins
;
315 for (insn
= cebe_insn
; insn
; insn
= NEXT_INSN (insn
))
317 if (PREV_INSN (insn
) == cebbe_insn
)
319 if (GET_CODE (insn
) == NOTE
320 && NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_END
)
326 REORDER_BLOCK_END (ceb
) = block_ends
;
329 /* Blocks are in original order. */
330 if (sb
->index
== ceb
->index
331 && ceb
->index
+ 1 == db
->index
&& NEXT_INSN (cebe_insn
))
334 /* Get the type of block and type of condition. */
336 cond_block_type
= NO_COND_BLOCK
;
337 if (GET_CODE (sb
->end
) == JUMP_INSN
&& ! simplejump_p (sb
->end
)
338 && condjump_p (sb
->end
))
340 if (e
->flags
& EDGE_FALLTHRU
)
341 cond_block_type
= THEN_BLOCK
;
342 else if (get_common_dest (sb
->succ
->dest
, sb
))
343 cond_block_type
= NO_ELSE_BLOCK
;
345 cond_block_type
= ELSE_BLOCK
;
347 if (sb
->succ
->succ_next
348 && get_common_dest (sb
->succ
->dest
, sb
))
350 if (cond_block_type
== THEN_BLOCK
)
352 if (! (REORDER_BLOCK_FLAGS (sb
->succ
->succ_next
->dest
)
353 & REORDER_BLOCK_VISITED
))
354 cond_type
= PREDICT_THEN_NO_ELSE
;
356 cond_type
= PREDICT_NOT_THEN_NO_ELSE
;
358 else if (cond_block_type
== NO_ELSE_BLOCK
)
360 if (! (REORDER_BLOCK_FLAGS (sb
->succ
->dest
)
361 & REORDER_BLOCK_VISITED
))
362 cond_type
= PREDICT_NOT_THEN_NO_ELSE
;
364 cond_type
= PREDICT_THEN_NO_ELSE
;
369 if (cond_block_type
== THEN_BLOCK
)
371 if (! (REORDER_BLOCK_FLAGS (sb
->succ
->succ_next
->dest
)
372 & REORDER_BLOCK_VISITED
))
373 cond_type
= PREDICT_THEN_WITH_ELSE
;
375 cond_type
= PREDICT_ELSE
;
377 else if (cond_block_type
== ELSE_BLOCK
378 && sb
->succ
->dest
!= EXIT_BLOCK_PTR
)
380 if (! (REORDER_BLOCK_FLAGS (sb
->succ
->dest
)
381 & REORDER_BLOCK_VISITED
))
382 cond_type
= PREDICT_ELSE
;
384 cond_type
= PREDICT_THEN_WITH_ELSE
;
391 static const char * cond_type_str
[] = {"not cond jump", "predict then",
393 "predict then w/o else",
394 "predict not then w/o else"};
395 static const char * cond_block_type_str
[] = {"not then or else block",
398 "then w/o else block"};
400 fprintf (rtl_dump_file
, " %s (looking at %s)\n",
401 cond_type_str
[(int)cond_type
],
402 cond_block_type_str
[(int)cond_block_type
]);
405 /* Reflect that then block will move and we'll jump to it. */
406 if (cond_block_type
!= THEN_BLOCK
407 && (cond_type
== PREDICT_ELSE
408 || cond_type
== PREDICT_NOT_THEN_NO_ELSE
))
411 fprintf (rtl_dump_file
,
412 " then jump from block %d to block %d\n",
413 sb
->index
, sb
->succ
->dest
->index
);
415 /* Jump to reordered then block. */
416 REORDER_BLOCK_ADD_JUMP (sb
) = sb
->succ
->dest
;
419 /* Reflect that then block will jump back when we have no else. */
420 if (cond_block_type
!= THEN_BLOCK
421 && cond_type
== PREDICT_NOT_THEN_NO_ELSE
)
423 for (ee
= sb
->succ
->dest
->succ
;
424 ee
&& ! (ee
->flags
& EDGE_FALLTHRU
);
428 if (ee
&& ! (GET_CODE (sb
->succ
->dest
->end
) == JUMP_INSN
429 && ! simplejump_p (sb
->succ
->dest
->end
)))
431 REORDER_BLOCK_ADD_JUMP (sb
->succ
->dest
) = ee
->dest
;
435 /* Reflect that else block will jump back. */
436 if (cond_block_type
== ELSE_BLOCK
437 && (cond_type
== PREDICT_THEN_WITH_ELSE
|| cond_type
== PREDICT_ELSE
))
442 && last_edge
->dest
!= EXIT_BLOCK_PTR
443 && GET_CODE (last_edge
->dest
->head
) == CODE_LABEL
444 && ! (GET_CODE (db
->end
) == JUMP_INSN
))
447 fprintf (rtl_dump_file
,
448 " else jump from block %d to block %d\n",
449 db
->index
, last_edge
->dest
->index
);
451 REORDER_BLOCK_ADD_JUMP (db
) = last_edge
->dest
;
455 /* This block's successor has already been reordered. This can happen
456 when we reorder a chain starting at a then or else. */
457 for (last_edge
= db
->succ
;
458 last_edge
&& ! (last_edge
->flags
& EDGE_FALLTHRU
);
459 last_edge
= last_edge
->succ_next
)
463 && last_edge
->dest
!= EXIT_BLOCK_PTR
464 && (REORDER_BLOCK_FLAGS (last_edge
->dest
)
465 & REORDER_BLOCK_VISITED
))
468 fprintf (rtl_dump_file
,
469 " end of chain jump from block %d to block %d\n",
470 db
->index
, last_edge
->dest
->index
);
472 REORDER_BLOCK_ADD_JUMP (db
) = last_edge
->dest
;
475 dbh_insn
= REORDER_BLOCK_EFF_HEAD (db
);
476 cebe_insn
= REORDER_BLOCK_EFF_END (ceb
);
477 dbe_insn
= REORDER_BLOCK_EFF_END (db
);
479 /* Leave behind any lexical block markers. */
480 if (debug_info_level
> DINFO_LEVEL_TERSE
481 && ceb
->index
+ 1 < db
->index
)
483 rtx insn
, last_insn
= get_last_insn ();
484 insn
= NEXT_INSN (ceb
->end
);
486 insn
= REORDER_BLOCK_OLD_END (ceb
);
488 if (NEXT_INSN (cebe_insn
) == 0)
489 set_last_insn (cebe_insn
);
490 for (; insn
&& insn
!= db
->head
/*dbh_insn*/;
491 insn
= NEXT_INSN (insn
))
493 if (GET_CODE (insn
) == NOTE
494 && (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_BEG
))
496 cebe_insn
= emit_note_after (NOTE_INSN_BLOCK_BEG
, cebe_insn
);
499 if (GET_CODE (insn
) == NOTE
500 && (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_END
))
502 cebe_insn
= emit_note_after (NOTE_INSN_BLOCK_END
, cebe_insn
);
506 set_last_insn (last_insn
);
509 /* Rechain predicted block. */
510 NEXT_INSN (cebe_insn
) = dbh_insn
;
511 PREV_INSN (dbh_insn
) = cebe_insn
;
513 REORDER_BLOCK_OLD_END (db
) = NEXT_INSN (dbe_insn
);
514 if (db
->index
!= n_basic_blocks
- 1)
515 NEXT_INSN (dbe_insn
) = 0;
521 /* Reorder blocks starting at block BB. */
524 make_reorder_chain (bb
)
528 basic_block visited_edge
= NULL
;
532 if (bb
== EXIT_BLOCK_PTR
)
535 /* Find the most probable block. */
538 if (GET_CODE (block_end
) == JUMP_INSN
&& condjump_p (block_end
))
540 rtx note
= find_reg_note (block_end
, REG_BR_PROB
, 0);
543 probability
= INTVAL (XEXP (note
, 0));
547 if (probability
>= REG_BR_PROB_BASE
/ 2)
548 e
= bb
->succ
->succ_next
;
551 /* Add chosen successor to chain and recurse on it. */
552 if (e
&& e
->dest
!= EXIT_BLOCK_PTR
554 && (! (REORDER_BLOCK_FLAGS (e
->dest
) & REORDER_BLOCK_VISITED
)
555 || (REORDER_BLOCK_FLAGS (e
->dest
) == REORDER_BLOCK_HEAD
)))
557 if (! (REORDER_BLOCK_FLAGS (bb
) & REORDER_BLOCK_VISITED
))
559 REORDER_BLOCK_FLAGS (bb
) |= REORDER_BLOCK_HEAD
;
560 REORDER_BLOCK_INDEX (bb
) = reorder_index
++;
561 REORDER_BLOCK_FLAGS (bb
) |= REORDER_BLOCK_VISITED
;
564 if (REORDER_BLOCK_FLAGS (e
->dest
) & REORDER_BLOCK_VISITED
)
565 REORDER_BLOCK_FLAGS (e
->dest
) &= ~REORDER_BLOCK_HEAD
;
567 REORDER_BLOCK_SUCC (bb
) = e
;
569 visited_edge
= e
->dest
;
571 reorder_last_visited
= chain_reorder_blocks (e
, bb
);
574 && ! (REORDER_BLOCK_FLAGS (e
->dest
)
575 & REORDER_BLOCK_VISITED
))
576 make_reorder_chain (e
->dest
);
580 if (! (REORDER_BLOCK_FLAGS (bb
) & REORDER_BLOCK_VISITED
))
582 REORDER_BLOCK_INDEX (bb
) = reorder_index
++;
583 REORDER_BLOCK_FLAGS (bb
) |= REORDER_BLOCK_VISITED
;
587 /* Recurse on the successors. */
588 for (e
= bb
->succ
; e
; e
= e
->succ_next
)
590 if (e
->dest
&& e
->dest
== EXIT_BLOCK_PTR
)
595 && e
->dest
!= visited_edge
596 && ! (REORDER_BLOCK_FLAGS (e
->dest
)
597 & REORDER_BLOCK_VISITED
))
600 = chain_reorder_blocks (e
, reorder_last_visited
);
601 make_reorder_chain (e
->dest
);
607 /* Fixup jumps and labels after reordering basic blocks. */
610 fixup_reorder_chain ()
614 int orig_num_blocks
= n_basic_blocks
;
616 /* Set the new last insn. */
620 for (j
= 0; j
< n_basic_blocks
; j
++)
622 int val
= REORDER_BLOCK_INDEX (BASIC_BLOCK (j
));
629 insn
= REORDER_BLOCK_EFF_END (BASIC_BLOCK (max_index
));
630 NEXT_INSN (insn
) = NULL_RTX
;
631 set_last_insn (insn
);
634 /* Add jumps and labels to fixup blocks. */
635 for (i
= 0; i
< orig_num_blocks
; i
++)
638 basic_block bbi
= BASIC_BLOCK (i
);
639 if (REORDER_BLOCK_ADD_JUMP (bbi
))
641 rtx label_insn
, jump_insn
, barrier_insn
;
643 if (GET_CODE (REORDER_BLOCK_ADD_JUMP (bbi
)->head
) == CODE_LABEL
)
644 label_insn
= REORDER_BLOCK_ADD_JUMP (bbi
)->head
;
647 rtx new_label
= gen_label_rtx ();
648 label_insn
= emit_label_before (new_label
,
649 REORDER_BLOCK_ADD_JUMP (bbi
)->head
);
650 REORDER_BLOCK_ADD_JUMP (bbi
)->head
= label_insn
;
653 if (GET_CODE (bbi
->end
) != JUMP_INSN
)
655 jump_insn
= emit_jump_insn_after (gen_jump (label_insn
),
657 bbi
->end
= jump_insn
;
662 jump_insn
= emit_jump_insn_after (gen_jump (label_insn
),
663 REORDER_BLOCK_EFF_END (bbi
));
667 JUMP_LABEL (jump_insn
) = label_insn
;
668 ++LABEL_NUSES (label_insn
);
669 barrier_insn
= emit_barrier_after (jump_insn
);
671 /* Add block for jump. Typically this is when a then is not
672 predicted and we are jumping to the moved then block. */
677 VARRAY_GROW (basic_block_info
, ++n_basic_blocks
);
678 create_basic_block (n_basic_blocks
- 1, jump_insn
,
680 nb
= BASIC_BLOCK (n_basic_blocks
- 1);
681 nb
->global_live_at_start
682 = OBSTACK_ALLOC_REG_SET (function_obstack
);
683 nb
->global_live_at_end
684 = OBSTACK_ALLOC_REG_SET (function_obstack
);
686 COPY_REG_SET (nb
->global_live_at_start
,
687 bbi
->global_live_at_start
);
688 COPY_REG_SET (nb
->global_live_at_end
,
689 bbi
->global_live_at_start
);
690 BASIC_BLOCK (nb
->index
)->local_set
= 0;
692 nb
->aux
= xcalloc (1, sizeof (struct reorder_block_def
));
693 REORDER_BLOCK_INDEX (BASIC_BLOCK (n_basic_blocks
- 1))
694 = REORDER_BLOCK_INDEX (bbi
) + 1;
695 /* Relink to new block. */
696 nb
->succ
= bbi
->succ
;
699 make_edge (NULL
, bbi
, nb
, 0);
701 = bbi
->succ
->succ_next
->succ_next
;
702 nb
->succ
->succ_next
= 0;
703 /* Fix reorder block index to reflect new block. */
704 for (j
= 0; j
< n_basic_blocks
- 1; j
++)
706 basic_block bbj
= BASIC_BLOCK (j
);
707 if (REORDER_BLOCK_INDEX (bbj
)
708 >= REORDER_BLOCK_INDEX (bbi
) + 1)
709 REORDER_BLOCK_INDEX (bbj
)++;
717 /* Perform sanity checks on the insn chain.
718 1. Check that next/prev pointers are consistent in both the forward and
720 2. Count insns in chain, going both directions, and check if equal.
721 3. Check that get_last_insn () returns the actual end of chain. */
722 #ifdef ENABLE_CHECKING
734 for (x
= get_insns (); x
; x
= NEXT_INSN (x
))
736 if (PREV_INSN (x
) != prevx
)
738 fprintf (stderr
, "Forward traversal: insn chain corrupt.\n");
739 fprintf (stderr
, "previous insn:\n");
741 fprintf (stderr
, "current insn:\n");
749 if (prevx
!= get_last_insn ())
751 fprintf (stderr
, "last_insn corrupt.\n");
757 for (x
= get_last_insn (); x
; x
= PREV_INSN (x
))
759 if (NEXT_INSN (x
) != nextx
)
761 fprintf (stderr
, "Reverse traversal: insn chain corrupt.\n");
762 fprintf (stderr
, "current insn:\n");
764 fprintf (stderr
, "next insn:\n");
772 if (insn_cnt1
!= insn_cnt2
)
774 fprintf (stderr
, "insn_cnt1 (%d) not equal to insn_cnt2 (%d).\n",
775 insn_cnt1
, insn_cnt2
);
781 /* Reorder basic blocks. */
784 reorder_basic_blocks ()
787 struct loops loops_info
;
790 if (profile_arc_flag
)
793 if (n_basic_blocks
<= 1)
796 /* Exception edges are not currently handled. */
797 for (i
= 0; i
< n_basic_blocks
; i
++)
801 for (e
= BASIC_BLOCK (i
)->succ
; e
&& ! (e
->flags
& EDGE_EH
);
805 if (e
&& (e
->flags
& EDGE_EH
))
811 /* Find natural loops using the CFG. */
812 num_loops
= flow_loops_find (&loops_info
);
814 /* Dump loop information. */
815 flow_loops_dump (&loops_info
, rtl_dump_file
, 0);
817 /* Estimate using heuristics if no profiling info is available. */
818 if (! flag_branch_probabilities
)
819 estimate_probability (&loops_info
);
821 reorder_last_visited
= BASIC_BLOCK (0);
823 for (i
= 0; i
< n_basic_blocks
; i
++)
825 basic_block bbi
= BASIC_BLOCK (i
);
826 bbi
->aux
= xcalloc (1, sizeof (struct reorder_block_def
));
827 *((struct reorder_block_def
*)bbi
->aux
) = rbd_init
;
828 REORDER_BLOCK_EFF_END (bbi
)
829 = skip_insns_between_block (bbi
, REORDER_SKIP_AFTER
);
831 REORDER_BLOCK_EFF_HEAD (bbi
) = get_insns ();
834 rtx prev_eff_end
= REORDER_BLOCK_EFF_END (BASIC_BLOCK (i
- 1));
835 REORDER_BLOCK_EFF_HEAD (bbi
) = NEXT_INSN (prev_eff_end
);
839 make_reorder_chain (BASIC_BLOCK (0));
841 fixup_reorder_chain ();
843 #ifdef ENABLE_CHECKING
844 verify_insn_chain ();
847 /* Put basic_block_info in new order. */
848 for (i
= 0; i
< n_basic_blocks
- 1; i
++)
850 for (j
= i
; i
!= REORDER_BLOCK_INDEX (BASIC_BLOCK (j
)); j
++)
853 if (REORDER_BLOCK_INDEX (BASIC_BLOCK (j
)) == i
858 int rbi
= REORDER_BLOCK_INDEX (BASIC_BLOCK (j
));
860 temprbi
= BASIC_BLOCK (rbi
)->index
;
861 BASIC_BLOCK (rbi
)->index
= BASIC_BLOCK (j
)->index
;
862 BASIC_BLOCK (j
)->index
= temprbi
;
863 tempbb
= BASIC_BLOCK (rbi
);
864 BASIC_BLOCK (rbi
) = BASIC_BLOCK (j
);
865 BASIC_BLOCK (j
) = tempbb
;
869 #ifdef ENABLE_CHECKING
873 for (i
= 0; i
< n_basic_blocks
; i
++)
874 free (BASIC_BLOCK (i
)->aux
);
876 /* Free loop information. */
877 flow_loops_free (&loops_info
);