1 /* Register renaming for the GNU compiler.
2 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 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 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License 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
27 #include "insn-config.h"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
39 #define obstack_chunk_alloc xmalloc
40 #define obstack_chunk_free free
42 #ifndef REGNO_MODE_OK_FOR_BASE_P
43 #define REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) REGNO_OK_FOR_BASE_P (REGNO)
46 #ifndef REG_MODE_OK_FOR_BASE_P
47 #define REG_MODE_OK_FOR_BASE_P(REGNO, MODE) REG_OK_FOR_BASE_P (REGNO)
50 static const char *const reg_class_names
[] = REG_CLASS_NAMES
;
54 struct du_chain
*next_chain
;
55 struct du_chain
*next_use
;
60 unsigned int need_caller_save_reg
:1;
61 unsigned int earlyclobber
:1;
67 terminate_overlapping_read
,
74 static const char * const scan_actions_name
[] =
77 "terminate_overlapping_read",
84 static struct obstack rename_obstack
;
86 static void do_replace
PARAMS ((struct du_chain
*, int));
87 static void scan_rtx_reg
PARAMS ((rtx
, rtx
*, enum reg_class
,
88 enum scan_actions
, enum op_type
, int));
89 static void scan_rtx_address
PARAMS ((rtx
, rtx
*, enum reg_class
,
90 enum scan_actions
, enum machine_mode
));
91 static void scan_rtx
PARAMS ((rtx
, rtx
*, enum reg_class
,
92 enum scan_actions
, enum op_type
, int));
93 static struct du_chain
*build_def_use
PARAMS ((basic_block
));
94 static void dump_def_use_chain
PARAMS ((struct du_chain
*));
95 static void note_sets
PARAMS ((rtx
, rtx
, void *));
96 static void clear_dead_regs
PARAMS ((HARD_REG_SET
*, enum machine_mode
, rtx
));
97 static void merge_overlapping_regs
PARAMS ((basic_block
, HARD_REG_SET
*,
100 /* Called through note_stores from update_life. Find sets of registers, and
101 record them in *DATA (which is actually a HARD_REG_SET *). */
104 note_sets (x
, set
, data
)
106 rtx set ATTRIBUTE_UNUSED
;
109 HARD_REG_SET
*pset
= (HARD_REG_SET
*) data
;
112 if (GET_CODE (x
) != REG
)
115 nregs
= HARD_REGNO_NREGS (regno
, GET_MODE (x
));
117 /* There must not be pseudos at this point. */
118 if (regno
+ nregs
> FIRST_PSEUDO_REGISTER
)
122 SET_HARD_REG_BIT (*pset
, regno
+ nregs
);
125 /* Clear all registers from *PSET for which a note of kind KIND can be found
126 in the list NOTES. */
129 clear_dead_regs (pset
, kind
, notes
)
131 enum machine_mode kind
;
135 for (note
= notes
; note
; note
= XEXP (note
, 1))
136 if (REG_NOTE_KIND (note
) == kind
&& REG_P (XEXP (note
, 0)))
138 rtx reg
= XEXP (note
, 0);
139 unsigned int regno
= REGNO (reg
);
140 int nregs
= HARD_REGNO_NREGS (regno
, GET_MODE (reg
));
142 /* There must not be pseudos at this point. */
143 if (regno
+ nregs
> FIRST_PSEUDO_REGISTER
)
147 CLEAR_HARD_REG_BIT (*pset
, regno
+ nregs
);
151 /* For a def-use chain CHAIN in basic block B, find which registers overlap
152 its lifetime and set the corresponding bits in *PSET. */
155 merge_overlapping_regs (b
, pset
, chain
)
158 struct du_chain
*chain
;
160 struct du_chain
*t
= chain
;
164 REG_SET_TO_HARD_REG_SET (live
, b
->global_live_at_start
);
168 /* Search forward until the next reference to the register to be
170 while (insn
!= t
->insn
)
174 clear_dead_regs (&live
, REG_DEAD
, REG_NOTES (insn
));
175 note_stores (PATTERN (insn
), note_sets
, (void *) &live
);
176 /* Only record currently live regs if we are inside the
179 IOR_HARD_REG_SET (*pset
, live
);
180 clear_dead_regs (&live
, REG_UNUSED
, REG_NOTES (insn
));
182 insn
= NEXT_INSN (insn
);
185 IOR_HARD_REG_SET (*pset
, live
);
187 /* For the last reference, also merge in all registers set in the
189 @@@ We only have take earlyclobbered sets into account. */
191 note_stores (PATTERN (insn
), note_sets
, (void *) pset
);
197 /* Perform register renaming on the current function. */
200 regrename_optimize ()
202 int tick
[FIRST_PSEUDO_REGISTER
];
207 memset (tick
, 0, sizeof tick
);
209 gcc_obstack_init (&rename_obstack
);
210 first_obj
= (char *) obstack_alloc (&rename_obstack
, 0);
212 for (b
= 0; b
< n_basic_blocks
; b
++)
214 basic_block bb
= BASIC_BLOCK (b
);
215 struct du_chain
*all_chains
= 0;
216 HARD_REG_SET unavailable
;
217 HARD_REG_SET regs_seen
;
219 CLEAR_HARD_REG_SET (unavailable
);
222 fprintf (rtl_dump_file
, "\nBasic block %d:\n", b
);
224 all_chains
= build_def_use (bb
);
227 dump_def_use_chain (all_chains
);
229 CLEAR_HARD_REG_SET (unavailable
);
230 /* Don't clobber traceback for noreturn functions. */
231 if (frame_pointer_needed
)
235 for (i
= HARD_REGNO_NREGS (FRAME_POINTER_REGNUM
, Pmode
); i
--;)
236 SET_HARD_REG_BIT (unavailable
, FRAME_POINTER_REGNUM
+ i
);
238 #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
239 for (i
= HARD_REGNO_NREGS (HARD_FRAME_POINTER_REGNUM
, Pmode
); i
--;)
240 SET_HARD_REG_BIT (unavailable
, HARD_FRAME_POINTER_REGNUM
+ i
);
244 CLEAR_HARD_REG_SET (regs_seen
);
247 int new_reg
, best_new_reg
= -1;
249 struct du_chain
*this = all_chains
;
250 struct du_chain
*tmp
, *last
;
251 HARD_REG_SET this_unavailable
;
252 int reg
= REGNO (*this->loc
);
255 all_chains
= this->next_chain
;
257 #if 0 /* This just disables optimization opportunities. */
258 /* Only rename once we've seen the reg more than once. */
259 if (! TEST_HARD_REG_BIT (regs_seen
, reg
))
261 SET_HARD_REG_BIT (regs_seen
, reg
);
266 if (fixed_regs
[reg
] || global_regs
[reg
]
267 #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
268 || (frame_pointer_needed
&& reg
== HARD_FRAME_POINTER_REGNUM
)
270 || (frame_pointer_needed
&& reg
== FRAME_POINTER_REGNUM
)
275 COPY_HARD_REG_SET (this_unavailable
, unavailable
);
277 /* Find last entry on chain (which has the need_caller_save bit),
278 count number of uses, and narrow the set of registers we can
281 for (last
= this; last
->next_use
; last
= last
->next_use
)
284 IOR_COMPL_HARD_REG_SET (this_unavailable
,
285 reg_class_contents
[last
->class]);
290 IOR_COMPL_HARD_REG_SET (this_unavailable
,
291 reg_class_contents
[last
->class]);
293 if (this->need_caller_save_reg
)
294 IOR_HARD_REG_SET (this_unavailable
, call_used_reg_set
);
296 merge_overlapping_regs (bb
, &this_unavailable
, this);
298 /* Now potential_regs is a reasonable approximation, let's
299 have a closer look at each register still in there. */
300 for (new_reg
= 0; new_reg
< FIRST_PSEUDO_REGISTER
; new_reg
++)
302 int nregs
= HARD_REGNO_NREGS (new_reg
, GET_MODE (*this->loc
));
304 for (i
= nregs
- 1; i
>= 0; --i
)
305 if (TEST_HARD_REG_BIT (this_unavailable
, new_reg
+ i
)
306 || fixed_regs
[new_reg
+ i
]
307 || global_regs
[new_reg
+ i
]
308 /* Can't use regs which aren't saved by the prologue. */
309 || (! regs_ever_live
[new_reg
+ i
]
310 && ! call_used_regs
[new_reg
+ i
])
311 #ifdef LEAF_REGISTERS
312 /* We can't use a non-leaf register if we're in a
314 || (current_function_is_leaf
315 && !LEAF_REGISTERS
[new_reg
+ i
])
317 #ifdef HARD_REGNO_RENAME_OK
318 || ! HARD_REGNO_RENAME_OK (reg
+ i
, new_reg
+ i
)
325 /* See whether it accepts all modes that occur in
326 definition and uses. */
327 for (tmp
= this; tmp
; tmp
= tmp
->next_use
)
328 if (! HARD_REGNO_MODE_OK (new_reg
, GET_MODE (*tmp
->loc
)))
332 if (best_new_reg
== -1
333 || tick
[best_new_reg
] > tick
[new_reg
])
334 best_new_reg
= new_reg
;
340 fprintf (rtl_dump_file
, "Register %s in insn %d",
341 reg_names
[reg
], INSN_UID (last
->insn
));
342 if (last
->need_caller_save_reg
)
343 fprintf (rtl_dump_file
, " crosses a call");
346 if (best_new_reg
== -1)
349 fprintf (rtl_dump_file
, "; no available registers\n");
353 do_replace (this, best_new_reg
);
354 tick
[best_new_reg
] = this_tick
++;
357 fprintf (rtl_dump_file
, ", renamed as %s\n", reg_names
[best_new_reg
]);
360 obstack_free (&rename_obstack
, first_obj
);
363 obstack_free (&rename_obstack
, NULL
);
366 fputc ('\n', rtl_dump_file
);
368 count_or_remove_death_notes (NULL
, 1);
369 update_life_info (NULL
, UPDATE_LIFE_LOCAL
,
370 PROP_REG_INFO
| PROP_DEATH_NOTES
);
374 do_replace (chain
, reg
)
375 struct du_chain
*chain
;
380 unsigned int regno
= ORIGINAL_REGNO (*chain
->loc
);
381 *chain
->loc
= gen_raw_REG (GET_MODE (*chain
->loc
), reg
);
382 if (regno
>= FIRST_PSEUDO_REGISTER
)
383 ORIGINAL_REGNO (*chain
->loc
) = regno
;
384 chain
= chain
->next_use
;
389 static struct du_chain
*open_chains
;
390 static struct du_chain
*closed_chains
;
393 scan_rtx_reg (insn
, loc
, class, action
, type
, earlyclobber
)
396 enum reg_class
class;
397 enum scan_actions action
;
403 enum machine_mode mode
= GET_MODE (x
);
404 int this_regno
= REGNO (x
);
405 int this_nregs
= HARD_REGNO_NREGS (this_regno
, mode
);
407 if (action
== mark_write
)
411 struct du_chain
*this = (struct du_chain
*)
412 obstack_alloc (&rename_obstack
, sizeof (struct du_chain
));
414 this->next_chain
= open_chains
;
418 this->need_caller_save_reg
= 0;
419 this->earlyclobber
= earlyclobber
;
425 if ((type
== OP_OUT
&& action
!= terminate_write
)
426 || (type
!= OP_OUT
&& action
== terminate_write
))
429 for (p
= &open_chains
; *p
;)
431 struct du_chain
*this = *p
;
433 /* Check if the chain has been terminated if it has then skip to
436 This can happen when we've already appended the location to
437 the chain in Step 3, but are trying to hide in-out operands
438 from terminate_write in Step 5. */
440 if (*this->loc
== cc0_rtx
)
441 p
= &this->next_chain
;
444 int regno
= REGNO (*this->loc
);
445 int nregs
= HARD_REGNO_NREGS (regno
, GET_MODE (*this->loc
));
446 int exact_match
= (regno
== this_regno
&& nregs
== this_nregs
);
448 if (regno
+ nregs
<= this_regno
449 || this_regno
+ this_nregs
<= regno
)
451 p
= &this->next_chain
;
455 if (action
== mark_read
)
460 /* ??? Class NO_REGS can happen if the md file makes use of
461 EXTRA_CONSTRAINTS to match registers. Which is arguably
462 wrong, but there we are. Since we know not what this may
463 be replaced with, terminate the chain. */
464 if (class != NO_REGS
)
466 this = (struct du_chain
*)
467 obstack_alloc (&rename_obstack
, sizeof (struct du_chain
));
469 this->next_chain
= (*p
)->next_chain
;
473 this->need_caller_save_reg
= 0;
481 if (action
!= terminate_overlapping_read
|| ! exact_match
)
483 struct du_chain
*next
= this->next_chain
;
485 /* Whether the terminated chain can be used for renaming
486 depends on the action and this being an exact match.
487 In either case, we remove this element from open_chains. */
489 if ((action
== terminate_dead
|| action
== terminate_write
)
492 this->next_chain
= closed_chains
;
493 closed_chains
= this;
495 fprintf (rtl_dump_file
,
496 "Closing chain %s at insn %d (%s)\n",
497 reg_names
[REGNO (*this->loc
)], INSN_UID (insn
),
498 scan_actions_name
[(int) action
]);
503 fprintf (rtl_dump_file
,
504 "Discarding chain %s at insn %d (%s)\n",
505 reg_names
[REGNO (*this->loc
)], INSN_UID (insn
),
506 scan_actions_name
[(int) action
]);
511 p
= &this->next_chain
;
516 /* Adapted from find_reloads_address_1. CLASS is INDEX_REG_CLASS or
517 BASE_REG_CLASS depending on how the register is being considered. */
520 scan_rtx_address (insn
, loc
, class, action
, mode
)
523 enum reg_class
class;
524 enum scan_actions action
;
525 enum machine_mode mode
;
528 RTX_CODE code
= GET_CODE (x
);
532 if (action
== mark_write
)
539 rtx orig_op0
= XEXP (x
, 0);
540 rtx orig_op1
= XEXP (x
, 1);
541 RTX_CODE code0
= GET_CODE (orig_op0
);
542 RTX_CODE code1
= GET_CODE (orig_op1
);
548 if (GET_CODE (op0
) == SUBREG
)
550 op0
= SUBREG_REG (op0
);
551 code0
= GET_CODE (op0
);
554 if (GET_CODE (op1
) == SUBREG
)
556 op1
= SUBREG_REG (op1
);
557 code1
= GET_CODE (op1
);
560 if (code0
== MULT
|| code0
== SIGN_EXTEND
|| code0
== TRUNCATE
561 || code0
== ZERO_EXTEND
|| code1
== MEM
)
566 else if (code1
== MULT
|| code1
== SIGN_EXTEND
|| code1
== TRUNCATE
567 || code1
== ZERO_EXTEND
|| code0
== MEM
)
572 else if (code0
== CONST_INT
|| code0
== CONST
573 || code0
== SYMBOL_REF
|| code0
== LABEL_REF
)
575 else if (code1
== CONST_INT
|| code1
== CONST
576 || code1
== SYMBOL_REF
|| code1
== LABEL_REF
)
578 else if (code0
== REG
&& code1
== REG
)
582 if (REG_OK_FOR_INDEX_P (op0
)
583 && REG_MODE_OK_FOR_BASE_P (op1
, mode
))
585 else if (REG_OK_FOR_INDEX_P (op1
)
586 && REG_MODE_OK_FOR_BASE_P (op0
, mode
))
588 else if (REG_MODE_OK_FOR_BASE_P (op1
, mode
))
590 else if (REG_MODE_OK_FOR_BASE_P (op0
, mode
))
592 else if (REG_OK_FOR_INDEX_P (op1
))
597 locI
= &XEXP (x
, index_op
);
598 locB
= &XEXP (x
, !index_op
);
600 else if (code0
== REG
)
605 else if (code1
== REG
)
612 scan_rtx_address (insn
, locI
, INDEX_REG_CLASS
, action
, mode
);
614 scan_rtx_address (insn
, locB
, MODE_BASE_REG_CLASS (mode
), action
, mode
);
625 /* If the target doesn't claim to handle autoinc, this must be
626 something special, like a stack push. Kill this chain. */
627 action
= terminate_all_read
;
632 scan_rtx_address (insn
, &XEXP (x
, 0),
633 MODE_BASE_REG_CLASS (GET_MODE (x
)), action
,
638 scan_rtx_reg (insn
, loc
, class, action
, OP_IN
, 0);
645 fmt
= GET_RTX_FORMAT (code
);
646 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
649 scan_rtx_address (insn
, &XEXP (x
, i
), class, action
, mode
);
650 else if (fmt
[i
] == 'E')
651 for (j
= XVECLEN (x
, i
) - 1; j
>= 0; j
--)
652 scan_rtx_address (insn
, &XVECEXP (x
, i
, j
), class, action
, mode
);
657 scan_rtx (insn
, loc
, class, action
, type
, earlyclobber
)
660 enum reg_class
class;
661 enum scan_actions action
;
667 enum rtx_code code
= GET_CODE (x
);
683 scan_rtx_reg (insn
, loc
, class, action
, type
, earlyclobber
);
687 scan_rtx_address (insn
, &XEXP (x
, 0),
688 MODE_BASE_REG_CLASS (GET_MODE (x
)), action
,
693 scan_rtx (insn
, &SET_SRC (x
), class, action
, OP_IN
, 0);
694 scan_rtx (insn
, &SET_DEST (x
), class, action
, OP_OUT
, 0);
697 case STRICT_LOW_PART
:
698 scan_rtx (insn
, &XEXP (x
, 0), class, action
, OP_INOUT
, earlyclobber
);
703 scan_rtx (insn
, &XEXP (x
, 0), class, action
,
704 type
== OP_IN
? OP_IN
: OP_INOUT
, earlyclobber
);
705 scan_rtx (insn
, &XEXP (x
, 1), class, action
, OP_IN
, 0);
706 scan_rtx (insn
, &XEXP (x
, 2), class, action
, OP_IN
, 0);
715 /* Should only happen inside MEM. */
719 scan_rtx (insn
, &SET_DEST (x
), class, action
, OP_OUT
, 1);
723 scan_rtx (insn
, &XEXP (x
, 0), class, action
, type
, 0);
725 scan_rtx (insn
, &XEXP (x
, 1), class, action
, type
, 0);
732 fmt
= GET_RTX_FORMAT (code
);
733 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
736 scan_rtx (insn
, &XEXP (x
, i
), class, action
, type
, 0);
737 else if (fmt
[i
] == 'E')
738 for (j
= XVECLEN (x
, i
) - 1; j
>= 0; j
--)
739 scan_rtx (insn
, &XVECEXP (x
, i
, j
), class, action
, type
, 0);
743 /* Build def/use chain */
745 static struct du_chain
*
751 open_chains
= closed_chains
= NULL
;
753 for (insn
= bb
->head
; ; insn
= NEXT_INSN (insn
))
759 rtx old_operands
[MAX_RECOG_OPERANDS
];
760 rtx old_dups
[MAX_DUP_OPERANDS
];
765 /* Process the insn, determining its effect on the def-use
766 chains. We perform the following steps with the register
767 references in the insn:
768 (1) Any read that overlaps an open chain, but doesn't exactly
769 match, causes that chain to be closed. We can't deal
771 (2) Any read outside an operand causes any chain it overlaps
772 with to be closed, since we can't replace it.
773 (3) Any read inside an operand is added if there's already
774 an open chain for it.
775 (4) For any REG_DEAD note we find, close open chains that
777 (5) For any write we find, close open chains that overlap it.
778 (6) For any write we find in an operand, make a new chain.
779 (7) For any REG_UNUSED, close any chains we just opened. */
782 constrain_operands (1);
783 preprocess_constraints ();
784 alt
= which_alternative
;
785 n_ops
= recog_data
.n_operands
;
787 /* Simplify the code below by rewriting things to reflect
788 matching constraints. Also promote OP_OUT to OP_INOUT
789 in predicated instructions. */
791 predicated
= GET_CODE (PATTERN (insn
)) == COND_EXEC
;
792 for (i
= 0; i
< n_ops
; ++i
)
794 int matches
= recog_op_alt
[i
][alt
].matches
;
796 recog_op_alt
[i
][alt
].class = recog_op_alt
[matches
][alt
].class;
797 if (matches
>= 0 || recog_op_alt
[i
][alt
].matched
>= 0
798 || (predicated
&& recog_data
.operand_type
[i
] == OP_OUT
))
799 recog_data
.operand_type
[i
] = OP_INOUT
;
802 /* Step 1: Close chains for which we have overlapping reads. */
803 for (i
= 0; i
< n_ops
; i
++)
804 scan_rtx (insn
, recog_data
.operand_loc
[i
],
805 NO_REGS
, terminate_overlapping_read
,
806 recog_data
.operand_type
[i
], 0);
808 /* Step 2: Close chains for which we have reads outside operands.
809 We do this by munging all operands into CC0, and closing
810 everything remaining. */
812 for (i
= 0; i
< n_ops
; i
++)
814 old_operands
[i
] = recog_data
.operand
[i
];
815 /* Don't squash match_operator or match_parallel here, since
816 we don't know that all of the contained registers are
817 reachable by proper operands. */
818 if (recog_data
.constraints
[i
][0] == '\0')
820 *recog_data
.operand_loc
[i
] = cc0_rtx
;
822 for (i
= 0; i
< recog_data
.n_dups
; i
++)
824 old_dups
[i
] = *recog_data
.dup_loc
[i
];
825 *recog_data
.dup_loc
[i
] = cc0_rtx
;
828 scan_rtx (insn
, &PATTERN (insn
), NO_REGS
, terminate_all_read
,
831 for (i
= 0; i
< recog_data
.n_dups
; i
++)
832 *recog_data
.dup_loc
[i
] = old_dups
[i
];
833 for (i
= 0; i
< n_ops
; i
++)
834 *recog_data
.operand_loc
[i
] = old_operands
[i
];
836 /* Step 2B: Can't rename function call argument registers. */
837 if (GET_CODE (insn
) == CALL_INSN
&& CALL_INSN_FUNCTION_USAGE (insn
))
838 scan_rtx (insn
, &CALL_INSN_FUNCTION_USAGE (insn
),
839 NO_REGS
, terminate_all_read
, OP_IN
, 0);
841 /* Step 3: Append to chains for reads inside operands. */
842 for (i
= 0; i
< n_ops
+ recog_data
.n_dups
; i
++)
844 int opn
= i
< n_ops
? i
: recog_data
.dup_num
[i
- n_ops
];
845 rtx
*loc
= (i
< n_ops
846 ? recog_data
.operand_loc
[opn
]
847 : recog_data
.dup_loc
[i
- n_ops
]);
848 enum reg_class
class = recog_op_alt
[opn
][alt
].class;
849 enum op_type type
= recog_data
.operand_type
[opn
];
851 /* Don't scan match_operand here, since we've no reg class
852 information to pass down. Any operands that we could
853 substitute in will be represented elsewhere. */
854 if (recog_data
.constraints
[opn
][0] == '\0')
857 if (recog_op_alt
[opn
][alt
].is_address
)
858 scan_rtx_address (insn
, loc
, class, mark_read
, VOIDmode
);
860 scan_rtx (insn
, loc
, class, mark_read
, type
, 0);
863 /* Step 4: Close chains for registers that die here.
864 Also record updates for REG_INC notes. */
865 for (note
= REG_NOTES (insn
); note
; note
= XEXP (note
, 1))
867 if (REG_NOTE_KIND (note
) == REG_DEAD
)
868 scan_rtx (insn
, &XEXP (note
, 0), NO_REGS
, terminate_dead
,
870 else if (REG_NOTE_KIND (note
) == REG_INC
)
871 scan_rtx (insn
, &XEXP (note
, 0), ALL_REGS
, mark_read
,
875 /* Step 4B: If this is a call, any chain live at this point
876 requires a caller-saved reg. */
877 if (GET_CODE (insn
) == CALL_INSN
)
880 for (p
= open_chains
; p
; p
= p
->next_chain
)
881 p
->need_caller_save_reg
= 1;
884 /* Step 5: Close open chains that overlap writes. Similar to
885 step 2, we hide in-out operands, since we do not want to
886 close these chains. */
888 for (i
= 0; i
< n_ops
; i
++)
890 old_operands
[i
] = recog_data
.operand
[i
];
891 if (recog_data
.operand_type
[i
] == OP_INOUT
)
892 *recog_data
.operand_loc
[i
] = cc0_rtx
;
894 for (i
= 0; i
< recog_data
.n_dups
; i
++)
896 int opn
= recog_data
.dup_num
[i
];
897 old_dups
[i
] = *recog_data
.dup_loc
[i
];
898 if (recog_data
.operand_type
[opn
] == OP_INOUT
)
899 *recog_data
.dup_loc
[i
] = cc0_rtx
;
902 scan_rtx (insn
, &PATTERN (insn
), NO_REGS
, terminate_write
, OP_IN
, 0);
904 for (i
= 0; i
< recog_data
.n_dups
; i
++)
905 *recog_data
.dup_loc
[i
] = old_dups
[i
];
906 for (i
= 0; i
< n_ops
; i
++)
907 *recog_data
.operand_loc
[i
] = old_operands
[i
];
909 /* Step 6: Begin new chains for writes inside operands. */
910 /* ??? Many targets have output constraints on the SET_DEST
911 of a call insn, which is stupid, since these are certainly
912 ABI defined hard registers. Don't change calls at all. */
913 if (GET_CODE (insn
) != CALL_INSN
)
914 for (i
= 0; i
< n_ops
+ recog_data
.n_dups
; i
++)
916 int opn
= i
< n_ops
? i
: recog_data
.dup_num
[i
- n_ops
];
917 rtx
*loc
= (i
< n_ops
918 ? recog_data
.operand_loc
[opn
]
919 : recog_data
.dup_loc
[i
- n_ops
]);
920 enum reg_class
class = recog_op_alt
[opn
][alt
].class;
922 if (recog_data
.operand_type
[opn
] == OP_OUT
)
923 scan_rtx (insn
, loc
, class, mark_write
, OP_OUT
,
924 recog_op_alt
[opn
][alt
].earlyclobber
);
927 /* Step 7: Close chains for registers that were never
929 for (note
= REG_NOTES (insn
); note
; note
= XEXP (note
, 1))
930 if (REG_NOTE_KIND (note
) == REG_UNUSED
)
931 scan_rtx (insn
, &XEXP (note
, 0), NO_REGS
, terminate_dead
,
938 /* Since we close every chain when we find a REG_DEAD note, anything that
939 is still open lives past the basic block, so it can't be renamed. */
940 return closed_chains
;
943 /* Dump all def/use chains in CHAINS to RTL_DUMP_FILE. They are
944 printed in reverse order as that's how we build them. */
947 dump_def_use_chain (chains
)
948 struct du_chain
*chains
;
952 struct du_chain
*this = chains
;
953 int r
= REGNO (*this->loc
);
954 int nregs
= HARD_REGNO_NREGS (r
, GET_MODE (*this->loc
));
955 fprintf (rtl_dump_file
, "Register %s (%d):", reg_names
[r
], nregs
);
958 fprintf (rtl_dump_file
, " %d [%s]", INSN_UID (this->insn
),
959 reg_class_names
[this->class]);
960 this = this->next_use
;
962 fprintf (rtl_dump_file
, "\n");
963 chains
= chains
->next_chain
;
967 /* The following code does forward propagation of hard register copies.
968 The object is to eliminate as many dependencies as possible, so that
969 we have the most scheduling freedom. As a side effect, we also clean
970 up some silly register allocation decisions made by reload. This
971 code may be obsoleted by a new register allocator. */
973 /* For each register, we have a list of registers that contain the same
974 value. The OLDEST_REGNO field points to the head of the list, and
975 the NEXT_REGNO field runs through the list. The MODE field indicates
976 what mode the data is known to be in; this field is VOIDmode when the
977 register is not known to contain valid data. */
979 struct value_data_entry
981 enum machine_mode mode
;
982 unsigned int oldest_regno
;
983 unsigned int next_regno
;
988 struct value_data_entry e
[FIRST_PSEUDO_REGISTER
];
989 unsigned int max_value_regs
;
992 static void kill_value_regno
PARAMS ((unsigned, struct value_data
*));
993 static void kill_value
PARAMS ((rtx
, struct value_data
*));
994 static void set_value_regno
PARAMS ((unsigned, enum machine_mode
,
995 struct value_data
*));
996 static void init_value_data
PARAMS ((struct value_data
*));
997 static void kill_clobbered_value
PARAMS ((rtx
, rtx
, void *));
998 static void kill_set_value
PARAMS ((rtx
, rtx
, void *));
999 static int kill_autoinc_value
PARAMS ((rtx
*, void *));
1000 static void copy_value
PARAMS ((rtx
, rtx
, struct value_data
*));
1001 static bool mode_change_ok
PARAMS ((enum machine_mode
, enum machine_mode
,
1003 static rtx find_oldest_value_reg
PARAMS ((enum reg_class
, unsigned int,
1005 struct value_data
*));
1006 static bool replace_oldest_value_reg
PARAMS ((rtx
*, enum reg_class
, rtx
,
1007 struct value_data
*));
1008 static bool replace_oldest_value_addr
PARAMS ((rtx
*, enum reg_class
,
1009 enum machine_mode
, rtx
,
1010 struct value_data
*));
1011 static bool replace_oldest_value_mem
PARAMS ((rtx
, rtx
, struct value_data
*));
1012 static bool copyprop_hardreg_forward_1
PARAMS ((basic_block
,
1013 struct value_data
*));
1014 extern void debug_value_data
PARAMS ((struct value_data
*));
1015 #ifdef ENABLE_CHECKING
1016 static void validate_value_data
PARAMS ((struct value_data
*));
1019 /* Kill register REGNO. This involves removing it from any value lists,
1020 and resetting the value mode to VOIDmode. */
1023 kill_value_regno (regno
, vd
)
1025 struct value_data
*vd
;
1027 unsigned int i
, next
;
1029 if (vd
->e
[regno
].oldest_regno
!= regno
)
1031 for (i
= vd
->e
[regno
].oldest_regno
;
1032 vd
->e
[i
].next_regno
!= regno
;
1033 i
= vd
->e
[i
].next_regno
)
1035 vd
->e
[i
].next_regno
= vd
->e
[regno
].next_regno
;
1037 else if ((next
= vd
->e
[regno
].next_regno
) != INVALID_REGNUM
)
1039 for (i
= next
; i
!= INVALID_REGNUM
; i
= vd
->e
[i
].next_regno
)
1040 vd
->e
[i
].oldest_regno
= next
;
1043 vd
->e
[regno
].mode
= VOIDmode
;
1044 vd
->e
[regno
].oldest_regno
= regno
;
1045 vd
->e
[regno
].next_regno
= INVALID_REGNUM
;
1047 #ifdef ENABLE_CHECKING
1048 validate_value_data (vd
);
1052 /* Kill X. This is a convenience function for kill_value_regno
1053 so that we mind the mode the register is in. */
1058 struct value_data
*vd
;
1062 unsigned int regno
= REGNO (x
);
1063 unsigned int n
= HARD_REGNO_NREGS (regno
, GET_MODE (x
));
1066 /* Kill the value we're told to kill. */
1067 for (i
= 0; i
< n
; ++i
)
1068 kill_value_regno (regno
+ i
, vd
);
1070 /* Kill everything that overlapped what we're told to kill. */
1071 if (regno
< vd
->max_value_regs
)
1074 j
= regno
- vd
->max_value_regs
;
1075 for (; j
< regno
; ++j
)
1077 if (vd
->e
[j
].mode
== VOIDmode
)
1079 n
= HARD_REGNO_NREGS (regno
, vd
->e
[j
].mode
);
1081 for (i
= 0; i
< n
; ++i
)
1082 kill_value_regno (j
+ i
, vd
);
1087 /* Remember that REGNO is valid in MODE. */
1090 set_value_regno (regno
, mode
, vd
)
1092 enum machine_mode mode
;
1093 struct value_data
*vd
;
1097 vd
->e
[regno
].mode
= mode
;
1099 nregs
= HARD_REGNO_NREGS (regno
, mode
);
1100 if (nregs
> vd
->max_value_regs
)
1101 vd
->max_value_regs
= nregs
;
1104 /* Initialize VD such that there are no known relationships between regs. */
1107 init_value_data (vd
)
1108 struct value_data
*vd
;
1111 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; ++i
)
1113 vd
->e
[i
].mode
= VOIDmode
;
1114 vd
->e
[i
].oldest_regno
= i
;
1115 vd
->e
[i
].next_regno
= INVALID_REGNUM
;
1117 vd
->max_value_regs
= 0;
1120 /* Called through note_stores. If X is clobbered, kill its value. */
1123 kill_clobbered_value (x
, set
, data
)
1128 struct value_data
*vd
= data
;
1129 if (GET_CODE (set
) == CLOBBER
)
1133 /* Called through note_stores. If X is set, not clobbered, kill its
1134 current value and install it as the root of its own value list. */
1137 kill_set_value (x
, set
, data
)
1142 struct value_data
*vd
= data
;
1143 if (GET_CODE (set
) != CLOBBER
&& REG_P (x
))
1146 set_value_regno (REGNO (x
), GET_MODE (x
), vd
);
1150 /* Called through for_each_rtx. Kill any register used as the base of an
1151 auto-increment expression, and install that register as the root of its
1155 kill_autoinc_value (px
, data
)
1160 struct value_data
*vd
= data
;
1162 if (GET_RTX_CLASS (GET_CODE (x
)) == 'a')
1166 set_value_regno (REGNO (x
), Pmode
, vd
);
1173 /* Assert that SRC has been copied to DEST. Adjust the data structures
1174 to reflect that SRC contains an older copy of the shared value. */
1177 copy_value (dest
, src
, vd
)
1180 struct value_data
*vd
;
1182 unsigned int dr
= REGNO (dest
);
1183 unsigned int sr
= REGNO (src
);
1186 /* ??? At present, it's possible to see noop sets. It'd be nice if
1187 this were cleaned up beforehand... */
1191 /* Do not propagate copies to the stack pointer, as that can leave
1192 memory accesses with no scheduling dependancy on the stack update. */
1193 if (dr
== STACK_POINTER_REGNUM
)
1196 /* Likewise with the frame pointer, if we're using one. */
1197 if (frame_pointer_needed
&& dr
== HARD_FRAME_POINTER_REGNUM
)
1200 /* If SRC had no assigned mode (i.e. we didn't know it was live)
1201 assign it now and assume the value came from an input argument
1203 if (vd
->e
[sr
].mode
== VOIDmode
)
1204 set_value_regno (sr
, vd
->e
[dr
].mode
, vd
);
1206 /* Link DR at the end of the value chain used by SR. */
1208 vd
->e
[dr
].oldest_regno
= vd
->e
[sr
].oldest_regno
;
1210 for (i
= sr
; vd
->e
[i
].next_regno
!= INVALID_REGNUM
; i
= vd
->e
[i
].next_regno
)
1212 vd
->e
[i
].next_regno
= dr
;
1214 #ifdef ENABLE_CHECKING
1215 validate_value_data (vd
);
1219 /* Return true if a mode change from ORIG to NEW is allowed for REGNO. */
1222 mode_change_ok (orig_mode
, new_mode
, regno
)
1223 enum machine_mode orig_mode
, new_mode
;
1224 unsigned int regno ATTRIBUTE_UNUSED
;
1226 if (GET_MODE_SIZE (orig_mode
) < GET_MODE_SIZE (new_mode
))
1229 #ifdef CLASS_CANNOT_CHANGE_MODE
1230 if (TEST_HARD_REG_BIT (reg_class_contents
[CLASS_CANNOT_CHANGE_MODE
], regno
)
1231 && CLASS_CANNOT_CHANGE_MODE_P (orig_mode
, new_mode
))
1238 /* Find the oldest copy of the value contained in REGNO that is in
1239 register class CLASS and has mode MODE. If found, return an rtx
1240 of that oldest register, otherwise return NULL. */
1243 find_oldest_value_reg (class, regno
, mode
, vd
)
1244 enum reg_class
class;
1246 enum machine_mode mode
;
1247 struct value_data
*vd
;
1251 for (i
= vd
->e
[regno
].oldest_regno
; i
!= regno
; i
= vd
->e
[i
].next_regno
)
1252 if (TEST_HARD_REG_BIT (reg_class_contents
[class], i
)
1253 && (vd
->e
[i
].mode
== mode
1254 || mode_change_ok (vd
->e
[i
].mode
, mode
, regno
)))
1255 return gen_rtx_REG (mode
, i
);
1260 /* If possible, replace the register at *LOC with the oldest register
1261 in register class CLASS. Return true if successfully replaced. */
1264 replace_oldest_value_reg (loc
, class, insn
, vd
)
1266 enum reg_class
class;
1268 struct value_data
*vd
;
1270 rtx
new = find_oldest_value_reg (class, REGNO (*loc
), GET_MODE (*loc
), vd
);
1274 fprintf (rtl_dump_file
, "insn %u: replaced reg %u with %u\n",
1275 INSN_UID (insn
), REGNO (*loc
), REGNO (new));
1283 /* Similar to replace_oldest_value_reg, but *LOC contains an address.
1284 Adapted from find_reloads_address_1. CLASS is INDEX_REG_CLASS or
1285 BASE_REG_CLASS depending on how the register is being considered. */
1288 replace_oldest_value_addr (loc
, class, mode
, insn
, vd
)
1290 enum reg_class
class;
1291 enum machine_mode mode
;
1293 struct value_data
*vd
;
1296 RTX_CODE code
= GET_CODE (x
);
1299 bool changed
= false;
1305 rtx orig_op0
= XEXP (x
, 0);
1306 rtx orig_op1
= XEXP (x
, 1);
1307 RTX_CODE code0
= GET_CODE (orig_op0
);
1308 RTX_CODE code1
= GET_CODE (orig_op1
);
1314 if (GET_CODE (op0
) == SUBREG
)
1316 op0
= SUBREG_REG (op0
);
1317 code0
= GET_CODE (op0
);
1320 if (GET_CODE (op1
) == SUBREG
)
1322 op1
= SUBREG_REG (op1
);
1323 code1
= GET_CODE (op1
);
1326 if (code0
== MULT
|| code0
== SIGN_EXTEND
|| code0
== TRUNCATE
1327 || code0
== ZERO_EXTEND
|| code1
== MEM
)
1329 locI
= &XEXP (x
, 0);
1330 locB
= &XEXP (x
, 1);
1332 else if (code1
== MULT
|| code1
== SIGN_EXTEND
|| code1
== TRUNCATE
1333 || code1
== ZERO_EXTEND
|| code0
== MEM
)
1335 locI
= &XEXP (x
, 1);
1336 locB
= &XEXP (x
, 0);
1338 else if (code0
== CONST_INT
|| code0
== CONST
1339 || code0
== SYMBOL_REF
|| code0
== LABEL_REF
)
1340 locB
= &XEXP (x
, 1);
1341 else if (code1
== CONST_INT
|| code1
== CONST
1342 || code1
== SYMBOL_REF
|| code1
== LABEL_REF
)
1343 locB
= &XEXP (x
, 0);
1344 else if (code0
== REG
&& code1
== REG
)
1348 if (REG_OK_FOR_INDEX_P (op0
)
1349 && REG_MODE_OK_FOR_BASE_P (op1
, mode
))
1351 else if (REG_OK_FOR_INDEX_P (op1
)
1352 && REG_MODE_OK_FOR_BASE_P (op0
, mode
))
1354 else if (REG_MODE_OK_FOR_BASE_P (op1
, mode
))
1356 else if (REG_MODE_OK_FOR_BASE_P (op0
, mode
))
1358 else if (REG_OK_FOR_INDEX_P (op1
))
1363 locI
= &XEXP (x
, index_op
);
1364 locB
= &XEXP (x
, !index_op
);
1366 else if (code0
== REG
)
1368 locI
= &XEXP (x
, 0);
1369 locB
= &XEXP (x
, 1);
1371 else if (code1
== REG
)
1373 locI
= &XEXP (x
, 1);
1374 locB
= &XEXP (x
, 0);
1378 changed
|= replace_oldest_value_addr (locI
, INDEX_REG_CLASS
, mode
,
1381 changed
|= replace_oldest_value_addr (locB
,
1382 MODE_BASE_REG_CLASS (mode
),
1396 return replace_oldest_value_mem (x
, insn
, vd
);
1399 return replace_oldest_value_reg (loc
, class, insn
, vd
);
1405 fmt
= GET_RTX_FORMAT (code
);
1406 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
1409 changed
|= replace_oldest_value_addr (&XEXP (x
, i
), class, mode
,
1411 else if (fmt
[i
] == 'E')
1412 for (j
= XVECLEN (x
, i
) - 1; j
>= 0; j
--)
1413 changed
|= replace_oldest_value_addr (&XVECEXP (x
, i
, j
), class,
1420 /* Similar to replace_oldest_value_reg, but X contains a memory. */
1423 replace_oldest_value_mem (x
, insn
, vd
)
1426 struct value_data
*vd
;
1428 return replace_oldest_value_addr (&XEXP (x
, 0),
1429 MODE_BASE_REG_CLASS (GET_MODE (x
)),
1430 GET_MODE (x
), insn
, vd
);
1433 /* Perform the forward copy propagation on basic block BB. */
1436 copyprop_hardreg_forward_1 (bb
, vd
)
1438 struct value_data
*vd
;
1440 bool changed
= false;
1443 for (insn
= bb
->head
; ; insn
= NEXT_INSN (insn
))
1445 int n_ops
, i
, alt
, predicated
;
1448 if (! INSN_P (insn
))
1450 if (insn
== bb
->end
)
1456 set
= single_set (insn
);
1457 extract_insn (insn
);
1458 constrain_operands (1);
1459 preprocess_constraints ();
1460 alt
= which_alternative
;
1461 n_ops
= recog_data
.n_operands
;
1463 /* Simplify the code below by rewriting things to reflect
1464 matching constraints. Also promote OP_OUT to OP_INOUT
1465 in predicated instructions. */
1467 predicated
= GET_CODE (PATTERN (insn
)) == COND_EXEC
;
1468 for (i
= 0; i
< n_ops
; ++i
)
1470 int matches
= recog_op_alt
[i
][alt
].matches
;
1472 recog_op_alt
[i
][alt
].class = recog_op_alt
[matches
][alt
].class;
1473 if (matches
>= 0 || recog_op_alt
[i
][alt
].matched
>= 0
1474 || (predicated
&& recog_data
.operand_type
[i
] == OP_OUT
))
1475 recog_data
.operand_type
[i
] = OP_INOUT
;
1478 /* For each earlyclobber operand, zap the value data. */
1479 for (i
= 0; i
< n_ops
; i
++)
1480 if (recog_op_alt
[i
][alt
].earlyclobber
)
1481 kill_value (recog_data
.operand
[i
], vd
);
1483 /* Within asms, a clobber cannot overlap inputs or outputs.
1484 I wouldn't think this were true for regular insns, but
1485 scan_rtx treats them like that... */
1486 note_stores (PATTERN (insn
), kill_clobbered_value
, vd
);
1488 /* Kill all auto-incremented values. */
1489 /* ??? REG_INC is useless, since stack pushes aren't done that way. */
1490 for_each_rtx (&PATTERN (insn
), kill_autoinc_value
, vd
);
1492 /* Kill all early-clobbered operands. */
1493 for (i
= 0; i
< n_ops
; i
++)
1494 if (recog_op_alt
[i
][alt
].earlyclobber
)
1495 kill_value (recog_data
.operand
[i
], vd
);
1497 /* Special-case plain move instructions, since we may well
1498 be able to do the move from a different register class. */
1499 if (set
&& REG_P (SET_SRC (set
)))
1501 unsigned int regno
= REGNO (SET_SRC (set
));
1502 enum machine_mode mode
= GET_MODE (SET_SRC (set
));
1506 /* If the destination is also a register, try to find a source
1507 register in the same class. */
1508 if (REG_P (SET_DEST (set
)))
1510 new = find_oldest_value_reg (REGNO_REG_CLASS (regno
),
1512 if (new && validate_change (insn
, &SET_SRC (set
), new, 0))
1515 fprintf (rtl_dump_file
,
1516 "insn %u: replaced reg %u with %u\n",
1517 INSN_UID (insn
), regno
, REGNO (new));
1519 goto did_replacement
;
1523 /* Otherwise, try all valid registers and see if its valid. */
1524 for (i
= vd
->e
[regno
].oldest_regno
; i
!= regno
;
1525 i
= vd
->e
[i
].next_regno
)
1526 if (mode
== vd
->e
[regno
].mode
)
1528 new = gen_rtx_REG (mode
, i
);
1529 if (validate_change (insn
, &SET_SRC (set
), new, 0))
1532 fprintf (rtl_dump_file
,
1533 "insn %u: replaced reg %u with %u\n",
1534 INSN_UID (insn
), regno
, REGNO (new));
1536 goto did_replacement
;
1541 /* For each input operand, replace a hard register with the
1542 eldest live copy that's in an appropriate register class. */
1543 for (i
= 0; i
< n_ops
; i
++)
1545 bool replaced
= false;
1547 /* Don't scan match_operand here, since we've no reg class
1548 information to pass down. Any operands that we could
1549 substitute in will be represented elsewhere. */
1550 if (recog_data
.constraints
[i
][0] == '\0')
1553 if (recog_data
.operand_type
[i
] == OP_IN
)
1555 if (recog_op_alt
[i
][alt
].is_address
)
1557 = replace_oldest_value_addr (recog_data
.operand_loc
[i
],
1558 recog_op_alt
[i
][alt
].class,
1559 VOIDmode
, insn
, vd
);
1560 else if (REG_P (recog_data
.operand
[i
]))
1562 = replace_oldest_value_reg (recog_data
.operand_loc
[i
],
1563 recog_op_alt
[i
][alt
].class,
1565 else if (GET_CODE (recog_data
.operand
[i
]) == MEM
)
1566 replaced
= replace_oldest_value_mem (recog_data
.operand
[i
],
1569 else if (GET_CODE (recog_data
.operand
[i
]) == MEM
)
1570 replaced
= replace_oldest_value_mem (recog_data
.operand
[i
],
1573 /* If we performed any replacement, update match_dups. */
1581 new = *recog_data
.operand_loc
[i
];
1582 recog_data
.operand
[i
] = new;
1583 for (j
= 0; j
< recog_data
.n_dups
; j
++)
1584 if (recog_data
.dup_num
[j
] == i
)
1585 *recog_data
.dup_loc
[j
] = new;
1590 /* Clobber call-clobbered registers. */
1591 if (GET_CODE (insn
) == CALL_INSN
)
1592 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
1593 if (TEST_HARD_REG_BIT (regs_invalidated_by_call
, i
))
1594 kill_value_regno (i
, vd
);
1596 /* Notice stores. */
1597 note_stores (PATTERN (insn
), kill_set_value
, vd
);
1599 /* Notice copies. */
1600 if (set
&& REG_P (SET_DEST (set
)) && REG_P (SET_SRC (set
)))
1601 copy_value (SET_DEST (set
), SET_SRC (set
), vd
);
1603 if (insn
== bb
->end
)
1610 /* Main entry point for the forward copy propagation optimization. */
1613 copyprop_hardreg_forward ()
1615 struct value_data
*all_vd
;
1619 need_refresh
= false;
1621 all_vd
= xmalloc (sizeof (struct value_data
) * n_basic_blocks
);
1623 for (b
= 0; b
< n_basic_blocks
; b
++)
1625 basic_block bb
= BASIC_BLOCK (b
);
1627 /* If a block has a single predecessor, that we've already
1628 processed, begin with the value data that was live at
1629 the end of the predecessor block. */
1630 /* ??? Ought to use more intelligent queueing of blocks. */
1632 && ! bb
->pred
->pred_next
1633 && ! (bb
->pred
->flags
& (EDGE_ABNORMAL_CALL
| EDGE_EH
))
1634 && bb
->pred
->src
->index
!= ENTRY_BLOCK
1635 && bb
->pred
->src
->index
< b
)
1636 all_vd
[b
] = all_vd
[bb
->pred
->src
->index
];
1638 init_value_data (all_vd
+ b
);
1640 if (copyprop_hardreg_forward_1 (bb
, all_vd
+ b
))
1641 need_refresh
= true;
1647 fputs ("\n\n", rtl_dump_file
);
1649 /* ??? Irritatingly, delete_noop_moves does not take a set of blocks
1650 to scan, so we have to do a life update with no initial set of
1651 blocks Just In Case. */
1652 delete_noop_moves (get_insns ());
1653 update_life_info (NULL
, UPDATE_LIFE_GLOBAL_RM_NOTES
,
1655 | PROP_SCAN_DEAD_CODE
1656 | PROP_KILL_DEAD_CODE
);
1662 /* Dump the value chain data to stderr. */
1665 debug_value_data (vd
)
1666 struct value_data
*vd
;
1671 CLEAR_HARD_REG_SET (set
);
1673 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; ++i
)
1674 if (vd
->e
[i
].oldest_regno
== i
)
1676 if (vd
->e
[i
].mode
== VOIDmode
)
1678 if (vd
->e
[i
].next_regno
!= INVALID_REGNUM
)
1679 fprintf (stderr
, "[%u] Bad next_regno for empty chain (%u)\n",
1680 i
, vd
->e
[i
].next_regno
);
1684 SET_HARD_REG_BIT (set
, i
);
1685 fprintf (stderr
, "[%u %s] ", i
, GET_MODE_NAME (vd
->e
[i
].mode
));
1687 for (j
= vd
->e
[i
].next_regno
;
1688 j
!= INVALID_REGNUM
;
1689 j
= vd
->e
[j
].next_regno
)
1691 if (TEST_HARD_REG_BIT (set
, vd
->e
[j
].next_regno
))
1693 fprintf (stderr
, "[%u] Loop in regno chain\n", j
);
1697 if (vd
->e
[j
].oldest_regno
!= i
)
1699 fprintf (stderr
, "[%u] Bad oldest_regno (%u)\n",
1700 j
, vd
->e
[j
].oldest_regno
);
1703 SET_HARD_REG_BIT (set
, j
);
1704 fprintf (stderr
, "[%u %s] ", j
, GET_MODE_NAME (vd
->e
[j
].mode
));
1706 fputc ('\n', stderr
);
1709 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; ++i
)
1710 if (! TEST_HARD_REG_BIT (set
, i
)
1711 && (vd
->e
[i
].mode
!= VOIDmode
1712 || vd
->e
[i
].oldest_regno
!= i
1713 || vd
->e
[i
].next_regno
!= INVALID_REGNUM
))
1714 fprintf (stderr
, "[%u] Non-empty reg in chain (%s %u %i)\n",
1715 i
, GET_MODE_NAME (vd
->e
[i
].mode
), vd
->e
[i
].oldest_regno
,
1716 vd
->e
[i
].next_regno
);
1719 #ifdef ENABLE_CHECKING
1721 validate_value_data (vd
)
1722 struct value_data
*vd
;
1727 CLEAR_HARD_REG_SET (set
);
1729 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; ++i
)
1730 if (vd
->e
[i
].oldest_regno
== i
)
1732 if (vd
->e
[i
].mode
== VOIDmode
)
1734 if (vd
->e
[i
].next_regno
!= INVALID_REGNUM
)
1735 internal_error ("validate_value_data: [%u] Bad next_regno for empty chain (%u)",
1736 i
, vd
->e
[i
].next_regno
);
1740 SET_HARD_REG_BIT (set
, i
);
1742 for (j
= vd
->e
[i
].next_regno
;
1743 j
!= INVALID_REGNUM
;
1744 j
= vd
->e
[j
].next_regno
)
1746 if (TEST_HARD_REG_BIT (set
, j
))
1747 internal_error ("validate_value_data: Loop in regno chain (%u)",
1749 if (vd
->e
[j
].oldest_regno
!= i
)
1750 internal_error ("validate_value_data: [%u] Bad oldest_regno (%u)",
1751 j
, vd
->e
[j
].oldest_regno
);
1753 SET_HARD_REG_BIT (set
, j
);
1757 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; ++i
)
1758 if (! TEST_HARD_REG_BIT (set
, i
)
1759 && (vd
->e
[i
].mode
!= VOIDmode
1760 || vd
->e
[i
].oldest_regno
!= i
1761 || vd
->e
[i
].next_regno
!= INVALID_REGNUM
))
1762 internal_error ("validate_value_data: [%u] Non-empty reg in chain (%s %u %i)",
1763 i
, GET_MODE_NAME (vd
->e
[i
].mode
), vd
->e
[i
].oldest_regno
,
1764 vd
->e
[i
].next_regno
);