1 /* Data flow analysis for GNU compiler.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 /* This file contains the data flow analysis pass of the compiler. It
23 computes data flow information which tells combine_instructions
24 which insns to consider combining and controls register allocation.
26 Additional data flow information that is too bulky to record is
27 generated during the analysis, and is used at that time to create
28 autoincrement and autodecrement addressing.
30 The first step is dividing the function into basic blocks.
31 find_basic_blocks does this. Then life_analysis determines
32 where each register is live and where it is dead.
34 ** find_basic_blocks **
36 find_basic_blocks divides the current function's rtl into basic
37 blocks and constructs the CFG. The blocks are recorded in the
38 basic_block_info array; the CFG exists in the edge structures
39 referenced by the blocks.
41 find_basic_blocks also finds any unreachable loops and deletes them.
45 life_analysis is called immediately after find_basic_blocks.
46 It uses the basic block information to determine where each
47 hard or pseudo register is live.
49 ** live-register info **
51 The information about where each register is live is in two parts:
52 the REG_NOTES of insns, and the vector basic_block->global_live_at_start.
54 basic_block->global_live_at_start has an element for each basic
55 block, and the element is a bit-vector with a bit for each hard or
56 pseudo register. The bit is 1 if the register is live at the
57 beginning of the basic block.
59 Two types of elements can be added to an insn's REG_NOTES.
60 A REG_DEAD note is added to an insn's REG_NOTES for any register
61 that meets both of two conditions: The value in the register is not
62 needed in subsequent insns and the insn does not replace the value in
63 the register (in the case of multi-word hard registers, the value in
64 each register must be replaced by the insn to avoid a REG_DEAD note).
66 In the vast majority of cases, an object in a REG_DEAD note will be
67 used somewhere in the insn. The (rare) exception to this is if an
68 insn uses a multi-word hard register and only some of the registers are
69 needed in subsequent insns. In that case, REG_DEAD notes will be
70 provided for those hard registers that are not subsequently needed.
71 Partial REG_DEAD notes of this type do not occur when an insn sets
72 only some of the hard registers used in such a multi-word operand;
73 omitting REG_DEAD notes for objects stored in an insn is optional and
74 the desire to do so does not justify the complexity of the partial
77 REG_UNUSED notes are added for each register that is set by the insn
78 but is unused subsequently (if every register set by the insn is unused
79 and the insn does not reference memory or have some other side-effect,
80 the insn is deleted instead). If only part of a multi-word hard
81 register is used in a subsequent insn, REG_UNUSED notes are made for
82 the parts that will not be used.
84 To determine which registers are live after any insn, one can
85 start from the beginning of the basic block and scan insns, noting
86 which registers are set by each insn and which die there.
88 ** Other actions of life_analysis **
90 life_analysis sets up the LOG_LINKS fields of insns because the
91 information needed to do so is readily available.
93 life_analysis deletes insns whose only effect is to store a value
96 life_analysis notices cases where a reference to a register as
97 a memory address can be combined with a preceding or following
98 incrementation or decrementation of the register. The separate
99 instruction to increment or decrement is deleted and the address
100 is changed to a POST_INC or similar rtx.
102 Each time an incrementing or decrementing address is created,
103 a REG_INC element is added to the insn's REG_NOTES list.
105 life_analysis fills in certain vectors containing information about
106 register usage: REG_N_REFS, REG_N_DEATHS, REG_N_SETS, REG_LIVE_LENGTH,
107 REG_N_CALLS_CROSSED and REG_BASIC_BLOCK.
109 life_analysis sets current_function_sp_is_unchanging if the function
110 doesn't modify the stack pointer. */
114 Split out from life_analysis:
115 - local property discovery
116 - global property computation
118 - pre/post modify transformation
123 #include "coretypes.h"
128 #include "hard-reg-set.h"
129 #include "basic-block.h"
130 #include "insn-config.h"
134 #include "function.h"
142 #include "splay-tree.h"
144 #ifndef HAVE_epilogue
145 #define HAVE_epilogue 0
147 #ifndef HAVE_prologue
148 #define HAVE_prologue 0
150 #ifndef HAVE_sibcall_epilogue
151 #define HAVE_sibcall_epilogue 0
154 #ifndef EPILOGUE_USES
155 #define EPILOGUE_USES(REGNO) 0
158 #define EH_USES(REGNO) 0
161 #ifdef HAVE_conditional_execution
162 #ifndef REVERSE_CONDEXEC_PREDICATES_P
163 #define REVERSE_CONDEXEC_PREDICATES_P(x, y) \
164 (GET_CODE ((x)) == reversed_comparison_code ((y), NULL))
168 /* This is the maximum number of times we process any given block if the
169 latest loop depth count is smaller than this number. Only used for the
170 failure strategy to avoid infinite loops in calculate_global_regs_live. */
171 #define MAX_LIVENESS_ROUNDS 20
173 /* Nonzero if the second flow pass has completed. */
176 /* Maximum register number used in this function, plus one. */
180 /* Indexed by n, giving various register information */
182 varray_type reg_n_info
;
184 /* Regset of regs live when calls to `setjmp'-like functions happen. */
185 /* ??? Does this exist only for the setjmp-clobbered warning message? */
187 static regset regs_live_at_setjmp
;
189 /* List made of EXPR_LIST rtx's which gives pairs of pseudo registers
190 that have to go in the same hard reg.
191 The first two regs in the list are a pair, and the next two
192 are another pair, etc. */
195 /* Set of registers that may be eliminable. These are handled specially
196 in updating regs_ever_live. */
198 static HARD_REG_SET elim_reg_set
;
200 /* Holds information for tracking conditional register life information. */
201 struct reg_cond_life_info
203 /* A boolean expression of conditions under which a register is dead. */
205 /* Conditions under which a register is dead at the basic block end. */
208 /* A boolean expression of conditions under which a register has been
212 /* ??? Could store mask of bytes that are dead, so that we could finally
213 track lifetimes of multi-word registers accessed via subregs. */
216 /* For use in communicating between propagate_block and its subroutines.
217 Holds all information needed to compute life and def-use information. */
219 struct propagate_block_info
221 /* The basic block we're considering. */
224 /* Bit N is set if register N is conditionally or unconditionally live. */
227 /* Bit N is set if register N is set this insn. */
230 /* Element N is the next insn that uses (hard or pseudo) register N
231 within the current basic block; or zero, if there is no such insn. */
234 /* Contains a list of all the MEMs we are tracking for dead store
238 /* If non-null, record the set of registers set unconditionally in the
242 /* If non-null, record the set of registers set conditionally in the
244 regset cond_local_set
;
246 #ifdef HAVE_conditional_execution
247 /* Indexed by register number, holds a reg_cond_life_info for each
248 register that is not unconditionally live or dead. */
249 splay_tree reg_cond_dead
;
251 /* Bit N is set if register N is in an expression in reg_cond_dead. */
255 /* The length of mem_set_list. */
256 int mem_set_list_len
;
258 /* Nonzero if the value of CC0 is live. */
261 /* Flags controlling the set of information propagate_block collects. */
263 /* Index of instruction being processed. */
267 /* Number of dead insns removed. */
270 /* When PROP_REG_INFO set, array contains pbi->insn_num of instruction
271 where given register died. When the register is marked alive, we use the
272 information to compute amount of instructions life range cross.
273 (remember, we are walking backward). This can be computed as current
274 pbi->insn_num - reg_deaths[regno].
275 At the end of processing each basic block, the remaining live registers
276 are inspected and live ranges are increased same way so liverange of global
277 registers are computed correctly.
279 The array is maintained clear for dead registers, so it can be safely reused
280 for next basic block without expensive memset of the whole array after
281 reseting pbi->insn_num to 0. */
283 static int *reg_deaths
;
285 /* Maximum length of pbi->mem_set_list before we start dropping
286 new elements on the floor. */
287 #define MAX_MEM_SET_LIST_LEN 100
289 /* Forward declarations */
290 static int verify_wide_reg_1 (rtx
*, void *);
291 static void verify_wide_reg (int, basic_block
);
292 static void verify_local_live_at_start (regset
, basic_block
);
293 static void notice_stack_pointer_modification_1 (rtx
, rtx
, void *);
294 static void notice_stack_pointer_modification (void);
295 static void mark_reg (rtx
, void *);
296 static void mark_regs_live_at_end (regset
);
297 static void calculate_global_regs_live (sbitmap
, sbitmap
, int);
298 static void propagate_block_delete_insn (rtx
);
299 static rtx
propagate_block_delete_libcall (rtx
, rtx
);
300 static int insn_dead_p (struct propagate_block_info
*, rtx
, int, rtx
);
301 static int libcall_dead_p (struct propagate_block_info
*, rtx
, rtx
);
302 static void mark_set_regs (struct propagate_block_info
*, rtx
, rtx
);
303 static void mark_set_1 (struct propagate_block_info
*, enum rtx_code
, rtx
,
305 static int find_regno_partial (rtx
*, void *);
307 #ifdef HAVE_conditional_execution
308 static int mark_regno_cond_dead (struct propagate_block_info
*, int, rtx
);
309 static void free_reg_cond_life_info (splay_tree_value
);
310 static int flush_reg_cond_reg_1 (splay_tree_node
, void *);
311 static void flush_reg_cond_reg (struct propagate_block_info
*, int);
312 static rtx
elim_reg_cond (rtx
, unsigned int);
313 static rtx
ior_reg_cond (rtx
, rtx
, int);
314 static rtx
not_reg_cond (rtx
);
315 static rtx
and_reg_cond (rtx
, rtx
, int);
318 static void attempt_auto_inc (struct propagate_block_info
*, rtx
, rtx
, rtx
,
320 static void find_auto_inc (struct propagate_block_info
*, rtx
, rtx
);
321 static int try_pre_increment_1 (struct propagate_block_info
*, rtx
);
322 static int try_pre_increment (rtx
, rtx
, HOST_WIDE_INT
);
324 static void mark_used_reg (struct propagate_block_info
*, rtx
, rtx
, rtx
);
325 static void mark_used_regs (struct propagate_block_info
*, rtx
, rtx
, rtx
);
326 void debug_flow_info (void);
327 static void add_to_mem_set_list (struct propagate_block_info
*, rtx
);
328 static int invalidate_mems_from_autoinc (rtx
*, void *);
329 static void invalidate_mems_from_set (struct propagate_block_info
*, rtx
);
330 static void clear_log_links (sbitmap
);
331 static int count_or_remove_death_notes_bb (basic_block
, int);
332 static void allocate_bb_life_data (void);
334 /* Return the INSN immediately following the NOTE_INSN_BASIC_BLOCK
335 note associated with the BLOCK. */
338 first_insn_after_basic_block_note (basic_block block
)
342 /* Get the first instruction in the block. */
343 insn
= BB_HEAD (block
);
345 if (insn
== NULL_RTX
)
348 insn
= NEXT_INSN (insn
);
349 gcc_assert (NOTE_INSN_BASIC_BLOCK_P (insn
));
351 return NEXT_INSN (insn
);
354 /* Perform data flow analysis for the whole control flow graph.
355 FLAGS is a set of PROP_* flags to be used in accumulating flow info. */
358 life_analysis (FILE *file
, int flags
)
360 #ifdef ELIMINABLE_REGS
362 static const struct {const int from
, to
; } eliminables
[] = ELIMINABLE_REGS
;
365 /* Record which registers will be eliminated. We use this in
368 CLEAR_HARD_REG_SET (elim_reg_set
);
370 #ifdef ELIMINABLE_REGS
371 for (i
= 0; i
< (int) ARRAY_SIZE (eliminables
); i
++)
372 SET_HARD_REG_BIT (elim_reg_set
, eliminables
[i
].from
);
374 SET_HARD_REG_BIT (elim_reg_set
, FRAME_POINTER_REGNUM
);
378 #ifdef CANNOT_CHANGE_MODE_CLASS
379 if (flags
& PROP_REG_INFO
)
380 init_subregs_of_mode ();
384 flags
&= ~(PROP_LOG_LINKS
| PROP_AUTOINC
| PROP_ALLOW_CFG_CHANGES
);
386 /* The post-reload life analysis have (on a global basis) the same
387 registers live as was computed by reload itself. elimination
388 Otherwise offsets and such may be incorrect.
390 Reload will make some registers as live even though they do not
393 We don't want to create new auto-incs after reload, since they
394 are unlikely to be useful and can cause problems with shared
396 if (reload_completed
)
397 flags
&= ~(PROP_REG_INFO
| PROP_AUTOINC
);
399 /* We want alias analysis information for local dead store elimination. */
400 if (optimize
&& (flags
& PROP_SCAN_DEAD_STORES
))
401 init_alias_analysis ();
403 /* Always remove no-op moves. Do this before other processing so
404 that we don't have to keep re-scanning them. */
405 delete_noop_moves ();
407 /* Some targets can emit simpler epilogues if they know that sp was
408 not ever modified during the function. After reload, of course,
409 we've already emitted the epilogue so there's no sense searching. */
410 if (! reload_completed
)
411 notice_stack_pointer_modification ();
413 /* Allocate and zero out data structures that will record the
414 data from lifetime analysis. */
415 allocate_reg_life_data ();
416 allocate_bb_life_data ();
418 /* Find the set of registers live on function exit. */
419 mark_regs_live_at_end (EXIT_BLOCK_PTR
->global_live_at_start
);
421 /* "Update" life info from zero. It'd be nice to begin the
422 relaxation with just the exit and noreturn blocks, but that set
423 is not immediately handy. */
425 if (flags
& PROP_REG_INFO
)
427 memset (regs_ever_live
, 0, sizeof (regs_ever_live
));
428 memset (regs_asm_clobbered
, 0, sizeof (regs_asm_clobbered
));
430 update_life_info (NULL
, UPDATE_LIFE_GLOBAL
, flags
);
438 if (optimize
&& (flags
& PROP_SCAN_DEAD_STORES
))
439 end_alias_analysis ();
442 dump_flow_info (file
);
444 /* Removing dead insns should have made jumptables really dead. */
445 delete_dead_jumptables ();
448 /* A subroutine of verify_wide_reg, called through for_each_rtx.
449 Search for REGNO. If found, return 2 if it is not wider than
453 verify_wide_reg_1 (rtx
*px
, void *pregno
)
456 unsigned int regno
= *(int *) pregno
;
458 if (REG_P (x
) && REGNO (x
) == regno
)
460 if (GET_MODE_BITSIZE (GET_MODE (x
)) <= BITS_PER_WORD
)
467 /* A subroutine of verify_local_live_at_start. Search through insns
468 of BB looking for register REGNO. */
471 verify_wide_reg (int regno
, basic_block bb
)
473 rtx head
= BB_HEAD (bb
), end
= BB_END (bb
);
479 int r
= for_each_rtx (&PATTERN (head
), verify_wide_reg_1
, ®no
);
487 head
= NEXT_INSN (head
);
491 fprintf (dump_file
, "Register %d died unexpectedly.\n", regno
);
492 dump_bb (bb
, dump_file
, 0);
494 fatal_error ("internal consistency failure");
497 /* A subroutine of update_life_info. Verify that there are no untoward
498 changes in live_at_start during a local update. */
501 verify_local_live_at_start (regset new_live_at_start
, basic_block bb
)
503 if (reload_completed
)
505 /* After reload, there are no pseudos, nor subregs of multi-word
506 registers. The regsets should exactly match. */
507 if (! REG_SET_EQUAL_P (new_live_at_start
, bb
->global_live_at_start
))
512 "live_at_start mismatch in bb %d, aborting\nNew:\n",
514 debug_bitmap_file (dump_file
, new_live_at_start
);
515 fputs ("Old:\n", dump_file
);
516 dump_bb (bb
, dump_file
, 0);
518 fatal_error ("internal consistency failure");
524 reg_set_iterator rsi
;
526 /* Find the set of changed registers. */
527 XOR_REG_SET (new_live_at_start
, bb
->global_live_at_start
);
529 EXECUTE_IF_SET_IN_REG_SET (new_live_at_start
, 0, i
, rsi
)
531 /* No registers should die. */
532 if (REGNO_REG_SET_P (bb
->global_live_at_start
, i
))
537 "Register %d died unexpectedly.\n", i
);
538 dump_bb (bb
, dump_file
, 0);
540 fatal_error ("internal consistency failure");
542 /* Verify that the now-live register is wider than word_mode. */
543 verify_wide_reg (i
, bb
);
548 /* Updates life information starting with the basic blocks set in BLOCKS.
549 If BLOCKS is null, consider it to be the universal set.
551 If EXTENT is UPDATE_LIFE_LOCAL, such as after splitting or peepholing,
552 we are only expecting local modifications to basic blocks. If we find
553 extra registers live at the beginning of a block, then we either killed
554 useful data, or we have a broken split that wants data not provided.
555 If we find registers removed from live_at_start, that means we have
556 a broken peephole that is killing a register it shouldn't.
558 ??? This is not true in one situation -- when a pre-reload splitter
559 generates subregs of a multi-word pseudo, current life analysis will
560 lose the kill. So we _can_ have a pseudo go live. How irritating.
562 It is also not true when a peephole decides that it doesn't need one
563 or more of the inputs.
565 Including PROP_REG_INFO does not properly refresh regs_ever_live
566 unless the caller resets it to zero. */
569 update_life_info (sbitmap blocks
, enum update_life_extent extent
,
574 int stabilized_prop_flags
= prop_flags
;
577 tmp
= ALLOC_REG_SET (®_obstack
);
580 if ((prop_flags
& PROP_REG_INFO
) && !reg_deaths
)
581 reg_deaths
= xcalloc (sizeof (*reg_deaths
), max_regno
);
583 timevar_push ((extent
== UPDATE_LIFE_LOCAL
|| blocks
)
584 ? TV_LIFE_UPDATE
: TV_LIFE
);
586 /* Changes to the CFG are only allowed when
587 doing a global update for the entire CFG. */
588 gcc_assert (!(prop_flags
& PROP_ALLOW_CFG_CHANGES
)
589 || (extent
!= UPDATE_LIFE_LOCAL
&& !blocks
));
591 /* For a global update, we go through the relaxation process again. */
592 if (extent
!= UPDATE_LIFE_LOCAL
)
598 calculate_global_regs_live (blocks
, blocks
,
599 prop_flags
& (PROP_SCAN_DEAD_CODE
600 | PROP_SCAN_DEAD_STORES
601 | PROP_ALLOW_CFG_CHANGES
));
603 if ((prop_flags
& (PROP_KILL_DEAD_CODE
| PROP_ALLOW_CFG_CHANGES
))
604 != (PROP_KILL_DEAD_CODE
| PROP_ALLOW_CFG_CHANGES
))
607 /* Removing dead code may allow the CFG to be simplified which
608 in turn may allow for further dead code detection / removal. */
609 FOR_EACH_BB_REVERSE (bb
)
611 COPY_REG_SET (tmp
, bb
->global_live_at_end
);
612 changed
|= propagate_block (bb
, tmp
, NULL
, NULL
,
613 prop_flags
& (PROP_SCAN_DEAD_CODE
614 | PROP_SCAN_DEAD_STORES
615 | PROP_KILL_DEAD_CODE
));
618 /* Don't pass PROP_SCAN_DEAD_CODE or PROP_KILL_DEAD_CODE to
619 subsequent propagate_block calls, since removing or acting as
620 removing dead code can affect global register liveness, which
621 is supposed to be finalized for this call after this loop. */
622 stabilized_prop_flags
623 &= ~(PROP_SCAN_DEAD_CODE
| PROP_SCAN_DEAD_STORES
624 | PROP_KILL_DEAD_CODE
);
629 /* We repeat regardless of what cleanup_cfg says. If there were
630 instructions deleted above, that might have been only a
631 partial improvement (see MAX_MEM_SET_LIST_LEN usage).
632 Further improvement may be possible. */
633 cleanup_cfg (CLEANUP_EXPENSIVE
);
635 /* Zap the life information from the last round. If we don't
636 do this, we can wind up with registers that no longer appear
637 in the code being marked live at entry. */
640 CLEAR_REG_SET (bb
->global_live_at_start
);
641 CLEAR_REG_SET (bb
->global_live_at_end
);
645 /* If asked, remove notes from the blocks we'll update. */
646 if (extent
== UPDATE_LIFE_GLOBAL_RM_NOTES
)
647 count_or_remove_death_notes (blocks
, 1);
650 /* Clear log links in case we are asked to (re)compute them. */
651 if (prop_flags
& PROP_LOG_LINKS
)
652 clear_log_links (blocks
);
656 sbitmap_iterator sbi
;
658 EXECUTE_IF_SET_IN_SBITMAP (blocks
, 0, i
, sbi
)
660 bb
= BASIC_BLOCK (i
);
662 COPY_REG_SET (tmp
, bb
->global_live_at_end
);
663 propagate_block (bb
, tmp
, NULL
, NULL
, stabilized_prop_flags
);
665 if (extent
== UPDATE_LIFE_LOCAL
)
666 verify_local_live_at_start (tmp
, bb
);
671 FOR_EACH_BB_REVERSE (bb
)
673 COPY_REG_SET (tmp
, bb
->global_live_at_end
);
675 propagate_block (bb
, tmp
, NULL
, NULL
, stabilized_prop_flags
);
677 if (extent
== UPDATE_LIFE_LOCAL
)
678 verify_local_live_at_start (tmp
, bb
);
684 if (prop_flags
& PROP_REG_INFO
)
686 reg_set_iterator rsi
;
688 /* The only pseudos that are live at the beginning of the function
689 are those that were not set anywhere in the function. local-alloc
690 doesn't know how to handle these correctly, so mark them as not
691 local to any one basic block. */
692 EXECUTE_IF_SET_IN_REG_SET (ENTRY_BLOCK_PTR
->global_live_at_end
,
693 FIRST_PSEUDO_REGISTER
, i
, rsi
)
694 REG_BASIC_BLOCK (i
) = REG_BLOCK_GLOBAL
;
696 /* We have a problem with any pseudoreg that lives across the setjmp.
697 ANSI says that if a user variable does not change in value between
698 the setjmp and the longjmp, then the longjmp preserves it. This
699 includes longjmp from a place where the pseudo appears dead.
700 (In principle, the value still exists if it is in scope.)
701 If the pseudo goes in a hard reg, some other value may occupy
702 that hard reg where this pseudo is dead, thus clobbering the pseudo.
703 Conclusion: such a pseudo must not go in a hard reg. */
704 EXECUTE_IF_SET_IN_REG_SET (regs_live_at_setjmp
,
705 FIRST_PSEUDO_REGISTER
, i
, rsi
)
707 if (regno_reg_rtx
[i
] != 0)
709 REG_LIVE_LENGTH (i
) = -1;
710 REG_BASIC_BLOCK (i
) = REG_BLOCK_UNKNOWN
;
719 timevar_pop ((extent
== UPDATE_LIFE_LOCAL
|| blocks
)
720 ? TV_LIFE_UPDATE
: TV_LIFE
);
721 if (ndead
&& dump_file
)
722 fprintf (dump_file
, "deleted %i dead insns\n", ndead
);
726 /* Update life information in all blocks where BB_DIRTY is set. */
729 update_life_info_in_dirty_blocks (enum update_life_extent extent
, int prop_flags
)
731 sbitmap update_life_blocks
= sbitmap_alloc (last_basic_block
);
736 sbitmap_zero (update_life_blocks
);
739 if (bb
->flags
& BB_DIRTY
)
741 SET_BIT (update_life_blocks
, bb
->index
);
747 retval
= update_life_info (update_life_blocks
, extent
, prop_flags
);
749 sbitmap_free (update_life_blocks
);
753 /* Free the variables allocated by find_basic_blocks. */
756 free_basic_block_vars (void)
758 if (basic_block_info
)
761 basic_block_info
= NULL
;
764 last_basic_block
= 0;
767 label_to_block_map
= NULL
;
769 ENTRY_BLOCK_PTR
->aux
= NULL
;
770 ENTRY_BLOCK_PTR
->global_live_at_end
= NULL
;
771 EXIT_BLOCK_PTR
->aux
= NULL
;
772 EXIT_BLOCK_PTR
->global_live_at_start
= NULL
;
775 /* Delete any insns that copy a register to itself. */
778 delete_noop_moves (void)
786 for (insn
= BB_HEAD (bb
); insn
!= NEXT_INSN (BB_END (bb
)); insn
= next
)
788 next
= NEXT_INSN (insn
);
789 if (INSN_P (insn
) && noop_move_p (insn
))
793 /* If we're about to remove the first insn of a libcall
794 then move the libcall note to the next real insn and
795 update the retval note. */
796 if ((note
= find_reg_note (insn
, REG_LIBCALL
, NULL_RTX
))
797 && XEXP (note
, 0) != insn
)
799 rtx new_libcall_insn
= next_real_insn (insn
);
800 rtx retval_note
= find_reg_note (XEXP (note
, 0),
801 REG_RETVAL
, NULL_RTX
);
802 REG_NOTES (new_libcall_insn
)
803 = gen_rtx_INSN_LIST (REG_LIBCALL
, XEXP (note
, 0),
804 REG_NOTES (new_libcall_insn
));
805 XEXP (retval_note
, 0) = new_libcall_insn
;
808 delete_insn_and_edges (insn
);
813 if (nnoops
&& dump_file
)
814 fprintf (dump_file
, "deleted %i noop moves", nnoops
);
818 /* Delete any jump tables never referenced. We can't delete them at the
819 time of removing tablejump insn as they are referenced by the preceding
820 insns computing the destination, so we delay deleting and garbagecollect
821 them once life information is computed. */
823 delete_dead_jumptables (void)
827 /* A dead jump table does not belong to any basic block. Scan insns
828 between two adjacent basic blocks. */
833 for (insn
= NEXT_INSN (BB_END (bb
));
834 insn
&& !NOTE_INSN_BASIC_BLOCK_P (insn
);
837 next
= NEXT_INSN (insn
);
839 && LABEL_NUSES (insn
) == LABEL_PRESERVE_P (insn
)
841 && (GET_CODE (PATTERN (next
)) == ADDR_VEC
842 || GET_CODE (PATTERN (next
)) == ADDR_DIFF_VEC
))
844 rtx label
= insn
, jump
= next
;
847 fprintf (dump_file
, "Dead jumptable %i removed\n",
850 next
= NEXT_INSN (next
);
858 /* Determine if the stack pointer is constant over the life of the function.
859 Only useful before prologues have been emitted. */
862 notice_stack_pointer_modification_1 (rtx x
, rtx pat ATTRIBUTE_UNUSED
,
863 void *data ATTRIBUTE_UNUSED
)
865 if (x
== stack_pointer_rtx
866 /* The stack pointer is only modified indirectly as the result
867 of a push until later in flow. See the comments in rtl.texi
868 regarding Embedded Side-Effects on Addresses. */
870 && GET_RTX_CLASS (GET_CODE (XEXP (x
, 0))) == RTX_AUTOINC
871 && XEXP (XEXP (x
, 0), 0) == stack_pointer_rtx
))
872 current_function_sp_is_unchanging
= 0;
876 notice_stack_pointer_modification (void)
881 /* Assume that the stack pointer is unchanging if alloca hasn't
883 current_function_sp_is_unchanging
= !current_function_calls_alloca
;
884 if (! current_function_sp_is_unchanging
)
888 FOR_BB_INSNS (bb
, insn
)
892 /* Check if insn modifies the stack pointer. */
893 note_stores (PATTERN (insn
),
894 notice_stack_pointer_modification_1
,
896 if (! current_function_sp_is_unchanging
)
902 /* Mark a register in SET. Hard registers in large modes get all
903 of their component registers set as well. */
906 mark_reg (rtx reg
, void *xset
)
908 regset set
= (regset
) xset
;
909 int regno
= REGNO (reg
);
911 gcc_assert (GET_MODE (reg
) != BLKmode
);
913 SET_REGNO_REG_SET (set
, regno
);
914 if (regno
< FIRST_PSEUDO_REGISTER
)
916 int n
= hard_regno_nregs
[regno
][GET_MODE (reg
)];
918 SET_REGNO_REG_SET (set
, regno
+ n
);
922 /* Mark those regs which are needed at the end of the function as live
923 at the end of the last basic block. */
926 mark_regs_live_at_end (regset set
)
930 /* If exiting needs the right stack value, consider the stack pointer
931 live at the end of the function. */
932 if ((HAVE_epilogue
&& epilogue_completed
)
933 || ! EXIT_IGNORE_STACK
934 || (! FRAME_POINTER_REQUIRED
935 && ! current_function_calls_alloca
936 && flag_omit_frame_pointer
)
937 || current_function_sp_is_unchanging
)
939 SET_REGNO_REG_SET (set
, STACK_POINTER_REGNUM
);
942 /* Mark the frame pointer if needed at the end of the function. If
943 we end up eliminating it, it will be removed from the live list
944 of each basic block by reload. */
946 if (! reload_completed
|| frame_pointer_needed
)
948 SET_REGNO_REG_SET (set
, FRAME_POINTER_REGNUM
);
949 #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
950 /* If they are different, also mark the hard frame pointer as live. */
951 if (! LOCAL_REGNO (HARD_FRAME_POINTER_REGNUM
))
952 SET_REGNO_REG_SET (set
, HARD_FRAME_POINTER_REGNUM
);
956 #ifndef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
957 /* Many architectures have a GP register even without flag_pic.
958 Assume the pic register is not in use, or will be handled by
959 other means, if it is not fixed. */
960 if ((unsigned) PIC_OFFSET_TABLE_REGNUM
!= INVALID_REGNUM
961 && fixed_regs
[PIC_OFFSET_TABLE_REGNUM
])
962 SET_REGNO_REG_SET (set
, PIC_OFFSET_TABLE_REGNUM
);
965 /* Mark all global registers, and all registers used by the epilogue
966 as being live at the end of the function since they may be
967 referenced by our caller. */
968 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
969 if (global_regs
[i
] || EPILOGUE_USES (i
))
970 SET_REGNO_REG_SET (set
, i
);
972 if (HAVE_epilogue
&& epilogue_completed
)
974 /* Mark all call-saved registers that we actually used. */
975 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
976 if (regs_ever_live
[i
] && ! LOCAL_REGNO (i
)
977 && ! TEST_HARD_REG_BIT (regs_invalidated_by_call
, i
))
978 SET_REGNO_REG_SET (set
, i
);
981 #ifdef EH_RETURN_DATA_REGNO
982 /* Mark the registers that will contain data for the handler. */
983 if (reload_completed
&& current_function_calls_eh_return
)
986 unsigned regno
= EH_RETURN_DATA_REGNO(i
);
987 if (regno
== INVALID_REGNUM
)
989 SET_REGNO_REG_SET (set
, regno
);
992 #ifdef EH_RETURN_STACKADJ_RTX
993 if ((! HAVE_epilogue
|| ! epilogue_completed
)
994 && current_function_calls_eh_return
)
996 rtx tmp
= EH_RETURN_STACKADJ_RTX
;
997 if (tmp
&& REG_P (tmp
))
1001 #ifdef EH_RETURN_HANDLER_RTX
1002 if ((! HAVE_epilogue
|| ! epilogue_completed
)
1003 && current_function_calls_eh_return
)
1005 rtx tmp
= EH_RETURN_HANDLER_RTX
;
1006 if (tmp
&& REG_P (tmp
))
1007 mark_reg (tmp
, set
);
1011 /* Mark function return value. */
1012 diddle_return_value (mark_reg
, set
);
1015 /* Propagate global life info around the graph of basic blocks. Begin
1016 considering blocks with their corresponding bit set in BLOCKS_IN.
1017 If BLOCKS_IN is null, consider it the universal set.
1019 BLOCKS_OUT is set for every block that was changed. */
1022 calculate_global_regs_live (sbitmap blocks_in
, sbitmap blocks_out
, int flags
)
1024 basic_block
*queue
, *qhead
, *qtail
, *qend
, bb
;
1025 regset tmp
, new_live_at_end
, invalidated_by_call
;
1026 regset registers_made_dead
;
1027 bool failure_strategy_required
= false;
1028 int *block_accesses
;
1030 /* The registers that are modified within this in block. */
1033 /* The registers that are conditionally modified within this block.
1034 In other words, regs that are set only as part of a COND_EXEC. */
1035 regset
*cond_local_sets
;
1039 /* Some passes used to forget clear aux field of basic block causing
1040 sick behavior here. */
1041 #ifdef ENABLE_CHECKING
1042 FOR_BB_BETWEEN (bb
, ENTRY_BLOCK_PTR
, NULL
, next_bb
)
1043 gcc_assert (!bb
->aux
);
1046 tmp
= ALLOC_REG_SET (®_obstack
);
1047 new_live_at_end
= ALLOC_REG_SET (®_obstack
);
1048 invalidated_by_call
= ALLOC_REG_SET (®_obstack
);
1049 registers_made_dead
= ALLOC_REG_SET (®_obstack
);
1051 /* Inconveniently, this is only readily available in hard reg set form. */
1052 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; ++i
)
1053 if (TEST_HARD_REG_BIT (regs_invalidated_by_call
, i
))
1054 SET_REGNO_REG_SET (invalidated_by_call
, i
);
1056 /* Allocate space for the sets of local properties. */
1057 local_sets
= xcalloc (last_basic_block
- (INVALID_BLOCK
+ 1),
1059 cond_local_sets
= xcalloc (last_basic_block
- (INVALID_BLOCK
+ 1),
1062 /* Create a worklist. Allocate an extra slot for ENTRY_BLOCK, and one
1063 because the `head == tail' style test for an empty queue doesn't
1064 work with a full queue. */
1065 queue
= xmalloc ((n_basic_blocks
- (INVALID_BLOCK
+ 1)) * sizeof (*queue
));
1067 qhead
= qend
= queue
+ n_basic_blocks
- (INVALID_BLOCK
+ 1);
1069 /* Queue the blocks set in the initial mask. Do this in reverse block
1070 number order so that we are more likely for the first round to do
1071 useful work. We use AUX non-null to flag that the block is queued. */
1075 if (TEST_BIT (blocks_in
, bb
->index
))
1090 block_accesses
= xcalloc (last_basic_block
, sizeof (int));
1092 /* We clean aux when we remove the initially-enqueued bbs, but we
1093 don't enqueue ENTRY and EXIT initially, so clean them upfront and
1095 ENTRY_BLOCK_PTR
->aux
= EXIT_BLOCK_PTR
->aux
= NULL
;
1098 sbitmap_zero (blocks_out
);
1100 /* We work through the queue until there are no more blocks. What
1101 is live at the end of this block is precisely the union of what
1102 is live at the beginning of all its successors. So, we set its
1103 GLOBAL_LIVE_AT_END field based on the GLOBAL_LIVE_AT_START field
1104 for its successors. Then, we compute GLOBAL_LIVE_AT_START for
1105 this block by walking through the instructions in this block in
1106 reverse order and updating as we go. If that changed
1107 GLOBAL_LIVE_AT_START, we add the predecessors of the block to the
1108 queue; they will now need to recalculate GLOBAL_LIVE_AT_END.
1110 We are guaranteed to terminate, because GLOBAL_LIVE_AT_START
1111 never shrinks. If a register appears in GLOBAL_LIVE_AT_START, it
1112 must either be live at the end of the block, or used within the
1113 block. In the latter case, it will certainly never disappear
1114 from GLOBAL_LIVE_AT_START. In the former case, the register
1115 could go away only if it disappeared from GLOBAL_LIVE_AT_START
1116 for one of the successor blocks. By induction, that cannot
1119 ??? This reasoning doesn't work if we start from non-empty initial
1120 GLOBAL_LIVE_AT_START sets. And there are actually two problems:
1121 1) Updating may not terminate (endless oscillation).
1122 2) Even if it does (and it usually does), the resulting information
1123 may be inaccurate. Consider for example the following case:
1126 while (...) {...} -- 'a' not mentioned at all
1129 If the use of 'a' is deleted between two calculations of liveness
1130 information and the initial sets are not cleared, the information
1131 about a's liveness will get stuck inside the loop and the set will
1132 appear not to be dead.
1134 We do not attempt to solve 2) -- the information is conservatively
1135 correct (i.e. we never claim that something live is dead) and the
1136 amount of optimization opportunities missed due to this problem is
1139 1) is more serious. In order to fix it, we monitor the number of times
1140 each block is processed. Once one of the blocks has been processed more
1141 times than the maximum number of rounds, we use the following strategy:
1142 When a register disappears from one of the sets, we add it to a MAKE_DEAD
1143 set, remove all registers in this set from all GLOBAL_LIVE_AT_* sets and
1144 add the blocks with changed sets into the queue. Thus we are guaranteed
1145 to terminate (the worst case corresponds to all registers in MADE_DEAD,
1146 in which case the original reasoning above is valid), but in general we
1147 only fix up a few offending registers.
1149 The maximum number of rounds for computing liveness is the largest of
1150 MAX_LIVENESS_ROUNDS and the latest loop depth count for this function. */
1152 while (qhead
!= qtail
)
1154 int rescan
, changed
;
1164 /* Should we start using the failure strategy? */
1165 if (bb
!= ENTRY_BLOCK_PTR
)
1167 int max_liveness_rounds
=
1168 MAX (MAX_LIVENESS_ROUNDS
, cfun
->max_loop_depth
);
1170 block_accesses
[bb
->index
]++;
1171 if (block_accesses
[bb
->index
] > max_liveness_rounds
)
1172 failure_strategy_required
= true;
1175 /* Begin by propagating live_at_start from the successor blocks. */
1176 CLEAR_REG_SET (new_live_at_end
);
1178 if (EDGE_COUNT (bb
->succs
) > 0)
1179 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
1181 basic_block sb
= e
->dest
;
1183 /* Call-clobbered registers die across exception and
1185 /* ??? Abnormal call edges ignored for the moment, as this gets
1186 confused by sibling call edges, which crashes reg-stack. */
1187 if (e
->flags
& EDGE_EH
)
1188 bitmap_ior_and_compl_into (new_live_at_end
,
1189 sb
->global_live_at_start
,
1190 invalidated_by_call
);
1192 IOR_REG_SET (new_live_at_end
, sb
->global_live_at_start
);
1194 /* If a target saves one register in another (instead of on
1195 the stack) the save register will need to be live for EH. */
1196 if (e
->flags
& EDGE_EH
)
1197 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
1199 SET_REGNO_REG_SET (new_live_at_end
, i
);
1203 /* This might be a noreturn function that throws. And
1204 even if it isn't, getting the unwind info right helps
1206 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
1208 SET_REGNO_REG_SET (new_live_at_end
, i
);
1211 /* The all-important stack pointer must always be live. */
1212 SET_REGNO_REG_SET (new_live_at_end
, STACK_POINTER_REGNUM
);
1214 /* Before reload, there are a few registers that must be forced
1215 live everywhere -- which might not already be the case for
1216 blocks within infinite loops. */
1217 if (! reload_completed
)
1219 /* Any reference to any pseudo before reload is a potential
1220 reference of the frame pointer. */
1221 SET_REGNO_REG_SET (new_live_at_end
, FRAME_POINTER_REGNUM
);
1223 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
1224 /* Pseudos with argument area equivalences may require
1225 reloading via the argument pointer. */
1226 if (fixed_regs
[ARG_POINTER_REGNUM
])
1227 SET_REGNO_REG_SET (new_live_at_end
, ARG_POINTER_REGNUM
);
1230 /* Any constant, or pseudo with constant equivalences, may
1231 require reloading from memory using the pic register. */
1232 if ((unsigned) PIC_OFFSET_TABLE_REGNUM
!= INVALID_REGNUM
1233 && fixed_regs
[PIC_OFFSET_TABLE_REGNUM
])
1234 SET_REGNO_REG_SET (new_live_at_end
, PIC_OFFSET_TABLE_REGNUM
);
1237 if (bb
== ENTRY_BLOCK_PTR
)
1239 COPY_REG_SET (bb
->global_live_at_end
, new_live_at_end
);
1243 /* On our first pass through this block, we'll go ahead and continue.
1244 Recognize first pass by checking if local_set is NULL for this
1245 basic block. On subsequent passes, we get to skip out early if
1246 live_at_end wouldn't have changed. */
1248 if (local_sets
[bb
->index
- (INVALID_BLOCK
+ 1)] == NULL
)
1250 local_sets
[bb
->index
- (INVALID_BLOCK
+ 1)]
1251 = ALLOC_REG_SET (®_obstack
);
1252 cond_local_sets
[bb
->index
- (INVALID_BLOCK
+ 1)]
1253 = ALLOC_REG_SET (®_obstack
);
1258 /* If any bits were removed from live_at_end, we'll have to
1259 rescan the block. This wouldn't be necessary if we had
1260 precalculated local_live, however with PROP_SCAN_DEAD_CODE
1261 local_live is really dependent on live_at_end. */
1262 rescan
= bitmap_intersect_compl_p (bb
->global_live_at_end
,
1267 regset cond_local_set
;
1269 /* If any of the registers in the new live_at_end set are
1270 conditionally set in this basic block, we must rescan.
1271 This is because conditional lifetimes at the end of the
1272 block do not just take the live_at_end set into
1273 account, but also the liveness at the start of each
1274 successor block. We can miss changes in those sets if
1275 we only compare the new live_at_end against the
1277 cond_local_set
= cond_local_sets
[bb
->index
- (INVALID_BLOCK
+ 1)];
1278 rescan
= bitmap_intersect_p (new_live_at_end
, cond_local_set
);
1285 /* Find the set of changed bits. Take this opportunity
1286 to notice that this set is empty and early out. */
1287 bitmap_xor (tmp
, bb
->global_live_at_end
, new_live_at_end
);
1288 if (bitmap_empty_p (tmp
))
1291 /* If any of the changed bits overlap with local_sets[bb],
1292 we'll have to rescan the block. */
1293 local_set
= local_sets
[bb
->index
- (INVALID_BLOCK
+ 1)];
1294 rescan
= bitmap_intersect_p (tmp
, local_set
);
1298 /* Let our caller know that BB changed enough to require its
1299 death notes updated. */
1301 SET_BIT (blocks_out
, bb
->index
);
1305 /* Add to live_at_start the set of all registers in
1306 new_live_at_end that aren't in the old live_at_end. */
1308 changed
= bitmap_ior_and_compl_into (bb
->global_live_at_start
,
1310 bb
->global_live_at_end
);
1311 COPY_REG_SET (bb
->global_live_at_end
, new_live_at_end
);
1317 COPY_REG_SET (bb
->global_live_at_end
, new_live_at_end
);
1319 /* Rescan the block insn by insn to turn (a copy of) live_at_end
1320 into live_at_start. */
1321 propagate_block (bb
, new_live_at_end
,
1322 local_sets
[bb
->index
- (INVALID_BLOCK
+ 1)],
1323 cond_local_sets
[bb
->index
- (INVALID_BLOCK
+ 1)],
1326 /* If live_at start didn't change, no need to go farther. */
1327 if (REG_SET_EQUAL_P (bb
->global_live_at_start
, new_live_at_end
))
1330 if (failure_strategy_required
)
1332 /* Get the list of registers that were removed from the
1333 bb->global_live_at_start set. */
1334 bitmap_and_compl (tmp
, bb
->global_live_at_start
,
1336 if (!bitmap_empty_p (tmp
))
1341 /* It should not happen that one of registers we have
1342 removed last time is disappears again before any other
1344 pbb_changed
= bitmap_ior_into (registers_made_dead
, tmp
);
1345 gcc_assert (pbb_changed
);
1347 /* Now remove the registers from all sets. */
1350 pbb_changed
= false;
1353 |= bitmap_and_compl_into (pbb
->global_live_at_start
,
1354 registers_made_dead
);
1356 |= bitmap_and_compl_into (pbb
->global_live_at_end
,
1357 registers_made_dead
);
1361 /* Note the (possible) change. */
1363 SET_BIT (blocks_out
, pbb
->index
);
1365 /* Makes sure to really rescan the block. */
1366 if (local_sets
[pbb
->index
- (INVALID_BLOCK
+ 1)])
1368 FREE_REG_SET (local_sets
[pbb
->index
- (INVALID_BLOCK
+ 1)]);
1369 FREE_REG_SET (cond_local_sets
[pbb
->index
- (INVALID_BLOCK
+ 1)]);
1370 local_sets
[pbb
->index
- (INVALID_BLOCK
+ 1)] = 0;
1373 /* Add it to the queue. */
1374 if (pbb
->aux
== NULL
)
1384 } /* end of failure_strategy_required */
1386 COPY_REG_SET (bb
->global_live_at_start
, new_live_at_end
);
1389 /* Queue all predecessors of BB so that we may re-examine
1390 their live_at_end. */
1391 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
1393 basic_block pb
= e
->src
;
1394 if (pb
->aux
== NULL
)
1405 FREE_REG_SET (new_live_at_end
);
1406 FREE_REG_SET (invalidated_by_call
);
1407 FREE_REG_SET (registers_made_dead
);
1411 sbitmap_iterator sbi
;
1413 EXECUTE_IF_SET_IN_SBITMAP (blocks_out
, 0, i
, sbi
)
1415 basic_block bb
= BASIC_BLOCK (i
);
1416 FREE_REG_SET (local_sets
[bb
->index
- (INVALID_BLOCK
+ 1)]);
1417 FREE_REG_SET (cond_local_sets
[bb
->index
- (INVALID_BLOCK
+ 1)]);
1424 FREE_REG_SET (local_sets
[bb
->index
- (INVALID_BLOCK
+ 1)]);
1425 FREE_REG_SET (cond_local_sets
[bb
->index
- (INVALID_BLOCK
+ 1)]);
1429 free (block_accesses
);
1431 free (cond_local_sets
);
1436 /* This structure is used to pass parameters to and from the
1437 the function find_regno_partial(). It is used to pass in the
1438 register number we are looking, as well as to return any rtx
1442 unsigned regno_to_find
;
1444 } find_regno_partial_param
;
1447 /* Find the rtx for the reg numbers specified in 'data' if it is
1448 part of an expression which only uses part of the register. Return
1449 it in the structure passed in. */
1451 find_regno_partial (rtx
*ptr
, void *data
)
1453 find_regno_partial_param
*param
= (find_regno_partial_param
*)data
;
1454 unsigned reg
= param
->regno_to_find
;
1455 param
->retval
= NULL_RTX
;
1457 if (*ptr
== NULL_RTX
)
1460 switch (GET_CODE (*ptr
))
1464 case STRICT_LOW_PART
:
1465 if (REG_P (XEXP (*ptr
, 0)) && REGNO (XEXP (*ptr
, 0)) == reg
)
1467 param
->retval
= XEXP (*ptr
, 0);
1473 if (REG_P (SUBREG_REG (*ptr
))
1474 && REGNO (SUBREG_REG (*ptr
)) == reg
)
1476 param
->retval
= SUBREG_REG (*ptr
);
1488 /* Process all immediate successors of the entry block looking for pseudo
1489 registers which are live on entry. Find all of those whose first
1490 instance is a partial register reference of some kind, and initialize
1491 them to 0 after the entry block. This will prevent bit sets within
1492 registers whose value is unknown, and may contain some kind of sticky
1493 bits we don't want. */
1496 initialize_uninitialized_subregs (void)
1500 unsigned reg
, did_something
= 0;
1501 find_regno_partial_param param
;
1504 FOR_EACH_EDGE (e
, ei
, ENTRY_BLOCK_PTR
->succs
)
1506 basic_block bb
= e
->dest
;
1507 regset map
= bb
->global_live_at_start
;
1508 reg_set_iterator rsi
;
1510 EXECUTE_IF_SET_IN_REG_SET (map
, FIRST_PSEUDO_REGISTER
, reg
, rsi
)
1512 int uid
= REGNO_FIRST_UID (reg
);
1515 /* Find an insn which mentions the register we are looking for.
1516 Its preferable to have an instance of the register's rtl since
1517 there may be various flags set which we need to duplicate.
1518 If we can't find it, its probably an automatic whose initial
1519 value doesn't matter, or hopefully something we don't care about. */
1520 for (i
= get_insns (); i
&& INSN_UID (i
) != uid
; i
= NEXT_INSN (i
))
1524 /* Found the insn, now get the REG rtx, if we can. */
1525 param
.regno_to_find
= reg
;
1526 for_each_rtx (&i
, find_regno_partial
, ¶m
);
1527 if (param
.retval
!= NULL_RTX
)
1530 emit_move_insn (param
.retval
,
1531 CONST0_RTX (GET_MODE (param
.retval
)));
1532 insn
= get_insns ();
1534 insert_insn_on_edge (insn
, e
);
1542 commit_edge_insertions ();
1543 return did_something
;
1547 /* Subroutines of life analysis. */
1549 /* Allocate the permanent data structures that represent the results
1550 of life analysis. */
1553 allocate_bb_life_data (void)
1557 FOR_BB_BETWEEN (bb
, ENTRY_BLOCK_PTR
, NULL
, next_bb
)
1559 bb
->global_live_at_start
= ALLOC_REG_SET (®_obstack
);
1560 bb
->global_live_at_end
= ALLOC_REG_SET (®_obstack
);
1563 regs_live_at_setjmp
= ALLOC_REG_SET (®_obstack
);
1567 allocate_reg_life_data (void)
1571 max_regno
= max_reg_num ();
1572 gcc_assert (!reg_deaths
);
1573 reg_deaths
= xcalloc (sizeof (*reg_deaths
), max_regno
);
1575 /* Recalculate the register space, in case it has grown. Old style
1576 vector oriented regsets would set regset_{size,bytes} here also. */
1577 allocate_reg_info (max_regno
, FALSE
, FALSE
);
1579 /* Reset all the data we'll collect in propagate_block and its
1581 for (i
= 0; i
< max_regno
; i
++)
1585 REG_N_DEATHS (i
) = 0;
1586 REG_N_CALLS_CROSSED (i
) = 0;
1587 REG_LIVE_LENGTH (i
) = 0;
1589 REG_BASIC_BLOCK (i
) = REG_BLOCK_UNKNOWN
;
1593 /* Delete dead instructions for propagate_block. */
1596 propagate_block_delete_insn (rtx insn
)
1598 rtx inote
= find_reg_note (insn
, REG_LABEL
, NULL_RTX
);
1600 /* If the insn referred to a label, and that label was attached to
1601 an ADDR_VEC, it's safe to delete the ADDR_VEC. In fact, it's
1602 pretty much mandatory to delete it, because the ADDR_VEC may be
1603 referencing labels that no longer exist.
1605 INSN may reference a deleted label, particularly when a jump
1606 table has been optimized into a direct jump. There's no
1607 real good way to fix up the reference to the deleted label
1608 when the label is deleted, so we just allow it here. */
1610 if (inote
&& LABEL_P (inote
))
1612 rtx label
= XEXP (inote
, 0);
1615 /* The label may be forced if it has been put in the constant
1616 pool. If that is the only use we must discard the table
1617 jump following it, but not the label itself. */
1618 if (LABEL_NUSES (label
) == 1 + LABEL_PRESERVE_P (label
)
1619 && (next
= next_nonnote_insn (label
)) != NULL
1621 && (GET_CODE (PATTERN (next
)) == ADDR_VEC
1622 || GET_CODE (PATTERN (next
)) == ADDR_DIFF_VEC
))
1624 rtx pat
= PATTERN (next
);
1625 int diff_vec_p
= GET_CODE (pat
) == ADDR_DIFF_VEC
;
1626 int len
= XVECLEN (pat
, diff_vec_p
);
1629 for (i
= 0; i
< len
; i
++)
1630 LABEL_NUSES (XEXP (XVECEXP (pat
, diff_vec_p
, i
), 0))--;
1632 delete_insn_and_edges (next
);
1637 delete_insn_and_edges (insn
);
1641 /* Delete dead libcalls for propagate_block. Return the insn
1642 before the libcall. */
1645 propagate_block_delete_libcall (rtx insn
, rtx note
)
1647 rtx first
= XEXP (note
, 0);
1648 rtx before
= PREV_INSN (first
);
1650 delete_insn_chain_and_edges (first
, insn
);
1655 /* Update the life-status of regs for one insn. Return the previous insn. */
1658 propagate_one_insn (struct propagate_block_info
*pbi
, rtx insn
)
1660 rtx prev
= PREV_INSN (insn
);
1661 int flags
= pbi
->flags
;
1662 int insn_is_dead
= 0;
1663 int libcall_is_dead
= 0;
1667 if (! INSN_P (insn
))
1670 note
= find_reg_note (insn
, REG_RETVAL
, NULL_RTX
);
1671 if (flags
& PROP_SCAN_DEAD_CODE
)
1673 insn_is_dead
= insn_dead_p (pbi
, PATTERN (insn
), 0, REG_NOTES (insn
));
1674 libcall_is_dead
= (insn_is_dead
&& note
!= 0
1675 && libcall_dead_p (pbi
, note
, insn
));
1678 /* If an instruction consists of just dead store(s) on final pass,
1680 if ((flags
& PROP_KILL_DEAD_CODE
) && insn_is_dead
)
1682 /* If we're trying to delete a prologue or epilogue instruction
1683 that isn't flagged as possibly being dead, something is wrong.
1684 But if we are keeping the stack pointer depressed, we might well
1685 be deleting insns that are used to compute the amount to update
1686 it by, so they are fine. */
1687 if (reload_completed
1688 && !(TREE_CODE (TREE_TYPE (current_function_decl
)) == FUNCTION_TYPE
1689 && (TYPE_RETURNS_STACK_DEPRESSED
1690 (TREE_TYPE (current_function_decl
))))
1691 && (((HAVE_epilogue
|| HAVE_prologue
)
1692 && prologue_epilogue_contains (insn
))
1693 || (HAVE_sibcall_epilogue
1694 && sibcall_epilogue_contains (insn
)))
1695 && find_reg_note (insn
, REG_MAYBE_DEAD
, NULL_RTX
) == 0)
1696 fatal_insn ("Attempt to delete prologue/epilogue insn:", insn
);
1698 /* Record sets. Do this even for dead instructions, since they
1699 would have killed the values if they hadn't been deleted. To
1700 be consistent, we also have to emit a clobber when we delete
1701 an insn that clobbers a live register. */
1702 pbi
->flags
|= PROP_DEAD_INSN
;
1703 mark_set_regs (pbi
, PATTERN (insn
), insn
);
1704 pbi
->flags
&= ~PROP_DEAD_INSN
;
1706 /* CC0 is now known to be dead. Either this insn used it,
1707 in which case it doesn't anymore, or clobbered it,
1708 so the next insn can't use it. */
1711 if (libcall_is_dead
)
1712 prev
= propagate_block_delete_libcall (insn
, note
);
1716 /* If INSN contains a RETVAL note and is dead, but the libcall
1717 as a whole is not dead, then we want to remove INSN, but
1718 not the whole libcall sequence.
1720 However, we need to also remove the dangling REG_LIBCALL
1721 note so that we do not have mis-matched LIBCALL/RETVAL
1722 notes. In theory we could find a new location for the
1723 REG_RETVAL note, but it hardly seems worth the effort.
1725 NOTE at this point will be the RETVAL note if it exists. */
1731 = find_reg_note (XEXP (note
, 0), REG_LIBCALL
, NULL_RTX
);
1732 remove_note (XEXP (note
, 0), libcall_note
);
1735 /* Similarly if INSN contains a LIBCALL note, remove the
1736 dangling REG_RETVAL note. */
1737 note
= find_reg_note (insn
, REG_LIBCALL
, NULL_RTX
);
1743 = find_reg_note (XEXP (note
, 0), REG_RETVAL
, NULL_RTX
);
1744 remove_note (XEXP (note
, 0), retval_note
);
1747 /* Now delete INSN. */
1748 propagate_block_delete_insn (insn
);
1754 /* See if this is an increment or decrement that can be merged into
1755 a following memory address. */
1758 rtx x
= single_set (insn
);
1760 /* Does this instruction increment or decrement a register? */
1761 if ((flags
& PROP_AUTOINC
)
1763 && REG_P (SET_DEST (x
))
1764 && (GET_CODE (SET_SRC (x
)) == PLUS
1765 || GET_CODE (SET_SRC (x
)) == MINUS
)
1766 && XEXP (SET_SRC (x
), 0) == SET_DEST (x
)
1767 && GET_CODE (XEXP (SET_SRC (x
), 1)) == CONST_INT
1768 /* Ok, look for a following memory ref we can combine with.
1769 If one is found, change the memory ref to a PRE_INC
1770 or PRE_DEC, cancel this insn, and return 1.
1771 Return 0 if nothing has been done. */
1772 && try_pre_increment_1 (pbi
, insn
))
1775 #endif /* AUTO_INC_DEC */
1777 CLEAR_REG_SET (pbi
->new_set
);
1779 /* If this is not the final pass, and this insn is copying the value of
1780 a library call and it's dead, don't scan the insns that perform the
1781 library call, so that the call's arguments are not marked live. */
1782 if (libcall_is_dead
)
1784 /* Record the death of the dest reg. */
1785 mark_set_regs (pbi
, PATTERN (insn
), insn
);
1787 insn
= XEXP (note
, 0);
1788 return PREV_INSN (insn
);
1790 else if (GET_CODE (PATTERN (insn
)) == SET
1791 && SET_DEST (PATTERN (insn
)) == stack_pointer_rtx
1792 && GET_CODE (SET_SRC (PATTERN (insn
))) == PLUS
1793 && XEXP (SET_SRC (PATTERN (insn
)), 0) == stack_pointer_rtx
1794 && GET_CODE (XEXP (SET_SRC (PATTERN (insn
)), 1)) == CONST_INT
)
1796 /* We have an insn to pop a constant amount off the stack.
1797 (Such insns use PLUS regardless of the direction of the stack,
1798 and any insn to adjust the stack by a constant is always a pop
1800 These insns, if not dead stores, have no effect on life, though
1801 they do have an effect on the memory stores we are tracking. */
1802 invalidate_mems_from_set (pbi
, stack_pointer_rtx
);
1803 /* Still, we need to update local_set, lest ifcvt.c:dead_or_predicable
1804 concludes that the stack pointer is not modified. */
1805 mark_set_regs (pbi
, PATTERN (insn
), insn
);
1809 /* Any regs live at the time of a call instruction must not go
1810 in a register clobbered by calls. Find all regs now live and
1811 record this for them. */
1813 if (CALL_P (insn
) && (flags
& PROP_REG_INFO
))
1815 reg_set_iterator rsi
;
1816 EXECUTE_IF_SET_IN_REG_SET (pbi
->reg_live
, 0, i
, rsi
)
1817 REG_N_CALLS_CROSSED (i
)++;
1820 /* Record sets. Do this even for dead instructions, since they
1821 would have killed the values if they hadn't been deleted. */
1822 mark_set_regs (pbi
, PATTERN (insn
), insn
);
1832 if (GET_CODE (PATTERN (insn
)) == COND_EXEC
)
1833 cond
= COND_EXEC_TEST (PATTERN (insn
));
1835 /* Non-constant calls clobber memory, constant calls do not
1836 clobber memory, though they may clobber outgoing arguments
1838 if (! CONST_OR_PURE_CALL_P (insn
))
1840 free_EXPR_LIST_list (&pbi
->mem_set_list
);
1841 pbi
->mem_set_list_len
= 0;
1844 invalidate_mems_from_set (pbi
, stack_pointer_rtx
);
1846 /* There may be extra registers to be clobbered. */
1847 for (note
= CALL_INSN_FUNCTION_USAGE (insn
);
1849 note
= XEXP (note
, 1))
1850 if (GET_CODE (XEXP (note
, 0)) == CLOBBER
)
1851 mark_set_1 (pbi
, CLOBBER
, XEXP (XEXP (note
, 0), 0),
1852 cond
, insn
, pbi
->flags
);
1854 /* Calls change all call-used and global registers; sibcalls do not
1855 clobber anything that must be preserved at end-of-function,
1856 except for return values. */
1858 sibcall_p
= SIBLING_CALL_P (insn
);
1859 live_at_end
= EXIT_BLOCK_PTR
->global_live_at_start
;
1860 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
1861 if (TEST_HARD_REG_BIT (regs_invalidated_by_call
, i
)
1863 && REGNO_REG_SET_P (live_at_end
, i
)
1864 && ! refers_to_regno_p (i
, i
+1,
1865 current_function_return_rtx
,
1868 enum rtx_code code
= global_regs
[i
] ? SET
: CLOBBER
;
1869 /* We do not want REG_UNUSED notes for these registers. */
1870 mark_set_1 (pbi
, code
, regno_reg_rtx
[i
], cond
, insn
,
1871 pbi
->flags
& ~(PROP_DEATH_NOTES
| PROP_REG_INFO
));
1875 /* If an insn doesn't use CC0, it becomes dead since we assume
1876 that every insn clobbers it. So show it dead here;
1877 mark_used_regs will set it live if it is referenced. */
1882 mark_used_regs (pbi
, PATTERN (insn
), NULL_RTX
, insn
);
1884 /* Sometimes we may have inserted something before INSN (such as a move)
1885 when we make an auto-inc. So ensure we will scan those insns. */
1887 prev
= PREV_INSN (insn
);
1890 if (! insn_is_dead
&& CALL_P (insn
))
1896 if (GET_CODE (PATTERN (insn
)) == COND_EXEC
)
1897 cond
= COND_EXEC_TEST (PATTERN (insn
));
1899 /* Calls use their arguments, and may clobber memory which
1900 address involves some register. */
1901 for (note
= CALL_INSN_FUNCTION_USAGE (insn
);
1903 note
= XEXP (note
, 1))
1904 /* We find USE or CLOBBER entities in a FUNCTION_USAGE list: both
1905 of which mark_used_regs knows how to handle. */
1906 mark_used_regs (pbi
, XEXP (XEXP (note
, 0), 0), cond
, insn
);
1908 /* The stack ptr is used (honorarily) by a CALL insn. */
1909 if ((flags
& PROP_REG_INFO
)
1910 && !REGNO_REG_SET_P (pbi
->reg_live
, STACK_POINTER_REGNUM
))
1911 reg_deaths
[STACK_POINTER_REGNUM
] = pbi
->insn_num
;
1912 SET_REGNO_REG_SET (pbi
->reg_live
, STACK_POINTER_REGNUM
);
1914 /* Calls may also reference any of the global registers,
1915 so they are made live. */
1916 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
1918 mark_used_reg (pbi
, regno_reg_rtx
[i
], cond
, insn
);
1927 /* Initialize a propagate_block_info struct for public consumption.
1928 Note that the structure itself is opaque to this file, but that
1929 the user can use the regsets provided here. */
1931 struct propagate_block_info
*
1932 init_propagate_block_info (basic_block bb
, regset live
, regset local_set
,
1933 regset cond_local_set
, int flags
)
1935 struct propagate_block_info
*pbi
= xmalloc (sizeof (*pbi
));
1938 pbi
->reg_live
= live
;
1939 pbi
->mem_set_list
= NULL_RTX
;
1940 pbi
->mem_set_list_len
= 0;
1941 pbi
->local_set
= local_set
;
1942 pbi
->cond_local_set
= cond_local_set
;
1947 if (flags
& (PROP_LOG_LINKS
| PROP_AUTOINC
))
1948 pbi
->reg_next_use
= xcalloc (max_reg_num (), sizeof (rtx
));
1950 pbi
->reg_next_use
= NULL
;
1952 pbi
->new_set
= BITMAP_ALLOC (NULL
);
1954 #ifdef HAVE_conditional_execution
1955 pbi
->reg_cond_dead
= splay_tree_new (splay_tree_compare_ints
, NULL
,
1956 free_reg_cond_life_info
);
1957 pbi
->reg_cond_reg
= BITMAP_ALLOC (NULL
);
1959 /* If this block ends in a conditional branch, for each register
1960 live from one side of the branch and not the other, record the
1961 register as conditionally dead. */
1962 if (JUMP_P (BB_END (bb
))
1963 && any_condjump_p (BB_END (bb
)))
1965 regset diff
= ALLOC_REG_SET (®_obstack
);
1966 basic_block bb_true
, bb_false
;
1969 /* Identify the successor blocks. */
1970 bb_true
= EDGE_SUCC (bb
, 0)->dest
;
1971 if (!single_succ_p (bb
))
1973 bb_false
= EDGE_SUCC (bb
, 1)->dest
;
1975 if (EDGE_SUCC (bb
, 0)->flags
& EDGE_FALLTHRU
)
1977 basic_block t
= bb_false
;
1982 gcc_assert (EDGE_SUCC (bb
, 1)->flags
& EDGE_FALLTHRU
);
1986 /* This can happen with a conditional jump to the next insn. */
1987 gcc_assert (JUMP_LABEL (BB_END (bb
)) == BB_HEAD (bb_true
));
1989 /* Simplest way to do nothing. */
1993 /* Compute which register lead different lives in the successors. */
1994 bitmap_xor (diff
, bb_true
->global_live_at_start
,
1995 bb_false
->global_live_at_start
);
1997 if (!bitmap_empty_p (diff
))
1999 /* Extract the condition from the branch. */
2000 rtx set_src
= SET_SRC (pc_set (BB_END (bb
)));
2001 rtx cond_true
= XEXP (set_src
, 0);
2002 rtx reg
= XEXP (cond_true
, 0);
2003 enum rtx_code inv_cond
;
2005 if (GET_CODE (reg
) == SUBREG
)
2006 reg
= SUBREG_REG (reg
);
2008 /* We can only track conditional lifetimes if the condition is
2009 in the form of a reversible comparison of a register against
2010 zero. If the condition is more complex than that, then it is
2011 safe not to record any information. */
2012 inv_cond
= reversed_comparison_code (cond_true
, BB_END (bb
));
2013 if (inv_cond
!= UNKNOWN
2015 && XEXP (cond_true
, 1) == const0_rtx
)
2018 = gen_rtx_fmt_ee (inv_cond
,
2019 GET_MODE (cond_true
), XEXP (cond_true
, 0),
2020 XEXP (cond_true
, 1));
2021 reg_set_iterator rsi
;
2023 if (GET_CODE (XEXP (set_src
, 1)) == PC
)
2026 cond_false
= cond_true
;
2030 SET_REGNO_REG_SET (pbi
->reg_cond_reg
, REGNO (reg
));
2032 /* For each such register, mark it conditionally dead. */
2033 EXECUTE_IF_SET_IN_REG_SET (diff
, 0, i
, rsi
)
2035 struct reg_cond_life_info
*rcli
;
2038 rcli
= xmalloc (sizeof (*rcli
));
2040 if (REGNO_REG_SET_P (bb_true
->global_live_at_start
, i
))
2044 rcli
->condition
= cond
;
2045 rcli
->stores
= const0_rtx
;
2046 rcli
->orig_condition
= cond
;
2048 splay_tree_insert (pbi
->reg_cond_dead
, i
,
2049 (splay_tree_value
) rcli
);
2054 FREE_REG_SET (diff
);
2058 /* If this block has no successors, any stores to the frame that aren't
2059 used later in the block are dead. So make a pass over the block
2060 recording any such that are made and show them dead at the end. We do
2061 a very conservative and simple job here. */
2063 && ! (TREE_CODE (TREE_TYPE (current_function_decl
)) == FUNCTION_TYPE
2064 && (TYPE_RETURNS_STACK_DEPRESSED
2065 (TREE_TYPE (current_function_decl
))))
2066 && (flags
& PROP_SCAN_DEAD_STORES
)
2067 && (EDGE_COUNT (bb
->succs
) == 0
2068 || (single_succ_p (bb
)
2069 && single_succ (bb
) == EXIT_BLOCK_PTR
2070 && ! current_function_calls_eh_return
)))
2073 for (insn
= BB_END (bb
); insn
!= BB_HEAD (bb
); insn
= PREV_INSN (insn
))
2074 if (NONJUMP_INSN_P (insn
)
2075 && (set
= single_set (insn
))
2076 && MEM_P (SET_DEST (set
)))
2078 rtx mem
= SET_DEST (set
);
2079 rtx canon_mem
= canon_rtx (mem
);
2081 if (XEXP (canon_mem
, 0) == frame_pointer_rtx
2082 || (GET_CODE (XEXP (canon_mem
, 0)) == PLUS
2083 && XEXP (XEXP (canon_mem
, 0), 0) == frame_pointer_rtx
2084 && GET_CODE (XEXP (XEXP (canon_mem
, 0), 1)) == CONST_INT
))
2085 add_to_mem_set_list (pbi
, canon_mem
);
2092 /* Release a propagate_block_info struct. */
2095 free_propagate_block_info (struct propagate_block_info
*pbi
)
2097 free_EXPR_LIST_list (&pbi
->mem_set_list
);
2099 BITMAP_FREE (pbi
->new_set
);
2101 #ifdef HAVE_conditional_execution
2102 splay_tree_delete (pbi
->reg_cond_dead
);
2103 BITMAP_FREE (pbi
->reg_cond_reg
);
2106 if (pbi
->flags
& PROP_REG_INFO
)
2108 int num
= pbi
->insn_num
;
2110 reg_set_iterator rsi
;
2112 EXECUTE_IF_SET_IN_REG_SET (pbi
->reg_live
, 0, i
, rsi
)
2114 REG_LIVE_LENGTH (i
) += num
- reg_deaths
[i
];
2118 if (pbi
->reg_next_use
)
2119 free (pbi
->reg_next_use
);
2124 /* Compute the registers live at the beginning of a basic block BB from
2125 those live at the end.
2127 When called, REG_LIVE contains those live at the end. On return, it
2128 contains those live at the beginning.
2130 LOCAL_SET, if non-null, will be set with all registers killed
2131 unconditionally by this basic block.
2132 Likewise, COND_LOCAL_SET, if non-null, will be set with all registers
2133 killed conditionally by this basic block. If there is any unconditional
2134 set of a register, then the corresponding bit will be set in LOCAL_SET
2135 and cleared in COND_LOCAL_SET.
2136 It is valid for LOCAL_SET and COND_LOCAL_SET to be the same set. In this
2137 case, the resulting set will be equal to the union of the two sets that
2138 would otherwise be computed.
2140 Return nonzero if an INSN is deleted (i.e. by dead code removal). */
2143 propagate_block (basic_block bb
, regset live
, regset local_set
,
2144 regset cond_local_set
, int flags
)
2146 struct propagate_block_info
*pbi
;
2150 pbi
= init_propagate_block_info (bb
, live
, local_set
, cond_local_set
, flags
);
2152 if (flags
& PROP_REG_INFO
)
2155 reg_set_iterator rsi
;
2157 /* Process the regs live at the end of the block.
2158 Mark them as not local to any one basic block. */
2159 EXECUTE_IF_SET_IN_REG_SET (live
, 0, i
, rsi
)
2160 REG_BASIC_BLOCK (i
) = REG_BLOCK_GLOBAL
;
2163 /* Scan the block an insn at a time from end to beginning. */
2166 for (insn
= BB_END (bb
); ; insn
= prev
)
2168 /* If this is a call to `setjmp' et al, warn if any
2169 non-volatile datum is live. */
2170 if ((flags
& PROP_REG_INFO
)
2172 && find_reg_note (insn
, REG_SETJMP
, NULL
))
2173 IOR_REG_SET (regs_live_at_setjmp
, pbi
->reg_live
);
2175 prev
= propagate_one_insn (pbi
, insn
);
2177 changed
|= insn
!= get_insns ();
2179 changed
|= NEXT_INSN (prev
) != insn
;
2181 if (insn
== BB_HEAD (bb
))
2185 free_propagate_block_info (pbi
);
2190 /* Return 1 if X (the body of an insn, or part of it) is just dead stores
2191 (SET expressions whose destinations are registers dead after the insn).
2192 NEEDED is the regset that says which regs are alive after the insn.
2194 Unless CALL_OK is nonzero, an insn is needed if it contains a CALL.
2196 If X is the entire body of an insn, NOTES contains the reg notes
2197 pertaining to the insn. */
2200 insn_dead_p (struct propagate_block_info
*pbi
, rtx x
, int call_ok
,
2201 rtx notes ATTRIBUTE_UNUSED
)
2203 enum rtx_code code
= GET_CODE (x
);
2205 /* Don't eliminate insns that may trap. */
2206 if (flag_non_call_exceptions
&& may_trap_p (x
))
2210 /* As flow is invoked after combine, we must take existing AUTO_INC
2211 expressions into account. */
2212 for (; notes
; notes
= XEXP (notes
, 1))
2214 if (REG_NOTE_KIND (notes
) == REG_INC
)
2216 int regno
= REGNO (XEXP (notes
, 0));
2218 /* Don't delete insns to set global regs. */
2219 if ((regno
< FIRST_PSEUDO_REGISTER
&& global_regs
[regno
])
2220 || REGNO_REG_SET_P (pbi
->reg_live
, regno
))
2226 /* If setting something that's a reg or part of one,
2227 see if that register's altered value will be live. */
2231 rtx r
= SET_DEST (x
);
2234 if (GET_CODE (r
) == CC0
)
2235 return ! pbi
->cc0_live
;
2238 /* A SET that is a subroutine call cannot be dead. */
2239 if (GET_CODE (SET_SRC (x
)) == CALL
)
2245 /* Don't eliminate loads from volatile memory or volatile asms. */
2246 else if (volatile_refs_p (SET_SRC (x
)))
2253 if (MEM_VOLATILE_P (r
) || GET_MODE (r
) == BLKmode
)
2256 canon_r
= canon_rtx (r
);
2258 /* Walk the set of memory locations we are currently tracking
2259 and see if one is an identical match to this memory location.
2260 If so, this memory write is dead (remember, we're walking
2261 backwards from the end of the block to the start). Since
2262 rtx_equal_p does not check the alias set or flags, we also
2263 must have the potential for them to conflict (anti_dependence). */
2264 for (temp
= pbi
->mem_set_list
; temp
!= 0; temp
= XEXP (temp
, 1))
2265 if (anti_dependence (r
, XEXP (temp
, 0)))
2267 rtx mem
= XEXP (temp
, 0);
2269 if (rtx_equal_p (XEXP (canon_r
, 0), XEXP (mem
, 0))
2270 && (GET_MODE_SIZE (GET_MODE (canon_r
))
2271 <= GET_MODE_SIZE (GET_MODE (mem
))))
2275 /* Check if memory reference matches an auto increment. Only
2276 post increment/decrement or modify are valid. */
2277 if (GET_MODE (mem
) == GET_MODE (r
)
2278 && (GET_CODE (XEXP (mem
, 0)) == POST_DEC
2279 || GET_CODE (XEXP (mem
, 0)) == POST_INC
2280 || GET_CODE (XEXP (mem
, 0)) == POST_MODIFY
)
2281 && GET_MODE (XEXP (mem
, 0)) == GET_MODE (r
)
2282 && rtx_equal_p (XEXP (XEXP (mem
, 0), 0), XEXP (r
, 0)))
2289 while (GET_CODE (r
) == SUBREG
2290 || GET_CODE (r
) == STRICT_LOW_PART
2291 || GET_CODE (r
) == ZERO_EXTRACT
)
2296 int regno
= REGNO (r
);
2299 if (REGNO_REG_SET_P (pbi
->reg_live
, regno
))
2302 /* If this is a hard register, verify that subsequent
2303 words are not needed. */
2304 if (regno
< FIRST_PSEUDO_REGISTER
)
2306 int n
= hard_regno_nregs
[regno
][GET_MODE (r
)];
2309 if (REGNO_REG_SET_P (pbi
->reg_live
, regno
+n
))
2313 /* Don't delete insns to set global regs. */
2314 if (regno
< FIRST_PSEUDO_REGISTER
&& global_regs
[regno
])
2317 /* Make sure insns to set the stack pointer aren't deleted. */
2318 if (regno
== STACK_POINTER_REGNUM
)
2321 /* ??? These bits might be redundant with the force live bits
2322 in calculate_global_regs_live. We would delete from
2323 sequential sets; whether this actually affects real code
2324 for anything but the stack pointer I don't know. */
2325 /* Make sure insns to set the frame pointer aren't deleted. */
2326 if (regno
== FRAME_POINTER_REGNUM
2327 && (! reload_completed
|| frame_pointer_needed
))
2329 #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2330 if (regno
== HARD_FRAME_POINTER_REGNUM
2331 && (! reload_completed
|| frame_pointer_needed
))
2335 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
2336 /* Make sure insns to set arg pointer are never deleted
2337 (if the arg pointer isn't fixed, there will be a USE
2338 for it, so we can treat it normally). */
2339 if (regno
== ARG_POINTER_REGNUM
&& fixed_regs
[regno
])
2343 /* Otherwise, the set is dead. */
2349 /* If performing several activities, insn is dead if each activity
2350 is individually dead. Also, CLOBBERs and USEs can be ignored; a
2351 CLOBBER or USE that's inside a PARALLEL doesn't make the insn
2353 else if (code
== PARALLEL
)
2355 int i
= XVECLEN (x
, 0);
2357 for (i
--; i
>= 0; i
--)
2358 if (GET_CODE (XVECEXP (x
, 0, i
)) != CLOBBER
2359 && GET_CODE (XVECEXP (x
, 0, i
)) != USE
2360 && ! insn_dead_p (pbi
, XVECEXP (x
, 0, i
), call_ok
, NULL_RTX
))
2366 /* A CLOBBER of a pseudo-register that is dead serves no purpose. That
2367 is not necessarily true for hard registers until after reload. */
2368 else if (code
== CLOBBER
)
2370 if (REG_P (XEXP (x
, 0))
2371 && (REGNO (XEXP (x
, 0)) >= FIRST_PSEUDO_REGISTER
2372 || reload_completed
)
2373 && ! REGNO_REG_SET_P (pbi
->reg_live
, REGNO (XEXP (x
, 0))))
2377 /* ??? A base USE is a historical relic. It ought not be needed anymore.
2378 Instances where it is still used are either (1) temporary and the USE
2379 escaped the pass, (2) cruft and the USE need not be emitted anymore,
2380 or (3) hiding bugs elsewhere that are not properly representing data
2386 /* If INSN is the last insn in a libcall, and assuming INSN is dead,
2387 return 1 if the entire library call is dead.
2388 This is true if INSN copies a register (hard or pseudo)
2389 and if the hard return reg of the call insn is dead.
2390 (The caller should have tested the destination of the SET inside
2391 INSN already for death.)
2393 If this insn doesn't just copy a register, then we don't
2394 have an ordinary libcall. In that case, cse could not have
2395 managed to substitute the source for the dest later on,
2396 so we can assume the libcall is dead.
2398 PBI is the block info giving pseudoregs live before this insn.
2399 NOTE is the REG_RETVAL note of the insn. */
2402 libcall_dead_p (struct propagate_block_info
*pbi
, rtx note
, rtx insn
)
2404 rtx x
= single_set (insn
);
2408 rtx r
= SET_SRC (x
);
2410 if (REG_P (r
) || GET_CODE (r
) == SUBREG
)
2412 rtx call
= XEXP (note
, 0);
2416 /* Find the call insn. */
2417 while (call
!= insn
&& !CALL_P (call
))
2418 call
= NEXT_INSN (call
);
2420 /* If there is none, do nothing special,
2421 since ordinary death handling can understand these insns. */
2425 /* See if the hard reg holding the value is dead.
2426 If this is a PARALLEL, find the call within it. */
2427 call_pat
= PATTERN (call
);
2428 if (GET_CODE (call_pat
) == PARALLEL
)
2430 for (i
= XVECLEN (call_pat
, 0) - 1; i
>= 0; i
--)
2431 if (GET_CODE (XVECEXP (call_pat
, 0, i
)) == SET
2432 && GET_CODE (SET_SRC (XVECEXP (call_pat
, 0, i
))) == CALL
)
2435 /* This may be a library call that is returning a value
2436 via invisible pointer. Do nothing special, since
2437 ordinary death handling can understand these insns. */
2441 call_pat
= XVECEXP (call_pat
, 0, i
);
2444 if (! insn_dead_p (pbi
, call_pat
, 1, REG_NOTES (call
)))
2447 while ((insn
= PREV_INSN (insn
)) != call
)
2449 if (! INSN_P (insn
))
2451 if (! insn_dead_p (pbi
, PATTERN (insn
), 0, REG_NOTES (insn
)))
2460 /* 1 if register REGNO was alive at a place where `setjmp' was called
2461 and was set more than once or is an argument.
2462 Such regs may be clobbered by `longjmp'. */
2465 regno_clobbered_at_setjmp (int regno
)
2467 if (n_basic_blocks
== 0)
2470 return ((REG_N_SETS (regno
) > 1
2471 || REGNO_REG_SET_P (ENTRY_BLOCK_PTR
->global_live_at_end
, regno
))
2472 && REGNO_REG_SET_P (regs_live_at_setjmp
, regno
));
2475 /* Add MEM to PBI->MEM_SET_LIST. MEM should be canonical. Respect the
2476 maximal list size; look for overlaps in mode and select the largest. */
2478 add_to_mem_set_list (struct propagate_block_info
*pbi
, rtx mem
)
2482 /* We don't know how large a BLKmode store is, so we must not
2483 take them into consideration. */
2484 if (GET_MODE (mem
) == BLKmode
)
2487 for (i
= pbi
->mem_set_list
; i
; i
= XEXP (i
, 1))
2489 rtx e
= XEXP (i
, 0);
2490 if (rtx_equal_p (XEXP (mem
, 0), XEXP (e
, 0)))
2492 if (GET_MODE_SIZE (GET_MODE (mem
)) > GET_MODE_SIZE (GET_MODE (e
)))
2495 /* If we must store a copy of the mem, we can just modify
2496 the mode of the stored copy. */
2497 if (pbi
->flags
& PROP_AUTOINC
)
2498 PUT_MODE (e
, GET_MODE (mem
));
2507 if (pbi
->mem_set_list_len
< MAX_MEM_SET_LIST_LEN
)
2510 /* Store a copy of mem, otherwise the address may be
2511 scrogged by find_auto_inc. */
2512 if (pbi
->flags
& PROP_AUTOINC
)
2513 mem
= shallow_copy_rtx (mem
);
2515 pbi
->mem_set_list
= alloc_EXPR_LIST (0, mem
, pbi
->mem_set_list
);
2516 pbi
->mem_set_list_len
++;
2520 /* INSN references memory, possibly using autoincrement addressing modes.
2521 Find any entries on the mem_set_list that need to be invalidated due
2522 to an address change. */
2525 invalidate_mems_from_autoinc (rtx
*px
, void *data
)
2528 struct propagate_block_info
*pbi
= data
;
2530 if (GET_RTX_CLASS (GET_CODE (x
)) == RTX_AUTOINC
)
2532 invalidate_mems_from_set (pbi
, XEXP (x
, 0));
2539 /* EXP is a REG or MEM. Remove any dependent entries from
2540 pbi->mem_set_list. */
2543 invalidate_mems_from_set (struct propagate_block_info
*pbi
, rtx exp
)
2545 rtx temp
= pbi
->mem_set_list
;
2546 rtx prev
= NULL_RTX
;
2551 next
= XEXP (temp
, 1);
2552 if ((REG_P (exp
) && reg_overlap_mentioned_p (exp
, XEXP (temp
, 0)))
2553 /* When we get an EXP that is a mem here, we want to check if EXP
2554 overlaps the *address* of any of the mems in the list (i.e. not
2555 whether the mems actually overlap; that's done elsewhere). */
2557 && reg_overlap_mentioned_p (exp
, XEXP (XEXP (temp
, 0), 0))))
2559 /* Splice this entry out of the list. */
2561 XEXP (prev
, 1) = next
;
2563 pbi
->mem_set_list
= next
;
2564 free_EXPR_LIST_node (temp
);
2565 pbi
->mem_set_list_len
--;
2573 /* Process the registers that are set within X. Their bits are set to
2574 1 in the regset DEAD, because they are dead prior to this insn.
2576 If INSN is nonzero, it is the insn being processed.
2578 FLAGS is the set of operations to perform. */
2581 mark_set_regs (struct propagate_block_info
*pbi
, rtx x
, rtx insn
)
2583 rtx cond
= NULL_RTX
;
2586 int flags
= pbi
->flags
;
2589 for (link
= REG_NOTES (insn
); link
; link
= XEXP (link
, 1))
2591 if (REG_NOTE_KIND (link
) == REG_INC
)
2592 mark_set_1 (pbi
, SET
, XEXP (link
, 0),
2593 (GET_CODE (x
) == COND_EXEC
2594 ? COND_EXEC_TEST (x
) : NULL_RTX
),
2598 switch (code
= GET_CODE (x
))
2601 if (GET_CODE (XEXP (x
, 1)) == ASM_OPERANDS
)
2602 flags
|= PROP_ASM_SCAN
;
2605 mark_set_1 (pbi
, code
, SET_DEST (x
), cond
, insn
, flags
);
2609 cond
= COND_EXEC_TEST (x
);
2610 x
= COND_EXEC_CODE (x
);
2617 /* We must scan forwards. If we have an asm, we need to set
2618 the PROP_ASM_SCAN flag before scanning the clobbers. */
2619 for (i
= 0; i
< XVECLEN (x
, 0); i
++)
2621 rtx sub
= XVECEXP (x
, 0, i
);
2622 switch (code
= GET_CODE (sub
))
2627 cond
= COND_EXEC_TEST (sub
);
2628 sub
= COND_EXEC_CODE (sub
);
2629 if (GET_CODE (sub
) == SET
)
2631 if (GET_CODE (sub
) == CLOBBER
)
2637 if (GET_CODE (XEXP (sub
, 1)) == ASM_OPERANDS
)
2638 flags
|= PROP_ASM_SCAN
;
2642 mark_set_1 (pbi
, code
, SET_DEST (sub
), cond
, insn
, flags
);
2646 flags
|= PROP_ASM_SCAN
;
2661 /* Process a single set, which appears in INSN. REG (which may not
2662 actually be a REG, it may also be a SUBREG, PARALLEL, etc.) is
2663 being set using the CODE (which may be SET, CLOBBER, or COND_EXEC).
2664 If the set is conditional (because it appear in a COND_EXEC), COND
2665 will be the condition. */
2668 mark_set_1 (struct propagate_block_info
*pbi
, enum rtx_code code
, rtx reg
, rtx cond
, rtx insn
, int flags
)
2670 int regno_first
= -1, regno_last
= -1;
2671 unsigned long not_dead
= 0;
2674 /* Modifying just one hardware register of a multi-reg value or just a
2675 byte field of a register does not mean the value from before this insn
2676 is now dead. Of course, if it was dead after it's unused now. */
2678 switch (GET_CODE (reg
))
2681 /* Some targets place small structures in registers for return values of
2682 functions. We have to detect this case specially here to get correct
2683 flow information. */
2684 for (i
= XVECLEN (reg
, 0) - 1; i
>= 0; i
--)
2685 if (XEXP (XVECEXP (reg
, 0, i
), 0) != 0)
2686 mark_set_1 (pbi
, code
, XEXP (XVECEXP (reg
, 0, i
), 0), cond
, insn
,
2691 /* SIGN_EXTRACT cannot be an lvalue. */
2695 case STRICT_LOW_PART
:
2696 /* ??? Assumes STRICT_LOW_PART not used on multi-word registers. */
2698 reg
= XEXP (reg
, 0);
2699 while (GET_CODE (reg
) == SUBREG
2700 || GET_CODE (reg
) == ZERO_EXTRACT
2701 || GET_CODE (reg
) == STRICT_LOW_PART
);
2704 not_dead
= (unsigned long) REGNO_REG_SET_P (pbi
->reg_live
, REGNO (reg
));
2708 regno_last
= regno_first
= REGNO (reg
);
2709 if (regno_first
< FIRST_PSEUDO_REGISTER
)
2710 regno_last
+= hard_regno_nregs
[regno_first
][GET_MODE (reg
)] - 1;
2714 if (REG_P (SUBREG_REG (reg
)))
2716 enum machine_mode outer_mode
= GET_MODE (reg
);
2717 enum machine_mode inner_mode
= GET_MODE (SUBREG_REG (reg
));
2719 /* Identify the range of registers affected. This is moderately
2720 tricky for hard registers. See alter_subreg. */
2722 regno_last
= regno_first
= REGNO (SUBREG_REG (reg
));
2723 if (regno_first
< FIRST_PSEUDO_REGISTER
)
2725 regno_first
+= subreg_regno_offset (regno_first
, inner_mode
,
2728 regno_last
= (regno_first
2729 + hard_regno_nregs
[regno_first
][outer_mode
] - 1);
2731 /* Since we've just adjusted the register number ranges, make
2732 sure REG matches. Otherwise some_was_live will be clear
2733 when it shouldn't have been, and we'll create incorrect
2734 REG_UNUSED notes. */
2735 reg
= gen_rtx_REG (outer_mode
, regno_first
);
2739 /* If the number of words in the subreg is less than the number
2740 of words in the full register, we have a well-defined partial
2741 set. Otherwise the high bits are undefined.
2743 This is only really applicable to pseudos, since we just took
2744 care of multi-word hard registers. */
2745 if (((GET_MODE_SIZE (outer_mode
)
2746 + UNITS_PER_WORD
- 1) / UNITS_PER_WORD
)
2747 < ((GET_MODE_SIZE (inner_mode
)
2748 + UNITS_PER_WORD
- 1) / UNITS_PER_WORD
))
2749 not_dead
= (unsigned long) REGNO_REG_SET_P (pbi
->reg_live
,
2752 reg
= SUBREG_REG (reg
);
2756 reg
= SUBREG_REG (reg
);
2763 /* If this set is a MEM, then it kills any aliased writes and any
2764 other MEMs which use it.
2765 If this set is a REG, then it kills any MEMs which use the reg. */
2766 if (optimize
&& (flags
& PROP_SCAN_DEAD_STORES
))
2768 if (REG_P (reg
) || MEM_P (reg
))
2769 invalidate_mems_from_set (pbi
, reg
);
2771 /* If the memory reference had embedded side effects (autoincrement
2772 address modes) then we may need to kill some entries on the
2774 if (insn
&& MEM_P (reg
))
2775 for_each_rtx (&PATTERN (insn
), invalidate_mems_from_autoinc
, pbi
);
2777 if (MEM_P (reg
) && ! side_effects_p (reg
)
2778 /* ??? With more effort we could track conditional memory life. */
2780 add_to_mem_set_list (pbi
, canon_rtx (reg
));
2784 && ! (regno_first
== FRAME_POINTER_REGNUM
2785 && (! reload_completed
|| frame_pointer_needed
))
2786 #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2787 && ! (regno_first
== HARD_FRAME_POINTER_REGNUM
2788 && (! reload_completed
|| frame_pointer_needed
))
2790 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
2791 && ! (regno_first
== ARG_POINTER_REGNUM
&& fixed_regs
[regno_first
])
2795 int some_was_live
= 0, some_was_dead
= 0;
2797 for (i
= regno_first
; i
<= regno_last
; ++i
)
2799 int needed_regno
= REGNO_REG_SET_P (pbi
->reg_live
, i
);
2802 /* Order of the set operation matters here since both
2803 sets may be the same. */
2804 CLEAR_REGNO_REG_SET (pbi
->cond_local_set
, i
);
2805 if (cond
!= NULL_RTX
2806 && ! REGNO_REG_SET_P (pbi
->local_set
, i
))
2807 SET_REGNO_REG_SET (pbi
->cond_local_set
, i
);
2809 SET_REGNO_REG_SET (pbi
->local_set
, i
);
2811 if (code
!= CLOBBER
)
2812 SET_REGNO_REG_SET (pbi
->new_set
, i
);
2814 some_was_live
|= needed_regno
;
2815 some_was_dead
|= ! needed_regno
;
2818 #ifdef HAVE_conditional_execution
2819 /* Consider conditional death in deciding that the register needs
2821 if (some_was_live
&& ! not_dead
2822 /* The stack pointer is never dead. Well, not strictly true,
2823 but it's very difficult to tell from here. Hopefully
2824 combine_stack_adjustments will fix up the most egregious
2826 && regno_first
!= STACK_POINTER_REGNUM
)
2828 for (i
= regno_first
; i
<= regno_last
; ++i
)
2829 if (! mark_regno_cond_dead (pbi
, i
, cond
))
2830 not_dead
|= ((unsigned long) 1) << (i
- regno_first
);
2834 /* Additional data to record if this is the final pass. */
2835 if (flags
& (PROP_LOG_LINKS
| PROP_REG_INFO
2836 | PROP_DEATH_NOTES
| PROP_AUTOINC
))
2839 int blocknum
= pbi
->bb
->index
;
2842 if (flags
& (PROP_LOG_LINKS
| PROP_AUTOINC
))
2844 y
= pbi
->reg_next_use
[regno_first
];
2846 /* The next use is no longer next, since a store intervenes. */
2847 for (i
= regno_first
; i
<= regno_last
; ++i
)
2848 pbi
->reg_next_use
[i
] = 0;
2851 if (flags
& PROP_REG_INFO
)
2853 for (i
= regno_first
; i
<= regno_last
; ++i
)
2855 /* Count (weighted) references, stores, etc. This counts a
2856 register twice if it is modified, but that is correct. */
2857 REG_N_SETS (i
) += 1;
2858 REG_N_REFS (i
) += 1;
2859 REG_FREQ (i
) += REG_FREQ_FROM_BB (pbi
->bb
);
2861 /* The insns where a reg is live are normally counted
2862 elsewhere, but we want the count to include the insn
2863 where the reg is set, and the normal counting mechanism
2864 would not count it. */
2865 REG_LIVE_LENGTH (i
) += 1;
2868 /* If this is a hard reg, record this function uses the reg. */
2869 if (regno_first
< FIRST_PSEUDO_REGISTER
)
2871 for (i
= regno_first
; i
<= regno_last
; i
++)
2872 regs_ever_live
[i
] = 1;
2873 if (flags
& PROP_ASM_SCAN
)
2874 for (i
= regno_first
; i
<= regno_last
; i
++)
2875 regs_asm_clobbered
[i
] = 1;
2879 /* Keep track of which basic blocks each reg appears in. */
2880 if (REG_BASIC_BLOCK (regno_first
) == REG_BLOCK_UNKNOWN
)
2881 REG_BASIC_BLOCK (regno_first
) = blocknum
;
2882 else if (REG_BASIC_BLOCK (regno_first
) != blocknum
)
2883 REG_BASIC_BLOCK (regno_first
) = REG_BLOCK_GLOBAL
;
2887 if (! some_was_dead
)
2889 if (flags
& PROP_LOG_LINKS
)
2891 /* Make a logical link from the next following insn
2892 that uses this register, back to this insn.
2893 The following insns have already been processed.
2895 We don't build a LOG_LINK for hard registers containing
2896 in ASM_OPERANDs. If these registers get replaced,
2897 we might wind up changing the semantics of the insn,
2898 even if reload can make what appear to be valid
2901 We don't build a LOG_LINK for global registers to
2902 or from a function call. We don't want to let
2903 combine think that it knows what is going on with
2904 global registers. */
2905 if (y
&& (BLOCK_NUM (y
) == blocknum
)
2906 && (regno_first
>= FIRST_PSEUDO_REGISTER
2907 || (asm_noperands (PATTERN (y
)) < 0
2908 && ! ((CALL_P (insn
)
2910 && global_regs
[regno_first
]))))
2911 LOG_LINKS (y
) = alloc_INSN_LIST (insn
, LOG_LINKS (y
));
2916 else if (! some_was_live
)
2918 if (flags
& PROP_REG_INFO
)
2919 REG_N_DEATHS (regno_first
) += 1;
2921 if (flags
& PROP_DEATH_NOTES
)
2923 /* Note that dead stores have already been deleted
2924 when possible. If we get here, we have found a
2925 dead store that cannot be eliminated (because the
2926 same insn does something useful). Indicate this
2927 by marking the reg being set as dying here. */
2929 = alloc_EXPR_LIST (REG_UNUSED
, reg
, REG_NOTES (insn
));
2934 if (flags
& PROP_DEATH_NOTES
)
2936 /* This is a case where we have a multi-word hard register
2937 and some, but not all, of the words of the register are
2938 needed in subsequent insns. Write REG_UNUSED notes
2939 for those parts that were not needed. This case should
2942 for (i
= regno_first
; i
<= regno_last
; ++i
)
2943 if (! REGNO_REG_SET_P (pbi
->reg_live
, i
))
2945 = alloc_EXPR_LIST (REG_UNUSED
,
2952 /* Mark the register as being dead. */
2954 /* The stack pointer is never dead. Well, not strictly true,
2955 but it's very difficult to tell from here. Hopefully
2956 combine_stack_adjustments will fix up the most egregious
2958 && regno_first
!= STACK_POINTER_REGNUM
)
2960 for (i
= regno_first
; i
<= regno_last
; ++i
)
2961 if (!(not_dead
& (((unsigned long) 1) << (i
- regno_first
))))
2963 if ((pbi
->flags
& PROP_REG_INFO
)
2964 && REGNO_REG_SET_P (pbi
->reg_live
, i
))
2966 REG_LIVE_LENGTH (i
) += pbi
->insn_num
- reg_deaths
[i
];
2969 CLEAR_REGNO_REG_SET (pbi
->reg_live
, i
);
2971 if (flags
& PROP_DEAD_INSN
)
2972 emit_insn_after (gen_rtx_CLOBBER (VOIDmode
, reg
), insn
);
2975 else if (REG_P (reg
))
2977 if (flags
& (PROP_LOG_LINKS
| PROP_AUTOINC
))
2978 pbi
->reg_next_use
[regno_first
] = 0;
2980 if ((flags
& PROP_REG_INFO
) != 0
2981 && (flags
& PROP_ASM_SCAN
) != 0
2982 && regno_first
< FIRST_PSEUDO_REGISTER
)
2984 for (i
= regno_first
; i
<= regno_last
; i
++)
2985 regs_asm_clobbered
[i
] = 1;
2989 /* If this is the last pass and this is a SCRATCH, show it will be dying
2990 here and count it. */
2991 else if (GET_CODE (reg
) == SCRATCH
)
2993 if (flags
& PROP_DEATH_NOTES
)
2995 = alloc_EXPR_LIST (REG_UNUSED
, reg
, REG_NOTES (insn
));
2999 #ifdef HAVE_conditional_execution
3000 /* Mark REGNO conditionally dead.
3001 Return true if the register is now unconditionally dead. */
3004 mark_regno_cond_dead (struct propagate_block_info
*pbi
, int regno
, rtx cond
)
3006 /* If this is a store to a predicate register, the value of the
3007 predicate is changing, we don't know that the predicate as seen
3008 before is the same as that seen after. Flush all dependent
3009 conditions from reg_cond_dead. This will make all such
3010 conditionally live registers unconditionally live. */
3011 if (REGNO_REG_SET_P (pbi
->reg_cond_reg
, regno
))
3012 flush_reg_cond_reg (pbi
, regno
);
3014 /* If this is an unconditional store, remove any conditional
3015 life that may have existed. */
3016 if (cond
== NULL_RTX
)
3017 splay_tree_remove (pbi
->reg_cond_dead
, regno
);
3020 splay_tree_node node
;
3021 struct reg_cond_life_info
*rcli
;
3024 /* Otherwise this is a conditional set. Record that fact.
3025 It may have been conditionally used, or there may be a
3026 subsequent set with a complementary condition. */
3028 node
= splay_tree_lookup (pbi
->reg_cond_dead
, regno
);
3031 /* The register was unconditionally live previously.
3032 Record the current condition as the condition under
3033 which it is dead. */
3034 rcli
= xmalloc (sizeof (*rcli
));
3035 rcli
->condition
= cond
;
3036 rcli
->stores
= cond
;
3037 rcli
->orig_condition
= const0_rtx
;
3038 splay_tree_insert (pbi
->reg_cond_dead
, regno
,
3039 (splay_tree_value
) rcli
);
3041 SET_REGNO_REG_SET (pbi
->reg_cond_reg
, REGNO (XEXP (cond
, 0)));
3043 /* Not unconditionally dead. */
3048 /* The register was conditionally live previously.
3049 Add the new condition to the old. */
3050 rcli
= (struct reg_cond_life_info
*) node
->value
;
3051 ncond
= rcli
->condition
;
3052 ncond
= ior_reg_cond (ncond
, cond
, 1);
3053 if (rcli
->stores
== const0_rtx
)
3054 rcli
->stores
= cond
;
3055 else if (rcli
->stores
!= const1_rtx
)
3056 rcli
->stores
= ior_reg_cond (rcli
->stores
, cond
, 1);
3058 /* If the register is now unconditionally dead, remove the entry
3059 in the splay_tree. A register is unconditionally dead if the
3060 dead condition ncond is true. A register is also unconditionally
3061 dead if the sum of all conditional stores is an unconditional
3062 store (stores is true), and the dead condition is identically the
3063 same as the original dead condition initialized at the end of
3064 the block. This is a pointer compare, not an rtx_equal_p
3066 if (ncond
== const1_rtx
3067 || (ncond
== rcli
->orig_condition
&& rcli
->stores
== const1_rtx
))
3068 splay_tree_remove (pbi
->reg_cond_dead
, regno
);
3071 rcli
->condition
= ncond
;
3073 SET_REGNO_REG_SET (pbi
->reg_cond_reg
, REGNO (XEXP (cond
, 0)));
3075 /* Not unconditionally dead. */
3084 /* Called from splay_tree_delete for pbi->reg_cond_life. */
3087 free_reg_cond_life_info (splay_tree_value value
)
3089 struct reg_cond_life_info
*rcli
= (struct reg_cond_life_info
*) value
;
3093 /* Helper function for flush_reg_cond_reg. */
3096 flush_reg_cond_reg_1 (splay_tree_node node
, void *data
)
3098 struct reg_cond_life_info
*rcli
;
3099 int *xdata
= (int *) data
;
3100 unsigned int regno
= xdata
[0];
3102 /* Don't need to search if last flushed value was farther on in
3103 the in-order traversal. */
3104 if (xdata
[1] >= (int) node
->key
)
3107 /* Splice out portions of the expression that refer to regno. */
3108 rcli
= (struct reg_cond_life_info
*) node
->value
;
3109 rcli
->condition
= elim_reg_cond (rcli
->condition
, regno
);
3110 if (rcli
->stores
!= const0_rtx
&& rcli
->stores
!= const1_rtx
)
3111 rcli
->stores
= elim_reg_cond (rcli
->stores
, regno
);
3113 /* If the entire condition is now false, signal the node to be removed. */
3114 if (rcli
->condition
== const0_rtx
)
3116 xdata
[1] = node
->key
;
3120 gcc_assert (rcli
->condition
!= const1_rtx
);
3125 /* Flush all (sub) expressions referring to REGNO from REG_COND_LIVE. */
3128 flush_reg_cond_reg (struct propagate_block_info
*pbi
, int regno
)
3134 while (splay_tree_foreach (pbi
->reg_cond_dead
,
3135 flush_reg_cond_reg_1
, pair
) == -1)
3136 splay_tree_remove (pbi
->reg_cond_dead
, pair
[1]);
3138 CLEAR_REGNO_REG_SET (pbi
->reg_cond_reg
, regno
);
3141 /* Logical arithmetic on predicate conditions. IOR, NOT and AND.
3142 For ior/and, the ADD flag determines whether we want to add the new
3143 condition X to the old one unconditionally. If it is zero, we will
3144 only return a new expression if X allows us to simplify part of
3145 OLD, otherwise we return NULL to the caller.
3146 If ADD is nonzero, we will return a new condition in all cases. The
3147 toplevel caller of one of these functions should always pass 1 for
3151 ior_reg_cond (rtx old
, rtx x
, int add
)
3155 if (COMPARISON_P (old
))
3157 if (COMPARISON_P (x
)
3158 && REVERSE_CONDEXEC_PREDICATES_P (x
, old
)
3159 && REGNO (XEXP (x
, 0)) == REGNO (XEXP (old
, 0)))
3161 if (GET_CODE (x
) == GET_CODE (old
)
3162 && REGNO (XEXP (x
, 0)) == REGNO (XEXP (old
, 0)))
3166 return gen_rtx_IOR (0, old
, x
);
3169 switch (GET_CODE (old
))
3172 op0
= ior_reg_cond (XEXP (old
, 0), x
, 0);
3173 op1
= ior_reg_cond (XEXP (old
, 1), x
, 0);
3174 if (op0
!= NULL
|| op1
!= NULL
)
3176 if (op0
== const0_rtx
)
3177 return op1
? op1
: gen_rtx_IOR (0, XEXP (old
, 1), x
);
3178 if (op1
== const0_rtx
)
3179 return op0
? op0
: gen_rtx_IOR (0, XEXP (old
, 0), x
);
3180 if (op0
== const1_rtx
|| op1
== const1_rtx
)
3183 op0
= gen_rtx_IOR (0, XEXP (old
, 0), x
);
3184 else if (rtx_equal_p (x
, op0
))
3185 /* (x | A) | x ~ (x | A). */
3188 op1
= gen_rtx_IOR (0, XEXP (old
, 1), x
);
3189 else if (rtx_equal_p (x
, op1
))
3190 /* (A | x) | x ~ (A | x). */
3192 return gen_rtx_IOR (0, op0
, op1
);
3196 return gen_rtx_IOR (0, old
, x
);
3199 op0
= ior_reg_cond (XEXP (old
, 0), x
, 0);
3200 op1
= ior_reg_cond (XEXP (old
, 1), x
, 0);
3201 if (op0
!= NULL
|| op1
!= NULL
)
3203 if (op0
== const1_rtx
)
3204 return op1
? op1
: gen_rtx_IOR (0, XEXP (old
, 1), x
);
3205 if (op1
== const1_rtx
)
3206 return op0
? op0
: gen_rtx_IOR (0, XEXP (old
, 0), x
);
3207 if (op0
== const0_rtx
|| op1
== const0_rtx
)
3210 op0
= gen_rtx_IOR (0, XEXP (old
, 0), x
);
3211 else if (rtx_equal_p (x
, op0
))
3212 /* (x & A) | x ~ x. */
3215 op1
= gen_rtx_IOR (0, XEXP (old
, 1), x
);
3216 else if (rtx_equal_p (x
, op1
))
3217 /* (A & x) | x ~ x. */
3219 return gen_rtx_AND (0, op0
, op1
);
3223 return gen_rtx_IOR (0, old
, x
);
3226 op0
= and_reg_cond (XEXP (old
, 0), not_reg_cond (x
), 0);
3228 return not_reg_cond (op0
);
3231 return gen_rtx_IOR (0, old
, x
);
3239 not_reg_cond (rtx x
)
3241 if (x
== const0_rtx
)
3243 else if (x
== const1_rtx
)
3245 if (GET_CODE (x
) == NOT
)
3247 if (COMPARISON_P (x
)
3248 && REG_P (XEXP (x
, 0)))
3250 gcc_assert (XEXP (x
, 1) == const0_rtx
);
3252 return gen_rtx_fmt_ee (reversed_comparison_code (x
, NULL
),
3253 VOIDmode
, XEXP (x
, 0), const0_rtx
);
3255 return gen_rtx_NOT (0, x
);
3259 and_reg_cond (rtx old
, rtx x
, int add
)
3263 if (COMPARISON_P (old
))
3265 if (COMPARISON_P (x
)
3266 && GET_CODE (x
) == reversed_comparison_code (old
, NULL
)
3267 && REGNO (XEXP (x
, 0)) == REGNO (XEXP (old
, 0)))
3269 if (GET_CODE (x
) == GET_CODE (old
)
3270 && REGNO (XEXP (x
, 0)) == REGNO (XEXP (old
, 0)))
3274 return gen_rtx_AND (0, old
, x
);
3277 switch (GET_CODE (old
))
3280 op0
= and_reg_cond (XEXP (old
, 0), x
, 0);
3281 op1
= and_reg_cond (XEXP (old
, 1), x
, 0);
3282 if (op0
!= NULL
|| op1
!= NULL
)
3284 if (op0
== const0_rtx
)
3285 return op1
? op1
: gen_rtx_AND (0, XEXP (old
, 1), x
);
3286 if (op1
== const0_rtx
)
3287 return op0
? op0
: gen_rtx_AND (0, XEXP (old
, 0), x
);
3288 if (op0
== const1_rtx
|| op1
== const1_rtx
)
3291 op0
= gen_rtx_AND (0, XEXP (old
, 0), x
);
3292 else if (rtx_equal_p (x
, op0
))
3293 /* (x | A) & x ~ x. */
3296 op1
= gen_rtx_AND (0, XEXP (old
, 1), x
);
3297 else if (rtx_equal_p (x
, op1
))
3298 /* (A | x) & x ~ x. */
3300 return gen_rtx_IOR (0, op0
, op1
);
3304 return gen_rtx_AND (0, old
, x
);
3307 op0
= and_reg_cond (XEXP (old
, 0), x
, 0);
3308 op1
= and_reg_cond (XEXP (old
, 1), x
, 0);
3309 if (op0
!= NULL
|| op1
!= NULL
)
3311 if (op0
== const1_rtx
)
3312 return op1
? op1
: gen_rtx_AND (0, XEXP (old
, 1), x
);
3313 if (op1
== const1_rtx
)
3314 return op0
? op0
: gen_rtx_AND (0, XEXP (old
, 0), x
);
3315 if (op0
== const0_rtx
|| op1
== const0_rtx
)
3318 op0
= gen_rtx_AND (0, XEXP (old
, 0), x
);
3319 else if (rtx_equal_p (x
, op0
))
3320 /* (x & A) & x ~ (x & A). */
3323 op1
= gen_rtx_AND (0, XEXP (old
, 1), x
);
3324 else if (rtx_equal_p (x
, op1
))
3325 /* (A & x) & x ~ (A & x). */
3327 return gen_rtx_AND (0, op0
, op1
);
3331 return gen_rtx_AND (0, old
, x
);
3334 op0
= ior_reg_cond (XEXP (old
, 0), not_reg_cond (x
), 0);
3336 return not_reg_cond (op0
);
3339 return gen_rtx_AND (0, old
, x
);
3346 /* Given a condition X, remove references to reg REGNO and return the
3347 new condition. The removal will be done so that all conditions
3348 involving REGNO are considered to evaluate to false. This function
3349 is used when the value of REGNO changes. */
3352 elim_reg_cond (rtx x
, unsigned int regno
)
3356 if (COMPARISON_P (x
))
3358 if (REGNO (XEXP (x
, 0)) == regno
)
3363 switch (GET_CODE (x
))
3366 op0
= elim_reg_cond (XEXP (x
, 0), regno
);
3367 op1
= elim_reg_cond (XEXP (x
, 1), regno
);
3368 if (op0
== const0_rtx
|| op1
== const0_rtx
)
3370 if (op0
== const1_rtx
)
3372 if (op1
== const1_rtx
)
3374 if (op0
== XEXP (x
, 0) && op1
== XEXP (x
, 1))
3376 return gen_rtx_AND (0, op0
, op1
);
3379 op0
= elim_reg_cond (XEXP (x
, 0), regno
);
3380 op1
= elim_reg_cond (XEXP (x
, 1), regno
);
3381 if (op0
== const1_rtx
|| op1
== const1_rtx
)
3383 if (op0
== const0_rtx
)
3385 if (op1
== const0_rtx
)
3387 if (op0
== XEXP (x
, 0) && op1
== XEXP (x
, 1))
3389 return gen_rtx_IOR (0, op0
, op1
);
3392 op0
= elim_reg_cond (XEXP (x
, 0), regno
);
3393 if (op0
== const0_rtx
)
3395 if (op0
== const1_rtx
)
3397 if (op0
!= XEXP (x
, 0))
3398 return not_reg_cond (op0
);
3405 #endif /* HAVE_conditional_execution */
3409 /* Try to substitute the auto-inc expression INC as the address inside
3410 MEM which occurs in INSN. Currently, the address of MEM is an expression
3411 involving INCR_REG, and INCR is the next use of INCR_REG; it is an insn
3412 that has a single set whose source is a PLUS of INCR_REG and something
3416 attempt_auto_inc (struct propagate_block_info
*pbi
, rtx inc
, rtx insn
,
3417 rtx mem
, rtx incr
, rtx incr_reg
)
3419 int regno
= REGNO (incr_reg
);
3420 rtx set
= single_set (incr
);
3421 rtx q
= SET_DEST (set
);
3422 rtx y
= SET_SRC (set
);
3423 int opnum
= XEXP (y
, 0) == incr_reg
? 0 : 1;
3426 /* Make sure this reg appears only once in this insn. */
3427 if (count_occurrences (PATTERN (insn
), incr_reg
, 1) != 1)
3430 if (dead_or_set_p (incr
, incr_reg
)
3431 /* Mustn't autoinc an eliminable register. */
3432 && (regno
>= FIRST_PSEUDO_REGISTER
3433 || ! TEST_HARD_REG_BIT (elim_reg_set
, regno
)))
3435 /* This is the simple case. Try to make the auto-inc. If
3436 we can't, we are done. Otherwise, we will do any
3437 needed updates below. */
3438 if (! validate_change (insn
, &XEXP (mem
, 0), inc
, 0))
3442 /* PREV_INSN used here to check the semi-open interval
3444 && ! reg_used_between_p (q
, PREV_INSN (insn
), incr
)
3445 /* We must also check for sets of q as q may be
3446 a call clobbered hard register and there may
3447 be a call between PREV_INSN (insn) and incr. */
3448 && ! reg_set_between_p (q
, PREV_INSN (insn
), incr
))
3450 /* We have *p followed sometime later by q = p+size.
3451 Both p and q must be live afterward,
3452 and q is not used between INSN and its assignment.
3453 Change it to q = p, ...*q..., q = q+size.
3454 Then fall into the usual case. */
3458 emit_move_insn (q
, incr_reg
);
3459 insns
= get_insns ();
3462 /* If we can't make the auto-inc, or can't make the
3463 replacement into Y, exit. There's no point in making
3464 the change below if we can't do the auto-inc and doing
3465 so is not correct in the pre-inc case. */
3468 validate_change (insn
, &XEXP (mem
, 0), inc
, 1);
3469 validate_change (incr
, &XEXP (y
, opnum
), q
, 1);
3470 if (! apply_change_group ())
3473 /* We now know we'll be doing this change, so emit the
3474 new insn(s) and do the updates. */
3475 emit_insn_before (insns
, insn
);
3477 if (BB_HEAD (pbi
->bb
) == insn
)
3478 BB_HEAD (pbi
->bb
) = insns
;
3480 /* INCR will become a NOTE and INSN won't contain a
3481 use of INCR_REG. If a use of INCR_REG was just placed in
3482 the insn before INSN, make that the next use.
3483 Otherwise, invalidate it. */
3484 if (NONJUMP_INSN_P (PREV_INSN (insn
))
3485 && GET_CODE (PATTERN (PREV_INSN (insn
))) == SET
3486 && SET_SRC (PATTERN (PREV_INSN (insn
))) == incr_reg
)
3487 pbi
->reg_next_use
[regno
] = PREV_INSN (insn
);
3489 pbi
->reg_next_use
[regno
] = 0;
3494 if ((pbi
->flags
& PROP_REG_INFO
)
3495 && !REGNO_REG_SET_P (pbi
->reg_live
, regno
))
3496 reg_deaths
[regno
] = pbi
->insn_num
;
3498 /* REGNO is now used in INCR which is below INSN, but
3499 it previously wasn't live here. If we don't mark
3500 it as live, we'll put a REG_DEAD note for it
3501 on this insn, which is incorrect. */
3502 SET_REGNO_REG_SET (pbi
->reg_live
, regno
);
3504 /* If there are any calls between INSN and INCR, show
3505 that REGNO now crosses them. */
3506 for (temp
= insn
; temp
!= incr
; temp
= NEXT_INSN (temp
))
3508 REG_N_CALLS_CROSSED (regno
)++;
3510 /* Invalidate alias info for Q since we just changed its value. */
3511 clear_reg_alias_info (q
);
3516 /* If we haven't returned, it means we were able to make the
3517 auto-inc, so update the status. First, record that this insn
3518 has an implicit side effect. */
3520 REG_NOTES (insn
) = alloc_EXPR_LIST (REG_INC
, incr_reg
, REG_NOTES (insn
));
3522 /* Modify the old increment-insn to simply copy
3523 the already-incremented value of our register. */
3524 changed
= validate_change (incr
, &SET_SRC (set
), incr_reg
, 0);
3525 gcc_assert (changed
);
3527 /* If that makes it a no-op (copying the register into itself) delete
3528 it so it won't appear to be a "use" and a "set" of this
3530 if (REGNO (SET_DEST (set
)) == REGNO (incr_reg
))
3532 /* If the original source was dead, it's dead now. */
3535 while ((note
= find_reg_note (incr
, REG_DEAD
, NULL_RTX
)) != NULL_RTX
)
3537 remove_note (incr
, note
);
3538 if (XEXP (note
, 0) != incr_reg
)
3540 unsigned int regno
= REGNO (XEXP (note
, 0));
3542 if ((pbi
->flags
& PROP_REG_INFO
)
3543 && REGNO_REG_SET_P (pbi
->reg_live
, regno
))
3545 REG_LIVE_LENGTH (regno
) += pbi
->insn_num
- reg_deaths
[regno
];
3546 reg_deaths
[regno
] = 0;
3548 CLEAR_REGNO_REG_SET (pbi
->reg_live
, REGNO (XEXP (note
, 0)));
3552 SET_INSN_DELETED (incr
);
3555 if (regno
>= FIRST_PSEUDO_REGISTER
)
3557 /* Count an extra reference to the reg. When a reg is
3558 incremented, spilling it is worse, so we want to make
3559 that less likely. */
3560 REG_FREQ (regno
) += REG_FREQ_FROM_BB (pbi
->bb
);
3562 /* Count the increment as a setting of the register,
3563 even though it isn't a SET in rtl. */
3564 REG_N_SETS (regno
)++;
3568 /* X is a MEM found in INSN. See if we can convert it into an auto-increment
3572 find_auto_inc (struct propagate_block_info
*pbi
, rtx x
, rtx insn
)
3574 rtx addr
= XEXP (x
, 0);
3575 HOST_WIDE_INT offset
= 0;
3576 rtx set
, y
, incr
, inc_val
;
3578 int size
= GET_MODE_SIZE (GET_MODE (x
));
3583 /* Here we detect use of an index register which might be good for
3584 postincrement, postdecrement, preincrement, or predecrement. */
3586 if (GET_CODE (addr
) == PLUS
&& GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
3587 offset
= INTVAL (XEXP (addr
, 1)), addr
= XEXP (addr
, 0);
3592 regno
= REGNO (addr
);
3594 /* Is the next use an increment that might make auto-increment? */
3595 incr
= pbi
->reg_next_use
[regno
];
3596 if (incr
== 0 || BLOCK_NUM (incr
) != BLOCK_NUM (insn
))
3598 set
= single_set (incr
);
3599 if (set
== 0 || GET_CODE (set
) != SET
)
3603 if (GET_CODE (y
) != PLUS
)
3606 if (REG_P (XEXP (y
, 0)) && REGNO (XEXP (y
, 0)) == REGNO (addr
))
3607 inc_val
= XEXP (y
, 1);
3608 else if (REG_P (XEXP (y
, 1)) && REGNO (XEXP (y
, 1)) == REGNO (addr
))
3609 inc_val
= XEXP (y
, 0);
3613 if (GET_CODE (inc_val
) == CONST_INT
)
3615 if (HAVE_POST_INCREMENT
3616 && (INTVAL (inc_val
) == size
&& offset
== 0))
3617 attempt_auto_inc (pbi
, gen_rtx_POST_INC (Pmode
, addr
), insn
, x
,
3619 else if (HAVE_POST_DECREMENT
3620 && (INTVAL (inc_val
) == -size
&& offset
== 0))
3621 attempt_auto_inc (pbi
, gen_rtx_POST_DEC (Pmode
, addr
), insn
, x
,
3623 else if (HAVE_PRE_INCREMENT
3624 && (INTVAL (inc_val
) == size
&& offset
== size
))
3625 attempt_auto_inc (pbi
, gen_rtx_PRE_INC (Pmode
, addr
), insn
, x
,
3627 else if (HAVE_PRE_DECREMENT
3628 && (INTVAL (inc_val
) == -size
&& offset
== -size
))
3629 attempt_auto_inc (pbi
, gen_rtx_PRE_DEC (Pmode
, addr
), insn
, x
,
3631 else if (HAVE_POST_MODIFY_DISP
&& offset
== 0)
3632 attempt_auto_inc (pbi
, gen_rtx_POST_MODIFY (Pmode
, addr
,
3633 gen_rtx_PLUS (Pmode
,
3636 insn
, x
, incr
, addr
);
3637 else if (HAVE_PRE_MODIFY_DISP
&& offset
== INTVAL (inc_val
))
3638 attempt_auto_inc (pbi
, gen_rtx_PRE_MODIFY (Pmode
, addr
,
3639 gen_rtx_PLUS (Pmode
,
3642 insn
, x
, incr
, addr
);
3644 else if (REG_P (inc_val
)
3645 && ! reg_set_between_p (inc_val
, PREV_INSN (insn
),
3649 if (HAVE_POST_MODIFY_REG
&& offset
== 0)
3650 attempt_auto_inc (pbi
, gen_rtx_POST_MODIFY (Pmode
, addr
,
3651 gen_rtx_PLUS (Pmode
,
3654 insn
, x
, incr
, addr
);
3658 #endif /* AUTO_INC_DEC */
3661 mark_used_reg (struct propagate_block_info
*pbi
, rtx reg
,
3662 rtx cond ATTRIBUTE_UNUSED
, rtx insn
)
3664 unsigned int regno_first
, regno_last
, i
;
3665 int some_was_live
, some_was_dead
, some_not_set
;
3667 regno_last
= regno_first
= REGNO (reg
);
3668 if (regno_first
< FIRST_PSEUDO_REGISTER
)
3669 regno_last
+= hard_regno_nregs
[regno_first
][GET_MODE (reg
)] - 1;
3671 /* Find out if any of this register is live after this instruction. */
3672 some_was_live
= some_was_dead
= 0;
3673 for (i
= regno_first
; i
<= regno_last
; ++i
)
3675 int needed_regno
= REGNO_REG_SET_P (pbi
->reg_live
, i
);
3676 some_was_live
|= needed_regno
;
3677 some_was_dead
|= ! needed_regno
;
3680 /* Find out if any of the register was set this insn. */
3682 for (i
= regno_first
; i
<= regno_last
; ++i
)
3683 some_not_set
|= ! REGNO_REG_SET_P (pbi
->new_set
, i
);
3685 if (pbi
->flags
& (PROP_LOG_LINKS
| PROP_AUTOINC
))
3687 /* Record where each reg is used, so when the reg is set we know
3688 the next insn that uses it. */
3689 pbi
->reg_next_use
[regno_first
] = insn
;
3692 if (pbi
->flags
& PROP_REG_INFO
)
3694 if (regno_first
< FIRST_PSEUDO_REGISTER
)
3696 /* If this is a register we are going to try to eliminate,
3697 don't mark it live here. If we are successful in
3698 eliminating it, it need not be live unless it is used for
3699 pseudos, in which case it will have been set live when it
3700 was allocated to the pseudos. If the register will not
3701 be eliminated, reload will set it live at that point.
3703 Otherwise, record that this function uses this register. */
3704 /* ??? The PPC backend tries to "eliminate" on the pic
3705 register to itself. This should be fixed. In the mean
3706 time, hack around it. */
3708 if (! (TEST_HARD_REG_BIT (elim_reg_set
, regno_first
)
3709 && (regno_first
== FRAME_POINTER_REGNUM
3710 || regno_first
== ARG_POINTER_REGNUM
)))
3711 for (i
= regno_first
; i
<= regno_last
; ++i
)
3712 regs_ever_live
[i
] = 1;
3716 /* Keep track of which basic block each reg appears in. */
3718 int blocknum
= pbi
->bb
->index
;
3719 if (REG_BASIC_BLOCK (regno_first
) == REG_BLOCK_UNKNOWN
)
3720 REG_BASIC_BLOCK (regno_first
) = blocknum
;
3721 else if (REG_BASIC_BLOCK (regno_first
) != blocknum
)
3722 REG_BASIC_BLOCK (regno_first
) = REG_BLOCK_GLOBAL
;
3724 /* Count (weighted) number of uses of each reg. */
3725 REG_FREQ (regno_first
) += REG_FREQ_FROM_BB (pbi
->bb
);
3726 REG_N_REFS (regno_first
)++;
3728 for (i
= regno_first
; i
<= regno_last
; ++i
)
3729 if (! REGNO_REG_SET_P (pbi
->reg_live
, i
))
3731 gcc_assert (!reg_deaths
[i
]);
3732 reg_deaths
[i
] = pbi
->insn_num
;
3736 /* Record and count the insns in which a reg dies. If it is used in
3737 this insn and was dead below the insn then it dies in this insn.
3738 If it was set in this insn, we do not make a REG_DEAD note;
3739 likewise if we already made such a note. */
3740 if ((pbi
->flags
& (PROP_DEATH_NOTES
| PROP_REG_INFO
))
3744 /* Check for the case where the register dying partially
3745 overlaps the register set by this insn. */
3746 if (regno_first
!= regno_last
)
3747 for (i
= regno_first
; i
<= regno_last
; ++i
)
3748 some_was_live
|= REGNO_REG_SET_P (pbi
->new_set
, i
);
3750 /* If none of the words in X is needed, make a REG_DEAD note.
3751 Otherwise, we must make partial REG_DEAD notes. */
3752 if (! some_was_live
)
3754 if ((pbi
->flags
& PROP_DEATH_NOTES
)
3755 && ! find_regno_note (insn
, REG_DEAD
, regno_first
))
3757 = alloc_EXPR_LIST (REG_DEAD
, reg
, REG_NOTES (insn
));
3759 if (pbi
->flags
& PROP_REG_INFO
)
3760 REG_N_DEATHS (regno_first
)++;
3764 /* Don't make a REG_DEAD note for a part of a register
3765 that is set in the insn. */
3766 for (i
= regno_first
; i
<= regno_last
; ++i
)
3767 if (! REGNO_REG_SET_P (pbi
->reg_live
, i
)
3768 && ! dead_or_set_regno_p (insn
, i
))
3770 = alloc_EXPR_LIST (REG_DEAD
,
3776 /* Mark the register as being live. */
3777 for (i
= regno_first
; i
<= regno_last
; ++i
)
3779 #ifdef HAVE_conditional_execution
3780 int this_was_live
= REGNO_REG_SET_P (pbi
->reg_live
, i
);
3783 SET_REGNO_REG_SET (pbi
->reg_live
, i
);
3785 #ifdef HAVE_conditional_execution
3786 /* If this is a conditional use, record that fact. If it is later
3787 conditionally set, we'll know to kill the register. */
3788 if (cond
!= NULL_RTX
)
3790 splay_tree_node node
;
3791 struct reg_cond_life_info
*rcli
;
3796 node
= splay_tree_lookup (pbi
->reg_cond_dead
, i
);
3799 /* The register was unconditionally live previously.
3800 No need to do anything. */
3804 /* The register was conditionally live previously.
3805 Subtract the new life cond from the old death cond. */
3806 rcli
= (struct reg_cond_life_info
*) node
->value
;
3807 ncond
= rcli
->condition
;
3808 ncond
= and_reg_cond (ncond
, not_reg_cond (cond
), 1);
3810 /* If the register is now unconditionally live,
3811 remove the entry in the splay_tree. */
3812 if (ncond
== const0_rtx
)
3813 splay_tree_remove (pbi
->reg_cond_dead
, i
);
3816 rcli
->condition
= ncond
;
3817 SET_REGNO_REG_SET (pbi
->reg_cond_reg
,
3818 REGNO (XEXP (cond
, 0)));
3824 /* The register was not previously live at all. Record
3825 the condition under which it is still dead. */
3826 rcli
= xmalloc (sizeof (*rcli
));
3827 rcli
->condition
= not_reg_cond (cond
);
3828 rcli
->stores
= const0_rtx
;
3829 rcli
->orig_condition
= const0_rtx
;
3830 splay_tree_insert (pbi
->reg_cond_dead
, i
,
3831 (splay_tree_value
) rcli
);
3833 SET_REGNO_REG_SET (pbi
->reg_cond_reg
, REGNO (XEXP (cond
, 0)));
3836 else if (this_was_live
)
3838 /* The register may have been conditionally live previously, but
3839 is now unconditionally live. Remove it from the conditionally
3840 dead list, so that a conditional set won't cause us to think
3842 splay_tree_remove (pbi
->reg_cond_dead
, i
);
3848 /* Scan expression X and store a 1-bit in NEW_LIVE for each reg it uses.
3849 This is done assuming the registers needed from X are those that
3850 have 1-bits in PBI->REG_LIVE.
3852 INSN is the containing instruction. If INSN is dead, this function
3856 mark_used_regs (struct propagate_block_info
*pbi
, rtx x
, rtx cond
, rtx insn
)
3860 int flags
= pbi
->flags
;
3865 code
= GET_CODE (x
);
3886 /* If we are clobbering a MEM, mark any registers inside the address
3888 if (MEM_P (XEXP (x
, 0)))
3889 mark_used_regs (pbi
, XEXP (XEXP (x
, 0), 0), cond
, insn
);
3893 /* Don't bother watching stores to mems if this is not the
3894 final pass. We'll not be deleting dead stores this round. */
3895 if (optimize
&& (flags
& PROP_SCAN_DEAD_STORES
))
3897 /* Invalidate the data for the last MEM stored, but only if MEM is
3898 something that can be stored into. */
3899 if (GET_CODE (XEXP (x
, 0)) == SYMBOL_REF
3900 && CONSTANT_POOL_ADDRESS_P (XEXP (x
, 0)))
3901 /* Needn't clear the memory set list. */
3905 rtx temp
= pbi
->mem_set_list
;
3906 rtx prev
= NULL_RTX
;
3911 next
= XEXP (temp
, 1);
3912 if (anti_dependence (XEXP (temp
, 0), x
))
3914 /* Splice temp out of the list. */
3916 XEXP (prev
, 1) = next
;
3918 pbi
->mem_set_list
= next
;
3919 free_EXPR_LIST_node (temp
);
3920 pbi
->mem_set_list_len
--;
3928 /* If the memory reference had embedded side effects (autoincrement
3929 address modes. Then we may need to kill some entries on the
3932 for_each_rtx (&PATTERN (insn
), invalidate_mems_from_autoinc
, pbi
);
3936 if (flags
& PROP_AUTOINC
)
3937 find_auto_inc (pbi
, x
, insn
);
3942 #ifdef CANNOT_CHANGE_MODE_CLASS
3943 if (flags
& PROP_REG_INFO
)
3944 record_subregs_of_mode (x
);
3947 /* While we're here, optimize this case. */
3954 /* See a register other than being set => mark it as needed. */
3955 mark_used_reg (pbi
, x
, cond
, insn
);
3960 rtx testreg
= SET_DEST (x
);
3963 /* If storing into MEM, don't show it as being used. But do
3964 show the address as being used. */
3965 if (MEM_P (testreg
))
3968 if (flags
& PROP_AUTOINC
)
3969 find_auto_inc (pbi
, testreg
, insn
);
3971 mark_used_regs (pbi
, XEXP (testreg
, 0), cond
, insn
);
3972 mark_used_regs (pbi
, SET_SRC (x
), cond
, insn
);
3976 /* Storing in STRICT_LOW_PART is like storing in a reg
3977 in that this SET might be dead, so ignore it in TESTREG.
3978 but in some other ways it is like using the reg.
3980 Storing in a SUBREG or a bit field is like storing the entire
3981 register in that if the register's value is not used
3982 then this SET is not needed. */
3983 while (GET_CODE (testreg
) == STRICT_LOW_PART
3984 || GET_CODE (testreg
) == ZERO_EXTRACT
3985 || GET_CODE (testreg
) == SUBREG
)
3987 #ifdef CANNOT_CHANGE_MODE_CLASS
3988 if ((flags
& PROP_REG_INFO
) && GET_CODE (testreg
) == SUBREG
)
3989 record_subregs_of_mode (testreg
);
3992 /* Modifying a single register in an alternate mode
3993 does not use any of the old value. But these other
3994 ways of storing in a register do use the old value. */
3995 if (GET_CODE (testreg
) == SUBREG
3996 && !((REG_BYTES (SUBREG_REG (testreg
))
3997 + UNITS_PER_WORD
- 1) / UNITS_PER_WORD
3998 > (REG_BYTES (testreg
)
3999 + UNITS_PER_WORD
- 1) / UNITS_PER_WORD
))
4004 testreg
= XEXP (testreg
, 0);
4007 /* If this is a store into a register or group of registers,
4008 recursively scan the value being stored. */
4010 if ((GET_CODE (testreg
) == PARALLEL
4011 && GET_MODE (testreg
) == BLKmode
)
4013 && (regno
= REGNO (testreg
),
4014 ! (regno
== FRAME_POINTER_REGNUM
4015 && (! reload_completed
|| frame_pointer_needed
)))
4016 #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
4017 && ! (regno
== HARD_FRAME_POINTER_REGNUM
4018 && (! reload_completed
|| frame_pointer_needed
))
4020 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
4021 && ! (regno
== ARG_POINTER_REGNUM
&& fixed_regs
[regno
])
4026 mark_used_regs (pbi
, SET_DEST (x
), cond
, insn
);
4027 mark_used_regs (pbi
, SET_SRC (x
), cond
, insn
);
4034 case UNSPEC_VOLATILE
:
4038 /* Traditional and volatile asm instructions must be considered to use
4039 and clobber all hard registers, all pseudo-registers and all of
4040 memory. So must TRAP_IF and UNSPEC_VOLATILE operations.
4042 Consider for instance a volatile asm that changes the fpu rounding
4043 mode. An insn should not be moved across this even if it only uses
4044 pseudo-regs because it might give an incorrectly rounded result.
4046 ?!? Unfortunately, marking all hard registers as live causes massive
4047 problems for the register allocator and marking all pseudos as live
4048 creates mountains of uninitialized variable warnings.
4050 So for now, just clear the memory set list and mark any regs
4051 we can find in ASM_OPERANDS as used. */
4052 if (code
!= ASM_OPERANDS
|| MEM_VOLATILE_P (x
))
4054 free_EXPR_LIST_list (&pbi
->mem_set_list
);
4055 pbi
->mem_set_list_len
= 0;
4058 /* For all ASM_OPERANDS, we must traverse the vector of input operands.
4059 We can not just fall through here since then we would be confused
4060 by the ASM_INPUT rtx inside ASM_OPERANDS, which do not indicate
4061 traditional asms unlike their normal usage. */
4062 if (code
== ASM_OPERANDS
)
4066 for (j
= 0; j
< ASM_OPERANDS_INPUT_LENGTH (x
); j
++)
4067 mark_used_regs (pbi
, ASM_OPERANDS_INPUT (x
, j
), cond
, insn
);
4075 mark_used_regs (pbi
, COND_EXEC_TEST (x
), NULL_RTX
, insn
);
4077 cond
= COND_EXEC_TEST (x
);
4078 x
= COND_EXEC_CODE (x
);
4085 /* Recursively scan the operands of this expression. */
4088 const char * const fmt
= GET_RTX_FORMAT (code
);
4091 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
4095 /* Tail recursive case: save a function call level. */
4101 mark_used_regs (pbi
, XEXP (x
, i
), cond
, insn
);
4103 else if (fmt
[i
] == 'E')
4106 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
4107 mark_used_regs (pbi
, XVECEXP (x
, i
, j
), cond
, insn
);
4116 try_pre_increment_1 (struct propagate_block_info
*pbi
, rtx insn
)
4118 /* Find the next use of this reg. If in same basic block,
4119 make it do pre-increment or pre-decrement if appropriate. */
4120 rtx x
= single_set (insn
);
4121 HOST_WIDE_INT amount
= ((GET_CODE (SET_SRC (x
)) == PLUS
? 1 : -1)
4122 * INTVAL (XEXP (SET_SRC (x
), 1)));
4123 int regno
= REGNO (SET_DEST (x
));
4124 rtx y
= pbi
->reg_next_use
[regno
];
4126 && SET_DEST (x
) != stack_pointer_rtx
4127 && BLOCK_NUM (y
) == BLOCK_NUM (insn
)
4128 /* Don't do this if the reg dies, or gets set in y; a standard addressing
4129 mode would be better. */
4130 && ! dead_or_set_p (y
, SET_DEST (x
))
4131 && try_pre_increment (y
, SET_DEST (x
), amount
))
4133 /* We have found a suitable auto-increment and already changed
4134 insn Y to do it. So flush this increment instruction. */
4135 propagate_block_delete_insn (insn
);
4137 /* Count a reference to this reg for the increment insn we are
4138 deleting. When a reg is incremented, spilling it is worse,
4139 so we want to make that less likely. */
4140 if (regno
>= FIRST_PSEUDO_REGISTER
)
4142 REG_FREQ (regno
) += REG_FREQ_FROM_BB (pbi
->bb
);
4143 REG_N_SETS (regno
)++;
4146 /* Flush any remembered memories depending on the value of
4147 the incremented register. */
4148 invalidate_mems_from_set (pbi
, SET_DEST (x
));
4155 /* Try to change INSN so that it does pre-increment or pre-decrement
4156 addressing on register REG in order to add AMOUNT to REG.
4157 AMOUNT is negative for pre-decrement.
4158 Returns 1 if the change could be made.
4159 This checks all about the validity of the result of modifying INSN. */
4162 try_pre_increment (rtx insn
, rtx reg
, HOST_WIDE_INT amount
)
4166 /* Nonzero if we can try to make a pre-increment or pre-decrement.
4167 For example, addl $4,r1; movl (r1),... can become movl +(r1),... */
4169 /* Nonzero if we can try to make a post-increment or post-decrement.
4170 For example, addl $4,r1; movl -4(r1),... can become movl (r1)+,...
4171 It is possible for both PRE_OK and POST_OK to be nonzero if the machine
4172 supports both pre-inc and post-inc, or both pre-dec and post-dec. */
4175 /* Nonzero if the opportunity actually requires post-inc or post-dec. */
4178 /* From the sign of increment, see which possibilities are conceivable
4179 on this target machine. */
4180 if (HAVE_PRE_INCREMENT
&& amount
> 0)
4182 if (HAVE_POST_INCREMENT
&& amount
> 0)
4185 if (HAVE_PRE_DECREMENT
&& amount
< 0)
4187 if (HAVE_POST_DECREMENT
&& amount
< 0)
4190 if (! (pre_ok
|| post_ok
))
4193 /* It is not safe to add a side effect to a jump insn
4194 because if the incremented register is spilled and must be reloaded
4195 there would be no way to store the incremented value back in memory. */
4202 use
= find_use_as_address (PATTERN (insn
), reg
, 0);
4203 if (post_ok
&& (use
== 0 || use
== (rtx
) (size_t) 1))
4205 use
= find_use_as_address (PATTERN (insn
), reg
, -amount
);
4209 if (use
== 0 || use
== (rtx
) (size_t) 1)
4212 if (GET_MODE_SIZE (GET_MODE (use
)) != (amount
> 0 ? amount
: - amount
))
4215 /* See if this combination of instruction and addressing mode exists. */
4216 if (! validate_change (insn
, &XEXP (use
, 0),
4217 gen_rtx_fmt_e (amount
> 0
4218 ? (do_post
? POST_INC
: PRE_INC
)
4219 : (do_post
? POST_DEC
: PRE_DEC
),
4223 /* Record that this insn now has an implicit side effect on X. */
4224 REG_NOTES (insn
) = alloc_EXPR_LIST (REG_INC
, reg
, REG_NOTES (insn
));
4228 #endif /* AUTO_INC_DEC */
4230 /* Find the place in the rtx X where REG is used as a memory address.
4231 Return the MEM rtx that so uses it.
4232 If PLUSCONST is nonzero, search instead for a memory address equivalent to
4233 (plus REG (const_int PLUSCONST)).
4235 If such an address does not appear, return 0.
4236 If REG appears more than once, or is used other than in such an address,
4240 find_use_as_address (rtx x
, rtx reg
, HOST_WIDE_INT plusconst
)
4242 enum rtx_code code
= GET_CODE (x
);
4243 const char * const fmt
= GET_RTX_FORMAT (code
);
4248 if (code
== MEM
&& XEXP (x
, 0) == reg
&& plusconst
== 0)
4251 if (code
== MEM
&& GET_CODE (XEXP (x
, 0)) == PLUS
4252 && XEXP (XEXP (x
, 0), 0) == reg
4253 && GET_CODE (XEXP (XEXP (x
, 0), 1)) == CONST_INT
4254 && INTVAL (XEXP (XEXP (x
, 0), 1)) == plusconst
)
4257 if (code
== SIGN_EXTRACT
|| code
== ZERO_EXTRACT
)
4259 /* If REG occurs inside a MEM used in a bit-field reference,
4260 that is unacceptable. */
4261 if (find_use_as_address (XEXP (x
, 0), reg
, 0) != 0)
4262 return (rtx
) (size_t) 1;
4266 return (rtx
) (size_t) 1;
4268 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
4272 tem
= find_use_as_address (XEXP (x
, i
), reg
, plusconst
);
4276 return (rtx
) (size_t) 1;
4278 else if (fmt
[i
] == 'E')
4281 for (j
= XVECLEN (x
, i
) - 1; j
>= 0; j
--)
4283 tem
= find_use_as_address (XVECEXP (x
, i
, j
), reg
, plusconst
);
4287 return (rtx
) (size_t) 1;
4295 /* Write information about registers and basic blocks into FILE.
4296 This is part of making a debugging dump. */
4299 dump_regset (regset r
, FILE *outf
)
4302 reg_set_iterator rsi
;
4306 fputs (" (nil)", outf
);
4310 EXECUTE_IF_SET_IN_REG_SET (r
, 0, i
, rsi
)
4312 fprintf (outf
, " %d", i
);
4313 if (i
< FIRST_PSEUDO_REGISTER
)
4314 fprintf (outf
, " [%s]",
4319 /* Print a human-readable representation of R on the standard error
4320 stream. This function is designed to be used from within the
4324 debug_regset (regset r
)
4326 dump_regset (r
, stderr
);
4327 putc ('\n', stderr
);
4330 /* Recompute register set/reference counts immediately prior to register
4333 This avoids problems with set/reference counts changing to/from values
4334 which have special meanings to the register allocators.
4336 Additionally, the reference counts are the primary component used by the
4337 register allocators to prioritize pseudos for allocation to hard regs.
4338 More accurate reference counts generally lead to better register allocation.
4340 It might be worthwhile to update REG_LIVE_LENGTH, REG_BASIC_BLOCK and
4341 possibly other information which is used by the register allocators. */
4344 recompute_reg_usage (void)
4346 allocate_reg_life_data ();
4347 /* distribute_notes in combiner fails to convert some of the
4348 REG_UNUSED notes to REG_DEAD notes. This causes CHECK_DEAD_NOTES
4349 in sched1 to die. To solve this update the DEATH_NOTES
4351 update_life_info (NULL
, UPDATE_LIFE_LOCAL
, PROP_REG_INFO
| PROP_DEATH_NOTES
);
4354 /* Optionally removes all the REG_DEAD and REG_UNUSED notes from a set of
4355 blocks. If BLOCKS is NULL, assume the universal set. Returns a count
4356 of the number of registers that died. */
4359 count_or_remove_death_notes (sbitmap blocks
, int kill
)
4365 /* This used to be a loop over all the blocks with a membership test
4366 inside the loop. That can be amazingly expensive on a large CFG
4367 when only a small number of bits are set in BLOCKs (for example,
4368 the calls from the scheduler typically have very few bits set).
4370 For extra credit, someone should convert BLOCKS to a bitmap rather
4374 sbitmap_iterator sbi
;
4376 EXECUTE_IF_SET_IN_SBITMAP (blocks
, 0, i
, sbi
)
4378 count
+= count_or_remove_death_notes_bb (BASIC_BLOCK (i
), kill
);
4385 count
+= count_or_remove_death_notes_bb (bb
, kill
);
4392 /* Optionally removes all the REG_DEAD and REG_UNUSED notes from basic
4393 block BB. Returns a count of the number of registers that died. */
4396 count_or_remove_death_notes_bb (basic_block bb
, int kill
)
4401 for (insn
= BB_HEAD (bb
); ; insn
= NEXT_INSN (insn
))
4405 rtx
*pprev
= ®_NOTES (insn
);
4410 switch (REG_NOTE_KIND (link
))
4413 if (REG_P (XEXP (link
, 0)))
4415 rtx reg
= XEXP (link
, 0);
4418 if (REGNO (reg
) >= FIRST_PSEUDO_REGISTER
)
4421 n
= hard_regno_nregs
[REGNO (reg
)][GET_MODE (reg
)];
4430 rtx next
= XEXP (link
, 1);
4431 free_EXPR_LIST_node (link
);
4432 *pprev
= link
= next
;
4438 pprev
= &XEXP (link
, 1);
4445 if (insn
== BB_END (bb
))
4452 /* Clear LOG_LINKS fields of insns in a selected blocks or whole chain
4453 if blocks is NULL. */
4456 clear_log_links (sbitmap blocks
)
4462 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
4464 free_INSN_LIST_list (&LOG_LINKS (insn
));
4469 sbitmap_iterator sbi
;
4471 EXECUTE_IF_SET_IN_SBITMAP (blocks
, 0, i
, sbi
)
4473 basic_block bb
= BASIC_BLOCK (i
);
4475 for (insn
= BB_HEAD (bb
); insn
!= NEXT_INSN (BB_END (bb
));
4476 insn
= NEXT_INSN (insn
))
4478 free_INSN_LIST_list (&LOG_LINKS (insn
));
4483 /* Given a register bitmap, turn on the bits in a HARD_REG_SET that
4484 correspond to the hard registers, if any, set in that map. This
4485 could be done far more efficiently by having all sorts of special-cases
4486 with moving single words, but probably isn't worth the trouble. */
4489 reg_set_to_hard_reg_set (HARD_REG_SET
*to
, bitmap from
)
4494 EXECUTE_IF_SET_IN_BITMAP (from
, 0, i
, bi
)
4496 if (i
>= FIRST_PSEUDO_REGISTER
)
4498 SET_HARD_REG_BIT (*to
, i
);