* basic-block.h (struct edge_stack): Remove.
[official-gcc.git] / gcc / bt-load.c
blob47d0af6078ef8d4880b1ea9c0b929a10669efd6c
1 /* Perform branch target register load optimizations.
2 Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "bitmap.h"
26 #include "sbitmap.h"
27 #include "rtl.h"
28 #include "hard-reg-set.h"
29 #include "basic-block.h"
30 #include "regs.h"
31 #include "obstack.h"
32 #include "fibheap.h"
33 #include "output.h"
34 #include "target.h"
35 #include "expr.h"
36 #include "flags.h"
37 #include "insn-attr.h"
38 #include "function.h"
39 #include "except.h"
40 #include "tm_p.h"
42 /* Target register optimizations - these are performed after reload. */
44 typedef struct btr_def_group_s
46 struct btr_def_group_s *next;
47 rtx src;
48 struct btr_def_s *members;
49 } *btr_def_group;
51 typedef struct btr_user_s
53 struct btr_user_s *next;
54 basic_block bb;
55 int luid;
56 rtx insn;
57 /* If INSN has a single use of a single branch register, then
58 USE points to it within INSN. If there is more than
59 one branch register use, or the use is in some way ambiguous,
60 then USE is NULL. */
61 rtx use;
62 int n_reaching_defs;
63 int first_reaching_def;
64 char other_use_this_block;
65 } *btr_user;
67 /* btr_def structs appear on three lists:
68 1. A list of all btr_def structures (head is
69 ALL_BTR_DEFS, linked by the NEXT field).
70 2. A list of branch reg definitions per basic block (head is
71 BB_BTR_DEFS[i], linked by the NEXT_THIS_BB field).
72 3. A list of all branch reg definitions belonging to the same
73 group (head is in a BTR_DEF_GROUP struct, linked by
74 NEXT_THIS_GROUP field). */
76 typedef struct btr_def_s
78 struct btr_def_s *next_this_bb;
79 struct btr_def_s *next_this_group;
80 basic_block bb;
81 int luid;
82 rtx insn;
83 int btr;
84 int cost;
85 /* For a branch register setting insn that has a constant
86 source (i.e. a label), group links together all the
87 insns with the same source. For other branch register
88 setting insns, group is NULL. */
89 btr_def_group group;
90 btr_user uses;
91 /* If this def has a reaching use which is not a simple use
92 in a branch instruction, then has_ambiguous_use will be true,
93 and we will not attempt to migrate this definition. */
94 char has_ambiguous_use;
95 /* live_range is an approximation to the true live range for this
96 def/use web, because it records the set of blocks that contain
97 the live range. There could be other live ranges for the same
98 branch register in that set of blocks, either in the block
99 containing the def (before the def), or in a block containing
100 a use (after the use). If there are such other live ranges, then
101 other_btr_uses_before_def or other_btr_uses_after_use must be set true
102 as appropriate. */
103 char other_btr_uses_before_def;
104 char other_btr_uses_after_use;
105 bitmap live_range;
106 } *btr_def;
108 static int issue_rate;
110 static int basic_block_freq (basic_block);
111 static int insn_sets_btr_p (rtx, int, int *);
112 static rtx *find_btr_use (rtx);
113 static int btr_referenced_p (rtx, rtx *);
114 static int find_btr_reference (rtx *, void *);
115 static void find_btr_def_group (btr_def_group *, btr_def);
116 static btr_def add_btr_def (fibheap_t, basic_block, int, rtx,
117 unsigned int, int, btr_def_group *);
118 static btr_user new_btr_user (basic_block, int, rtx);
119 static void dump_hard_reg_set (HARD_REG_SET);
120 static void dump_btrs_live (int);
121 static void note_other_use_this_block (unsigned int, btr_user);
122 static void compute_defs_uses_and_gen (fibheap_t, btr_def *,btr_user *,
123 sbitmap *, sbitmap *, HARD_REG_SET *);
124 static void compute_kill (sbitmap *, sbitmap *, HARD_REG_SET *);
125 static void compute_out (sbitmap *bb_out, sbitmap *, sbitmap *, int);
126 static void link_btr_uses (btr_def *, btr_user *, sbitmap *, sbitmap *, int);
127 static void build_btr_def_use_webs (fibheap_t);
128 static int block_at_edge_of_live_range_p (int, btr_def);
129 static void clear_btr_from_live_range (btr_def def);
130 static void add_btr_to_live_range (btr_def);
131 static void augment_live_range (bitmap, HARD_REG_SET *, basic_block,
132 basic_block);
133 static int choose_btr (HARD_REG_SET);
134 static void combine_btr_defs (btr_def, HARD_REG_SET *);
135 static void btr_def_live_range (btr_def, HARD_REG_SET *);
136 static void move_btr_def (basic_block, int, btr_def, bitmap, HARD_REG_SET *);
137 static int migrate_btr_def (btr_def, int);
138 static void migrate_btr_defs (enum reg_class, int);
139 static int can_move_up (basic_block, rtx, int);
140 static void note_btr_set (rtx, rtx, void *);
142 /* The following code performs code motion of target load instructions
143 (instructions that set branch target registers), to move them
144 forward away from the branch instructions and out of loops (or,
145 more generally, from a more frequently executed place to a less
146 frequently executed place).
147 Moving target load instructions further in front of the branch
148 instruction that uses the target register value means that the hardware
149 has a better chance of preloading the instructions at the branch
150 target by the time the branch is reached. This avoids bubbles
151 when a taken branch needs to flush out the pipeline.
152 Moving target load instructions out of loops means they are executed
153 less frequently. */
155 /* An obstack to hold the def-use web data structures built up for
156 migrating branch target load instructions. */
157 static struct obstack migrate_btrl_obstack;
159 /* Array indexed by basic block number, giving the set of registers
160 live in that block. */
161 static HARD_REG_SET *btrs_live;
163 /* Array indexed by basic block number, giving the set of registers live at
164 the end of that block, including any uses by a final jump insn, if any. */
165 static HARD_REG_SET *btrs_live_at_end;
167 /* Set of all target registers that we are willing to allocate. */
168 static HARD_REG_SET all_btrs;
170 /* Provide lower and upper bounds for target register numbers, so that
171 we don't need to search through all the hard registers all the time. */
172 static int first_btr, last_btr;
176 /* Return an estimate of the frequency of execution of block bb. */
177 static int
178 basic_block_freq (basic_block bb)
180 return bb->frequency;
183 static rtx *btr_reference_found;
185 /* A subroutine of btr_referenced_p, called through for_each_rtx.
186 PREG is a pointer to an rtx that is to be excluded from the
187 traversal. If we find a reference to a target register anywhere
188 else, return 1, and put a pointer to it into btr_reference_found. */
189 static int
190 find_btr_reference (rtx *px, void *preg)
192 rtx x;
193 int regno, i;
195 if (px == preg)
196 return -1;
197 x = *px;
198 if (!REG_P (x))
199 return 0;
200 regno = REGNO (x);
201 for (i = hard_regno_nregs[regno][GET_MODE (x)] - 1; i >= 0; i--)
202 if (TEST_HARD_REG_BIT (all_btrs, regno+i))
204 btr_reference_found = px;
205 return 1;
207 return -1;
210 /* Return nonzero if X references (sets or reads) any branch target register.
211 If EXCLUDEP is set, disregard any references within the rtx pointed to
212 by it. If returning nonzero, also set btr_reference_found as above. */
213 static int
214 btr_referenced_p (rtx x, rtx *excludep)
216 return for_each_rtx (&x, find_btr_reference, excludep);
219 /* Return true if insn is an instruction that sets a target register.
220 if CHECK_CONST is true, only return true if the source is constant.
221 If such a set is found and REGNO is nonzero, assign the register number
222 of the destination register to *REGNO. */
223 static int
224 insn_sets_btr_p (rtx insn, int check_const, int *regno)
226 rtx set;
228 if (NONJUMP_INSN_P (insn)
229 && (set = single_set (insn)))
231 rtx dest = SET_DEST (set);
232 rtx src = SET_SRC (set);
234 if (GET_CODE (dest) == SUBREG)
235 dest = XEXP (dest, 0);
237 if (REG_P (dest)
238 && TEST_HARD_REG_BIT (all_btrs, REGNO (dest)))
240 gcc_assert (!btr_referenced_p (src, NULL));
242 if (!check_const || CONSTANT_P (src))
244 if (regno)
245 *regno = REGNO (dest);
246 return 1;
250 return 0;
253 /* Find and return a use of a target register within an instruction INSN. */
254 static rtx *
255 find_btr_use (rtx insn)
257 return btr_referenced_p (insn, NULL) ? btr_reference_found : NULL;
260 /* Find the group that the target register definition DEF belongs
261 to in the list starting with *ALL_BTR_DEF_GROUPS. If no such
262 group exists, create one. Add def to the group. */
263 static void
264 find_btr_def_group (btr_def_group *all_btr_def_groups, btr_def def)
266 if (insn_sets_btr_p (def->insn, 1, NULL))
268 btr_def_group this_group;
269 rtx def_src = SET_SRC (single_set (def->insn));
271 /* ?? This linear search is an efficiency concern, particularly
272 as the search will almost always fail to find a match. */
273 for (this_group = *all_btr_def_groups;
274 this_group != NULL;
275 this_group = this_group->next)
276 if (rtx_equal_p (def_src, this_group->src))
277 break;
279 if (!this_group)
281 this_group = obstack_alloc (&migrate_btrl_obstack,
282 sizeof (struct btr_def_group_s));
283 this_group->src = def_src;
284 this_group->members = NULL;
285 this_group->next = *all_btr_def_groups;
286 *all_btr_def_groups = this_group;
288 def->group = this_group;
289 def->next_this_group = this_group->members;
290 this_group->members = def;
292 else
293 def->group = NULL;
296 /* Create a new target register definition structure, for a definition in
297 block BB, instruction INSN, and insert it into ALL_BTR_DEFS. Return
298 the new definition. */
299 static btr_def
300 add_btr_def (fibheap_t all_btr_defs, basic_block bb, int insn_luid, rtx insn,
301 unsigned int dest_reg, int other_btr_uses_before_def,
302 btr_def_group *all_btr_def_groups)
304 btr_def this
305 = obstack_alloc (&migrate_btrl_obstack, sizeof (struct btr_def_s));
306 this->bb = bb;
307 this->luid = insn_luid;
308 this->insn = insn;
309 this->btr = dest_reg;
310 this->cost = basic_block_freq (bb);
311 this->has_ambiguous_use = 0;
312 this->other_btr_uses_before_def = other_btr_uses_before_def;
313 this->other_btr_uses_after_use = 0;
314 this->next_this_bb = NULL;
315 this->next_this_group = NULL;
316 this->uses = NULL;
317 this->live_range = NULL;
318 find_btr_def_group (all_btr_def_groups, this);
320 fibheap_insert (all_btr_defs, -this->cost, this);
322 if (dump_file)
323 fprintf (dump_file,
324 "Found target reg definition: sets %u { bb %d, insn %d }%s priority %d\n",
325 dest_reg, bb->index, INSN_UID (insn), (this->group ? "" : ":not const"),
326 this->cost);
328 return this;
331 /* Create a new target register user structure, for a use in block BB,
332 instruction INSN. Return the new user. */
333 static btr_user
334 new_btr_user (basic_block bb, int insn_luid, rtx insn)
336 /* This instruction reads target registers. We need
337 to decide whether we can replace all target register
338 uses easily.
340 rtx *usep = find_btr_use (PATTERN (insn));
341 rtx use;
342 btr_user user = NULL;
344 if (usep)
346 int unambiguous_single_use;
348 /* We want to ensure that USE is the only use of a target
349 register in INSN, so that we know that to rewrite INSN to use
350 a different target register, all we have to do is replace USE. */
351 unambiguous_single_use = !btr_referenced_p (PATTERN (insn), usep);
352 if (!unambiguous_single_use)
353 usep = NULL;
355 use = usep ? *usep : NULL_RTX;
356 user = obstack_alloc (&migrate_btrl_obstack, sizeof (struct btr_user_s));
357 user->bb = bb;
358 user->luid = insn_luid;
359 user->insn = insn;
360 user->use = use;
361 user->other_use_this_block = 0;
362 user->next = NULL;
363 user->n_reaching_defs = 0;
364 user->first_reaching_def = -1;
366 if (dump_file)
368 fprintf (dump_file, "Uses target reg: { bb %d, insn %d }",
369 bb->index, INSN_UID (insn));
371 if (user->use)
372 fprintf (dump_file, ": unambiguous use of reg %d\n",
373 REGNO (user->use));
376 return user;
379 /* Write the contents of S to the dump file. */
380 static void
381 dump_hard_reg_set (HARD_REG_SET s)
383 int reg;
384 for (reg = 0; reg < FIRST_PSEUDO_REGISTER; reg++)
385 if (TEST_HARD_REG_BIT (s, reg))
386 fprintf (dump_file, " %d", reg);
389 /* Write the set of target regs live in block BB to the dump file. */
390 static void
391 dump_btrs_live (int bb)
393 fprintf (dump_file, "BB%d live:", bb);
394 dump_hard_reg_set (btrs_live[bb]);
395 fprintf (dump_file, "\n");
398 /* REGNO is the number of a branch target register that is being used or
399 set. USERS_THIS_BB is a list of preceding branch target register users;
400 If any of them use the same register, set their other_use_this_block
401 flag. */
402 static void
403 note_other_use_this_block (unsigned int regno, btr_user users_this_bb)
405 btr_user user;
407 for (user = users_this_bb; user != NULL; user = user->next)
408 if (user->use && REGNO (user->use) == regno)
409 user->other_use_this_block = 1;
412 typedef struct {
413 btr_user users_this_bb;
414 HARD_REG_SET btrs_written_in_block;
415 HARD_REG_SET btrs_live_in_block;
416 sbitmap bb_gen;
417 sbitmap *btr_defset;
418 } defs_uses_info;
420 /* Called via note_stores or directly to register stores into /
421 clobbers of a branch target register DEST that are not recognized as
422 straightforward definitions. DATA points to information about the
423 current basic block that needs updating. */
424 static void
425 note_btr_set (rtx dest, rtx set ATTRIBUTE_UNUSED, void *data)
427 defs_uses_info *info = data;
428 int regno, end_regno;
430 if (!REG_P (dest))
431 return;
432 regno = REGNO (dest);
433 end_regno = regno + hard_regno_nregs[regno][GET_MODE (dest)];
434 for (; regno < end_regno; regno++)
435 if (TEST_HARD_REG_BIT (all_btrs, regno))
437 note_other_use_this_block (regno, info->users_this_bb);
438 SET_HARD_REG_BIT (info->btrs_written_in_block, regno);
439 SET_HARD_REG_BIT (info->btrs_live_in_block, regno);
440 sbitmap_difference (info->bb_gen, info->bb_gen,
441 info->btr_defset[regno - first_btr]);
445 static void
446 compute_defs_uses_and_gen (fibheap_t all_btr_defs, btr_def *def_array,
447 btr_user *use_array, sbitmap *btr_defset,
448 sbitmap *bb_gen, HARD_REG_SET *btrs_written)
450 /* Scan the code building up the set of all defs and all uses.
451 For each target register, build the set of defs of that register.
452 For each block, calculate the set of target registers
453 written in that block.
454 Also calculate the set of btrs ever live in that block.
456 int i;
457 int insn_luid = 0;
458 btr_def_group all_btr_def_groups = NULL;
459 defs_uses_info info;
461 sbitmap_vector_zero (bb_gen, n_basic_blocks);
462 for (i = 0; i < n_basic_blocks; i++)
464 basic_block bb = BASIC_BLOCK (i);
465 int reg;
466 btr_def defs_this_bb = NULL;
467 rtx insn;
468 rtx last;
469 int can_throw = 0;
471 info.users_this_bb = NULL;
472 info.bb_gen = bb_gen[i];
473 info.btr_defset = btr_defset;
475 CLEAR_HARD_REG_SET (info.btrs_live_in_block);
476 CLEAR_HARD_REG_SET (info.btrs_written_in_block);
477 for (reg = first_btr; reg <= last_btr; reg++)
478 if (TEST_HARD_REG_BIT (all_btrs, reg)
479 && REGNO_REG_SET_P (bb->global_live_at_start, reg))
480 SET_HARD_REG_BIT (info.btrs_live_in_block, reg);
482 for (insn = BB_HEAD (bb), last = NEXT_INSN (BB_END (bb));
483 insn != last;
484 insn = NEXT_INSN (insn), insn_luid++)
486 if (INSN_P (insn))
488 int regno;
489 int insn_uid = INSN_UID (insn);
491 if (insn_sets_btr_p (insn, 0, &regno))
493 btr_def def = add_btr_def (
494 all_btr_defs, bb, insn_luid, insn, regno,
495 TEST_HARD_REG_BIT (info.btrs_live_in_block, regno),
496 &all_btr_def_groups);
498 def_array[insn_uid] = def;
499 SET_HARD_REG_BIT (info.btrs_written_in_block, regno);
500 SET_HARD_REG_BIT (info.btrs_live_in_block, regno);
501 sbitmap_difference (bb_gen[i], bb_gen[i],
502 btr_defset[regno - first_btr]);
503 SET_BIT (bb_gen[i], insn_uid);
504 def->next_this_bb = defs_this_bb;
505 defs_this_bb = def;
506 SET_BIT (btr_defset[regno - first_btr], insn_uid);
507 note_other_use_this_block (regno, info.users_this_bb);
509 else
511 if (btr_referenced_p (PATTERN (insn), NULL))
513 btr_user user = new_btr_user (bb, insn_luid, insn);
515 use_array[insn_uid] = user;
516 if (user->use)
517 SET_HARD_REG_BIT (info.btrs_live_in_block,
518 REGNO (user->use));
519 else
521 int reg;
522 for (reg = first_btr; reg <= last_btr; reg++)
523 if (TEST_HARD_REG_BIT (all_btrs, reg)
524 && refers_to_regno_p (reg, reg + 1, user->insn,
525 NULL))
527 note_other_use_this_block (reg,
528 info.users_this_bb);
529 SET_HARD_REG_BIT (info.btrs_live_in_block, reg);
531 note_stores (PATTERN (insn), note_btr_set, &info);
533 user->next = info.users_this_bb;
534 info.users_this_bb = user;
536 if (CALL_P (insn))
538 HARD_REG_SET *clobbered = &call_used_reg_set;
539 HARD_REG_SET call_saved;
540 rtx pat = PATTERN (insn);
541 int i;
543 /* Check for sibcall. */
544 if (GET_CODE (pat) == PARALLEL)
545 for (i = XVECLEN (pat, 0) - 1; i >= 0; i--)
546 if (GET_CODE (XVECEXP (pat, 0, i)) == RETURN)
548 COMPL_HARD_REG_SET (call_saved,
549 call_used_reg_set);
550 clobbered = &call_saved;
553 for (regno = first_btr; regno <= last_btr; regno++)
554 if (TEST_HARD_REG_BIT (*clobbered, regno))
555 note_btr_set (regno_reg_rtx[regno], NULL_RTX, &info);
561 COPY_HARD_REG_SET (btrs_live[i], info.btrs_live_in_block);
562 COPY_HARD_REG_SET (btrs_written[i], info.btrs_written_in_block);
564 REG_SET_TO_HARD_REG_SET (btrs_live_at_end[i], bb->global_live_at_end);
565 /* If this block ends in a jump insn, add any uses or even clobbers
566 of branch target registers that it might have. */
567 for (insn = BB_END (bb); insn != BB_HEAD (bb) && ! INSN_P (insn); )
568 insn = PREV_INSN (insn);
569 /* ??? for the fall-through edge, it would make sense to insert the
570 btr set on the edge, but that would require to split the block
571 early on so that we can distinguish between dominance from the fall
572 through edge - which can use the call-clobbered registers - from
573 dominance by the throw edge. */
574 if (can_throw_internal (insn))
576 HARD_REG_SET tmp;
578 COPY_HARD_REG_SET (tmp, call_used_reg_set);
579 AND_HARD_REG_SET (tmp, all_btrs);
580 IOR_HARD_REG_SET (btrs_live_at_end[i], tmp);
581 can_throw = 1;
583 if (can_throw || JUMP_P (insn))
585 int regno;
587 for (regno = first_btr; regno <= last_btr; regno++)
588 if (refers_to_regno_p (regno, regno+1, insn, NULL))
589 SET_HARD_REG_BIT (btrs_live_at_end[i], regno);
592 if (dump_file)
593 dump_btrs_live(i);
597 static void
598 compute_kill (sbitmap *bb_kill, sbitmap *btr_defset,
599 HARD_REG_SET *btrs_written)
601 int i;
602 int regno;
604 /* For each basic block, form the set BB_KILL - the set
605 of definitions that the block kills. */
606 sbitmap_vector_zero (bb_kill, n_basic_blocks);
607 for (i = 0; i < n_basic_blocks; i++)
609 for (regno = first_btr; regno <= last_btr; regno++)
610 if (TEST_HARD_REG_BIT (all_btrs, regno)
611 && TEST_HARD_REG_BIT (btrs_written[i], regno))
612 sbitmap_a_or_b (bb_kill[i], bb_kill[i],
613 btr_defset[regno - first_btr]);
617 static void
618 compute_out (sbitmap *bb_out, sbitmap *bb_gen, sbitmap *bb_kill, int max_uid)
620 /* Perform iterative dataflow:
621 Initially, for all blocks, BB_OUT = BB_GEN.
622 For each block,
623 BB_IN = union over predecessors of BB_OUT(pred)
624 BB_OUT = (BB_IN - BB_KILL) + BB_GEN
625 Iterate until the bb_out sets stop growing. */
626 int i;
627 int changed;
628 sbitmap bb_in = sbitmap_alloc (max_uid);
630 for (i = 0; i < n_basic_blocks; i++)
631 sbitmap_copy (bb_out[i], bb_gen[i]);
633 changed = 1;
634 while (changed)
636 changed = 0;
637 for (i = 0; i < n_basic_blocks; i++)
639 sbitmap_union_of_preds (bb_in, bb_out, i);
640 changed |= sbitmap_union_of_diff_cg (bb_out[i], bb_gen[i],
641 bb_in, bb_kill[i]);
644 sbitmap_free (bb_in);
647 static void
648 link_btr_uses (btr_def *def_array, btr_user *use_array, sbitmap *bb_out,
649 sbitmap *btr_defset, int max_uid)
651 int i;
652 sbitmap reaching_defs = sbitmap_alloc (max_uid);
654 /* Link uses to the uses lists of all of their reaching defs.
655 Count up the number of reaching defs of each use. */
656 for (i = 0; i < n_basic_blocks; i++)
658 basic_block bb = BASIC_BLOCK (i);
659 rtx insn;
660 rtx last;
662 sbitmap_union_of_preds (reaching_defs, bb_out, i);
663 for (insn = BB_HEAD (bb), last = NEXT_INSN (BB_END (bb));
664 insn != last;
665 insn = NEXT_INSN (insn))
667 if (INSN_P (insn))
669 int insn_uid = INSN_UID (insn);
671 btr_def def = def_array[insn_uid];
672 btr_user user = use_array[insn_uid];
673 if (def != NULL)
675 /* Remove all reaching defs of regno except
676 for this one. */
677 sbitmap_difference (reaching_defs, reaching_defs,
678 btr_defset[def->btr - first_btr]);
679 SET_BIT(reaching_defs, insn_uid);
682 if (user != NULL)
684 /* Find all the reaching defs for this use. */
685 sbitmap reaching_defs_of_reg = sbitmap_alloc(max_uid);
686 int uid;
688 if (user->use)
689 sbitmap_a_and_b (
690 reaching_defs_of_reg,
691 reaching_defs,
692 btr_defset[REGNO (user->use) - first_btr]);
693 else
695 int reg;
697 sbitmap_zero (reaching_defs_of_reg);
698 for (reg = first_btr; reg <= last_btr; reg++)
699 if (TEST_HARD_REG_BIT (all_btrs, reg)
700 && refers_to_regno_p (reg, reg + 1, user->insn,
701 NULL))
702 sbitmap_a_or_b_and_c (reaching_defs_of_reg,
703 reaching_defs_of_reg,
704 reaching_defs,
705 btr_defset[reg - first_btr]);
707 EXECUTE_IF_SET_IN_SBITMAP (reaching_defs_of_reg, 0, uid,
709 btr_def def = def_array[uid];
711 /* We now know that def reaches user. */
713 if (dump_file)
714 fprintf (dump_file,
715 "Def in insn %d reaches use in insn %d\n",
716 uid, insn_uid);
718 user->n_reaching_defs++;
719 if (!user->use)
720 def->has_ambiguous_use = 1;
721 if (user->first_reaching_def != -1)
722 { /* There is more than one reaching def. This is
723 a rare case, so just give up on this def/use
724 web when it occurs. */
725 def->has_ambiguous_use = 1;
726 def_array[user->first_reaching_def]
727 ->has_ambiguous_use = 1;
728 if (dump_file)
729 fprintf (dump_file,
730 "(use %d has multiple reaching defs)\n",
731 insn_uid);
733 else
734 user->first_reaching_def = uid;
735 if (user->other_use_this_block)
736 def->other_btr_uses_after_use = 1;
737 user->next = def->uses;
738 def->uses = user;
740 sbitmap_free (reaching_defs_of_reg);
743 if (CALL_P (insn))
745 int regno;
747 for (regno = first_btr; regno <= last_btr; regno++)
748 if (TEST_HARD_REG_BIT (all_btrs, regno)
749 && TEST_HARD_REG_BIT (call_used_reg_set, regno))
750 sbitmap_difference (reaching_defs, reaching_defs,
751 btr_defset[regno - first_btr]);
756 sbitmap_free (reaching_defs);
759 static void
760 build_btr_def_use_webs (fibheap_t all_btr_defs)
762 const int max_uid = get_max_uid ();
763 btr_def *def_array = xcalloc (max_uid, sizeof (btr_def));
764 btr_user *use_array = xcalloc (max_uid, sizeof (btr_user));
765 sbitmap *btr_defset = sbitmap_vector_alloc (
766 (last_btr - first_btr) + 1, max_uid);
767 sbitmap *bb_gen = sbitmap_vector_alloc (n_basic_blocks, max_uid);
768 HARD_REG_SET *btrs_written = xcalloc (n_basic_blocks, sizeof (HARD_REG_SET));
769 sbitmap *bb_kill;
770 sbitmap *bb_out;
772 sbitmap_vector_zero (btr_defset, (last_btr - first_btr) + 1);
774 compute_defs_uses_and_gen (all_btr_defs, def_array, use_array, btr_defset,
775 bb_gen, btrs_written);
777 bb_kill = sbitmap_vector_alloc (n_basic_blocks, max_uid);
778 compute_kill (bb_kill, btr_defset, btrs_written);
779 free (btrs_written);
781 bb_out = sbitmap_vector_alloc (n_basic_blocks, max_uid);
782 compute_out (bb_out, bb_gen, bb_kill, max_uid);
784 sbitmap_vector_free (bb_gen);
785 sbitmap_vector_free (bb_kill);
787 link_btr_uses (def_array, use_array, bb_out, btr_defset, max_uid);
789 sbitmap_vector_free (bb_out);
790 sbitmap_vector_free (btr_defset);
791 free (use_array);
792 free (def_array);
795 /* Return true if basic block BB contains the start or end of the
796 live range of the definition DEF, AND there are other live
797 ranges of the same target register that include BB. */
798 static int
799 block_at_edge_of_live_range_p (int bb, btr_def def)
801 if (def->other_btr_uses_before_def && BASIC_BLOCK (bb) == def->bb)
802 return 1;
803 else if (def->other_btr_uses_after_use)
805 btr_user user;
806 for (user = def->uses; user != NULL; user = user->next)
807 if (BASIC_BLOCK (bb) == user->bb)
808 return 1;
810 return 0;
813 /* We are removing the def/use web DEF. The target register
814 used in this web is therefore no longer live in the live range
815 of this web, so remove it from the live set of all basic blocks
816 in the live range of the web.
817 Blocks at the boundary of the live range may contain other live
818 ranges for the same target register, so we have to be careful
819 to remove the target register from the live set of these blocks
820 only if they do not contain other live ranges for the same register. */
821 static void
822 clear_btr_from_live_range (btr_def def)
824 int bb;
826 EXECUTE_IF_SET_IN_BITMAP
827 (def->live_range, 0, bb,
829 if ((!def->other_btr_uses_before_def
830 && !def->other_btr_uses_after_use)
831 || !block_at_edge_of_live_range_p (bb, def))
833 CLEAR_HARD_REG_BIT (btrs_live[bb], def->btr);
834 CLEAR_HARD_REG_BIT (btrs_live_at_end[bb], def->btr);
835 if (dump_file)
836 dump_btrs_live (bb);
842 /* We are adding the def/use web DEF. Add the target register used
843 in this web to the live set of all of the basic blocks that contain
844 the live range of the web. */
845 static void
846 add_btr_to_live_range (btr_def def)
848 int bb;
849 EXECUTE_IF_SET_IN_BITMAP
850 (def->live_range, 0, bb,
852 SET_HARD_REG_BIT (btrs_live[bb], def->btr);
853 SET_HARD_REG_BIT (btrs_live_at_end[bb], def->btr);
854 if (dump_file)
855 dump_btrs_live (bb);
859 /* Update a live range to contain the basic block NEW_BLOCK, and all
860 blocks on paths between the existing live range and NEW_BLOCK.
861 HEAD is a block contained in the existing live range that dominates
862 all other blocks in the existing live range.
863 Also add to the set BTRS_LIVE_IN_RANGE all target registers that
864 are live in the blocks that we add to the live range.
865 It is a precondition that either NEW_BLOCK dominates HEAD,or
866 HEAD dom NEW_BLOCK. This is used to speed up the
867 implementation of this function. */
868 static void
869 augment_live_range (bitmap live_range, HARD_REG_SET *btrs_live_in_range,
870 basic_block head_bb, basic_block new_bb)
872 basic_block *worklist, *tos;
874 tos = worklist = xmalloc (sizeof (basic_block) * (n_basic_blocks + 1));
876 if (dominated_by_p (CDI_DOMINATORS, new_bb, head_bb))
877 *tos++ = new_bb;
878 else
880 edge e;
881 int new_block = new_bb->index;
883 gcc_assert (dominated_by_p (CDI_DOMINATORS, head_bb, new_bb));
885 bitmap_set_bit (live_range, new_block);
886 if (flag_btr_bb_exclusive)
887 IOR_HARD_REG_SET (*btrs_live_in_range, btrs_live[new_block]);
888 else
890 IOR_HARD_REG_SET (*btrs_live_in_range, btrs_live_at_end[new_block]);
891 IOR_HARD_REG_SET (*btrs_live_in_range, btrs_live[head_bb->index]);
893 if (dump_file)
895 fprintf (dump_file,
896 "Adding end of block %d and rest of %d to live range\n",
897 new_block, head_bb->index);
898 fprintf (dump_file,"Now live btrs are ");
899 dump_hard_reg_set (*btrs_live_in_range);
900 fprintf (dump_file, "\n");
903 FOR_EACH_EDGE (e, head_bb->preds)
905 *tos++ = e->src;
907 END_FOR_EACH_EDGE;
910 while (tos != worklist)
912 basic_block bb = *--tos;
913 if (!bitmap_bit_p (live_range, bb->index))
915 edge e;
917 bitmap_set_bit (live_range, bb->index);
918 IOR_HARD_REG_SET (*btrs_live_in_range,
919 btrs_live[bb->index]);
920 if (dump_file)
922 fprintf (dump_file,
923 "Adding block %d to live range\n", bb->index);
924 fprintf (dump_file,"Now live btrs are ");
925 dump_hard_reg_set (*btrs_live_in_range);
926 fprintf (dump_file, "\n");
929 FOR_EACH_EDGE (e, bb->preds)
931 basic_block pred = e->src;
932 if (!bitmap_bit_p (live_range, pred->index))
933 *tos++ = pred;
935 END_FOR_EACH_EDGE;
939 free (worklist);
942 /* Return the most desirable target register that is not in
943 the set USED_BTRS. */
944 static int
945 choose_btr (HARD_REG_SET used_btrs)
947 int i;
948 GO_IF_HARD_REG_SUBSET (all_btrs, used_btrs, give_up);
950 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
952 #ifdef REG_ALLOC_ORDER
953 int regno = reg_alloc_order[i];
954 #else
955 int regno = i;
956 #endif
957 if (TEST_HARD_REG_BIT (all_btrs, regno)
958 && !TEST_HARD_REG_BIT (used_btrs, regno))
959 return regno;
961 give_up:
962 return -1;
965 /* Calculate the set of basic blocks that contain the live range of
966 the def/use web DEF.
967 Also calculate the set of target registers that are live at time
968 in this live range, but ignore the live range represented by DEF
969 when calculating this set. */
970 static void
971 btr_def_live_range (btr_def def, HARD_REG_SET *btrs_live_in_range)
973 if (!def->live_range)
975 btr_user user;
977 def->live_range = BITMAP_XMALLOC ();
979 bitmap_set_bit (def->live_range, def->bb->index);
980 if (flag_btr_bb_exclusive)
981 COPY_HARD_REG_SET (*btrs_live_in_range, btrs_live[def->bb->index]);
982 else
983 COPY_HARD_REG_SET (*btrs_live_in_range,
984 btrs_live_at_end[def->bb->index]);
986 for (user = def->uses; user != NULL; user = user->next)
987 augment_live_range (def->live_range, btrs_live_in_range,
988 def->bb, user->bb);
990 else
992 /* def->live_range is accurate, but we need to recompute
993 the set of target registers live over it, because migration
994 of other PT instructions may have affected it.
996 int bb;
997 int def_bb = def->bb->index;
999 CLEAR_HARD_REG_SET (*btrs_live_in_range);
1000 if (flag_btr_bb_exclusive)
1001 EXECUTE_IF_SET_IN_BITMAP
1002 (def->live_range, 0, bb,
1004 IOR_HARD_REG_SET (*btrs_live_in_range, btrs_live[bb]);
1006 else
1007 EXECUTE_IF_SET_IN_BITMAP
1008 (def->live_range, 0, bb,
1010 IOR_HARD_REG_SET (*btrs_live_in_range,
1011 (def_bb == bb
1012 ? btrs_live_at_end : btrs_live) [bb]);
1015 if (!def->other_btr_uses_before_def &&
1016 !def->other_btr_uses_after_use)
1017 CLEAR_HARD_REG_BIT (*btrs_live_in_range, def->btr);
1020 /* Merge into the def/use web DEF any other def/use webs in the same
1021 group that are dominated by DEF, provided that there is a target
1022 register available to allocate to the merged web. */
1023 static void
1024 combine_btr_defs (btr_def def, HARD_REG_SET *btrs_live_in_range)
1026 btr_def other_def;
1028 for (other_def = def->group->members;
1029 other_def != NULL;
1030 other_def = other_def->next_this_group)
1032 if (other_def != def
1033 && other_def->uses != NULL
1034 && ! other_def->has_ambiguous_use
1035 && dominated_by_p (CDI_DOMINATORS, other_def->bb, def->bb))
1037 /* def->bb dominates the other def, so def and other_def could
1038 be combined. */
1039 /* Merge their live ranges, and get the set of
1040 target registers live over the merged range. */
1041 int btr;
1042 HARD_REG_SET combined_btrs_live;
1043 bitmap combined_live_range = BITMAP_XMALLOC ();
1044 btr_user user;
1046 if (other_def->live_range == NULL)
1048 HARD_REG_SET dummy_btrs_live_in_range;
1049 btr_def_live_range (other_def, &dummy_btrs_live_in_range);
1051 COPY_HARD_REG_SET (combined_btrs_live, *btrs_live_in_range);
1052 bitmap_copy (combined_live_range, def->live_range);
1054 for (user = other_def->uses; user != NULL; user = user->next)
1055 augment_live_range (combined_live_range, &combined_btrs_live,
1056 def->bb, user->bb);
1058 btr = choose_btr (combined_btrs_live);
1059 if (btr != -1)
1061 /* We can combine them. */
1062 if (dump_file)
1063 fprintf (dump_file,
1064 "Combining def in insn %d with def in insn %d\n",
1065 INSN_UID (other_def->insn), INSN_UID (def->insn));
1067 def->btr = btr;
1068 user = other_def->uses;
1069 while (user != NULL)
1071 btr_user next = user->next;
1073 user->next = def->uses;
1074 def->uses = user;
1075 user = next;
1077 /* Combining def/use webs can make target registers live
1078 after uses where they previously were not. This means
1079 some REG_DEAD notes may no longer be correct. We could
1080 be more precise about this if we looked at the combined
1081 live range, but here I just delete any REG_DEAD notes
1082 in case they are no longer correct. */
1083 for (user = def->uses; user != NULL; user = user->next)
1084 remove_note (user->insn,
1085 find_regno_note (user->insn, REG_DEAD,
1086 REGNO (user->use)));
1087 clear_btr_from_live_range (other_def);
1088 other_def->uses = NULL;
1089 bitmap_copy (def->live_range, combined_live_range);
1090 if (other_def->other_btr_uses_after_use)
1091 def->other_btr_uses_after_use = 1;
1092 COPY_HARD_REG_SET (*btrs_live_in_range, combined_btrs_live);
1094 /* Delete the old target register initialization. */
1095 delete_insn (other_def->insn);
1098 BITMAP_XFREE (combined_live_range);
1103 /* Move the definition DEF from its current position to basic
1104 block NEW_DEF_BB, and modify it to use branch target register BTR.
1105 Delete the old defining insn, and insert a new one in NEW_DEF_BB.
1106 Update all reaching uses of DEF in the RTL to use BTR.
1107 If this new position means that other defs in the
1108 same group can be combined with DEF then combine them. */
1109 static void
1110 move_btr_def (basic_block new_def_bb, int btr, btr_def def, bitmap live_range,
1111 HARD_REG_SET *btrs_live_in_range)
1113 /* We can move the instruction.
1114 Set a target register in block NEW_DEF_BB to the value
1115 needed for this target register definition.
1116 Replace all uses of the old target register definition by
1117 uses of the new definition. Delete the old definition. */
1118 basic_block b = new_def_bb;
1119 rtx insp = BB_HEAD (b);
1120 rtx old_insn = def->insn;
1121 rtx src;
1122 rtx btr_rtx;
1123 rtx new_insn;
1124 enum machine_mode btr_mode;
1125 btr_user user;
1126 rtx set;
1128 if (dump_file)
1129 fprintf(dump_file, "migrating to basic block %d, using reg %d\n",
1130 new_def_bb->index, btr);
1132 clear_btr_from_live_range (def);
1133 def->btr = btr;
1134 def->bb = new_def_bb;
1135 def->luid = 0;
1136 def->cost = basic_block_freq (new_def_bb);
1137 def->other_btr_uses_before_def
1138 = TEST_HARD_REG_BIT (btrs_live[b->index], btr) ? 1 : 0;
1139 bitmap_copy (def->live_range, live_range);
1140 combine_btr_defs (def, btrs_live_in_range);
1141 btr = def->btr;
1142 add_btr_to_live_range (def);
1143 if (LABEL_P (insp))
1144 insp = NEXT_INSN (insp);
1145 /* N.B.: insp is expected to be NOTE_INSN_BASIC_BLOCK now. Some
1146 optimizations can result in insp being both first and last insn of
1147 its basic block. */
1148 /* ?? some assertions to check that insp is sensible? */
1150 if (def->other_btr_uses_before_def)
1152 insp = BB_END (b);
1153 for (insp = BB_END (b); ! INSN_P (insp); insp = PREV_INSN (insp))
1154 gcc_assert (insp != BB_HEAD (b));
1156 if (JUMP_P (insp) || can_throw_internal (insp))
1157 insp = PREV_INSN (insp);
1160 set = single_set (old_insn);
1161 src = SET_SRC (set);
1162 btr_mode = GET_MODE (SET_DEST (set));
1163 btr_rtx = gen_rtx_REG (btr_mode, btr);
1165 new_insn = gen_move_insn (btr_rtx, src);
1167 /* Insert target register initialization at head of basic block. */
1168 def->insn = emit_insn_after (new_insn, insp);
1170 regs_ever_live[btr] = 1;
1172 if (dump_file)
1173 fprintf (dump_file, "New pt is insn %d, inserted after insn %d\n",
1174 INSN_UID (def->insn), INSN_UID (insp));
1176 /* Delete the old target register initialization. */
1177 delete_insn (old_insn);
1179 /* Replace each use of the old target register by a use of the new target
1180 register. */
1181 for (user = def->uses; user != NULL; user = user->next)
1183 /* Some extra work here to ensure consistent modes, because
1184 it seems that a target register REG rtx can be given a different
1185 mode depending on the context (surely that should not be
1186 the case?). */
1187 rtx replacement_rtx;
1188 if (GET_MODE (user->use) == GET_MODE (btr_rtx)
1189 || GET_MODE (user->use) == VOIDmode)
1190 replacement_rtx = btr_rtx;
1191 else
1192 replacement_rtx = gen_rtx_REG (GET_MODE (user->use), btr);
1193 replace_rtx (user->insn, user->use, replacement_rtx);
1194 user->use = replacement_rtx;
1198 /* We anticipate intra-block scheduling to be done. See if INSN could move
1199 up within BB by N_INSNS. */
1200 static int
1201 can_move_up (basic_block bb, rtx insn, int n_insns)
1203 while (insn != BB_HEAD (bb) && n_insns > 0)
1205 insn = PREV_INSN (insn);
1206 /* ??? What if we have an anti-dependency that actually prevents the
1207 scheduler from doing the move? We'd like to re-allocate the register,
1208 but not necessarily put the load into another basic block. */
1209 if (INSN_P (insn))
1210 n_insns--;
1212 return n_insns <= 0;
1215 /* Attempt to migrate the target register definition DEF to an
1216 earlier point in the flowgraph.
1218 It is a precondition of this function that DEF is migratable:
1219 i.e. it has a constant source, and all uses are unambiguous.
1221 Only migrations that reduce the cost of DEF will be made.
1222 MIN_COST is the lower bound on the cost of the DEF after migration.
1223 If we migrate DEF so that its cost falls below MIN_COST,
1224 then we do not attempt to migrate further. The idea is that
1225 we migrate definitions in a priority order based on their cost,
1226 when the cost of this definition falls below MIN_COST, then
1227 there is another definition with cost == MIN_COST which now
1228 has a higher priority than this definition.
1230 Return nonzero if there may be benefit from attempting to
1231 migrate this DEF further (i.e. we have reduced the cost below
1232 MIN_COST, but we may be able to reduce it further).
1233 Return zero if no further migration is possible. */
1234 static int
1235 migrate_btr_def (btr_def def, int min_cost)
1237 bitmap live_range;
1238 HARD_REG_SET btrs_live_in_range;
1239 int btr_used_near_def = 0;
1240 int def_basic_block_freq;
1241 basic_block try;
1242 int give_up = 0;
1243 int def_moved = 0;
1244 btr_user user;
1245 int def_latency;
1247 if (dump_file)
1248 fprintf (dump_file,
1249 "Attempting to migrate pt from insn %d (cost = %d, min_cost = %d) ... ",
1250 INSN_UID (def->insn), def->cost, min_cost);
1252 if (!def->group || def->has_ambiguous_use)
1253 /* These defs are not migratable. */
1255 if (dump_file)
1256 fprintf (dump_file, "it's not migratable\n");
1257 return 0;
1260 if (!def->uses)
1261 /* We have combined this def with another in the same group, so
1262 no need to consider it further.
1265 if (dump_file)
1266 fprintf (dump_file, "it's already combined with another pt\n");
1267 return 0;
1270 btr_def_live_range (def, &btrs_live_in_range);
1271 live_range = BITMAP_XMALLOC ();
1272 bitmap_copy (live_range, def->live_range);
1274 #ifdef INSN_SCHEDULING
1275 def_latency = insn_default_latency (def->insn) * issue_rate;
1276 #else
1277 def_latency = issue_rate;
1278 #endif
1280 for (user = def->uses; user != NULL; user = user->next)
1282 if (user->bb == def->bb
1283 && user->luid > def->luid
1284 && (def->luid + def_latency) > user->luid
1285 && ! can_move_up (def->bb, def->insn,
1286 (def->luid + def_latency) - user->luid))
1288 btr_used_near_def = 1;
1289 break;
1293 def_basic_block_freq = basic_block_freq (def->bb);
1295 for (try = get_immediate_dominator (CDI_DOMINATORS, def->bb);
1296 !give_up && try && try != ENTRY_BLOCK_PTR && def->cost >= min_cost;
1297 try = get_immediate_dominator (CDI_DOMINATORS, try))
1299 /* Try to move the instruction that sets the target register into
1300 basic block TRY. */
1301 int try_freq = basic_block_freq (try);
1303 if (dump_file)
1304 fprintf (dump_file, "trying block %d ...", try->index);
1306 if (try_freq < def_basic_block_freq
1307 || (try_freq == def_basic_block_freq && btr_used_near_def))
1309 int btr;
1310 augment_live_range (live_range, &btrs_live_in_range, def->bb, try);
1311 if (dump_file)
1313 fprintf (dump_file, "Now btrs live in range are: ");
1314 dump_hard_reg_set (btrs_live_in_range);
1315 fprintf (dump_file, "\n");
1317 btr = choose_btr (btrs_live_in_range);
1318 if (btr != -1)
1320 move_btr_def (try, btr, def, live_range, &btrs_live_in_range);
1321 bitmap_copy(live_range, def->live_range);
1322 btr_used_near_def = 0;
1323 def_moved = 1;
1324 def_basic_block_freq = basic_block_freq (def->bb);
1326 else
1328 /* There are no free target registers available to move
1329 this far forward, so give up */
1330 give_up = 1;
1331 if (dump_file)
1332 fprintf (dump_file,
1333 "giving up because there are no free target registers\n");
1338 if (!def_moved)
1340 give_up = 1;
1341 if (dump_file)
1342 fprintf (dump_file, "failed to move\n");
1344 BITMAP_XFREE (live_range);
1345 return !give_up;
1348 /* Attempt to move instructions that set target registers earlier
1349 in the flowgraph, away from their corresponding uses. */
1350 static void
1351 migrate_btr_defs (enum reg_class btr_class, int allow_callee_save)
1353 fibheap_t all_btr_defs = fibheap_new ();
1354 int reg;
1356 gcc_obstack_init (&migrate_btrl_obstack);
1357 if (dump_file)
1359 int i;
1361 for (i = 0; i < n_basic_blocks; i++)
1363 basic_block bb = BASIC_BLOCK (i);
1364 fprintf(dump_file,
1365 "Basic block %d: count = " HOST_WIDEST_INT_PRINT_DEC
1366 " loop-depth = %d idom = %d\n",
1367 i, (HOST_WIDEST_INT) bb->count, bb->loop_depth,
1368 get_immediate_dominator (CDI_DOMINATORS, bb)->index);
1372 CLEAR_HARD_REG_SET (all_btrs);
1373 for (first_btr = -1, reg = 0; reg < FIRST_PSEUDO_REGISTER; reg++)
1374 if (TEST_HARD_REG_BIT (reg_class_contents[(int) btr_class], reg)
1375 && (allow_callee_save || call_used_regs[reg] || regs_ever_live[reg]))
1377 SET_HARD_REG_BIT (all_btrs, reg);
1378 last_btr = reg;
1379 if (first_btr < 0)
1380 first_btr = reg;
1383 btrs_live = xcalloc (n_basic_blocks, sizeof (HARD_REG_SET));
1384 btrs_live_at_end = xcalloc (n_basic_blocks, sizeof (HARD_REG_SET));
1386 build_btr_def_use_webs (all_btr_defs);
1388 while (!fibheap_empty (all_btr_defs))
1390 btr_def def = fibheap_extract_min (all_btr_defs);
1391 int min_cost = -fibheap_min_key (all_btr_defs);
1392 if (migrate_btr_def (def, min_cost))
1394 fibheap_insert (all_btr_defs, -def->cost, (void *) def);
1395 if (dump_file)
1397 fprintf (dump_file,
1398 "Putting insn %d back on queue with priority %d\n",
1399 INSN_UID (def->insn), def->cost);
1402 else
1404 if (def->live_range)
1405 BITMAP_XFREE (def->live_range);
1409 free (btrs_live);
1410 free (btrs_live_at_end);
1411 obstack_free (&migrate_btrl_obstack, NULL);
1412 fibheap_delete (all_btr_defs);
1415 void
1416 branch_target_load_optimize (bool after_prologue_epilogue_gen)
1418 enum reg_class class = targetm.branch_target_register_class ();
1419 if (class != NO_REGS)
1421 /* Initialize issue_rate. */
1422 if (targetm.sched.issue_rate)
1423 issue_rate = targetm.sched.issue_rate ();
1424 else
1425 issue_rate = 1;
1427 /* Build the CFG for migrate_btr_defs. */
1428 #if 1
1429 /* This may or may not be needed, depending on where we
1430 run this phase. */
1431 cleanup_cfg (optimize ? CLEANUP_EXPENSIVE : 0);
1432 #endif
1434 life_analysis (NULL, 0);
1436 /* Dominator info is also needed for migrate_btr_def. */
1437 calculate_dominance_info (CDI_DOMINATORS);
1438 migrate_btr_defs (class,
1439 (targetm.branch_target_register_callee_saved
1440 (after_prologue_epilogue_gen)));
1442 free_dominance_info (CDI_DOMINATORS);
1444 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
1445 PROP_DEATH_NOTES | PROP_REG_INFO);