1 /* Global constant/copy propagation for RTL.
2 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3 2006, 2007, 2008, 2009, 2010, 2011 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 3, 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 COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
25 #include "diagnostic-core.h"
32 #include "hard-reg-set.h"
34 #include "insn-config.h"
36 #include "basic-block.h"
46 #include "tree-pass.h"
53 /* An obstack for our working variables. */
54 static struct obstack gcse_obstack;
56 struct reg_use {rtx reg_rtx; };
58 /* Hash table of expressions. */
62 /* The expression (SET_SRC for expressions, PATTERN for assignments). */
64 /* Index in the available expression bitmaps. */
66 /* Next entry with the same hash. */
67 struct expr *next_same_hash;
68 /* List of available occurrence in basic blocks in the function.
69 An "available occurrence" is one that is the last occurrence in the
70 basic block and the operands are not modified by following statements in
71 the basic block [including this insn]. */
72 struct occr *avail_occr;
75 /* Occurrence of an expression.
76 There is one per basic block. If a pattern appears more than once the
77 last appearance is used. */
81 /* Next occurrence of this expression. */
83 /* The insn that computes the expression. */
87 typedef struct occr *occr_t;
89 DEF_VEC_ALLOC_P (occr_t, heap);
91 /* Expression and copy propagation hash tables.
92 Each hash table is an array of buckets.
93 ??? It is known that if it were an array of entries, structure elements
94 `next_same_hash' and `bitmap_index' wouldn't be necessary. However, it is
95 not clear whether in the final analysis a sufficient amount of memory would
96 be saved as the size of the available expression bitmaps would be larger
97 [one could build a mapping table without holes afterwards though].
98 Someday I'll perform the computation and figure it out. */
103 This is an array of `set_hash_table_size' elements. */
106 /* Size of the hash table, in elements. */
109 /* Number of hash table elements. */
110 unsigned int n_elems;
113 /* Copy propagation hash table. */
114 static struct hash_table_d set_hash_table;
116 /* Array of implicit set patterns indexed by basic block index. */
117 static rtx *implicit_sets;
119 /* Bitmap containing one bit for each register in the program.
120 Used when performing GCSE to track which registers have been set since
121 the start or end of the basic block while traversing that block. */
122 static regset reg_set_bitmap;
124 /* Various variables for statistics gathering. */
126 /* Memory used in a pass.
127 This isn't intended to be absolutely precise. Its intent is only
128 to keep an eye on memory usage. */
129 static int bytes_used;
131 /* Number of local constants propagated. */
132 static int local_const_prop_count;
133 /* Number of local copies propagated. */
134 static int local_copy_prop_count;
135 /* Number of global constants propagated. */
136 static int global_const_prop_count;
137 /* Number of global copies propagated. */
138 static int global_copy_prop_count;
141 #define GNEW(T) ((T *) gmalloc (sizeof (T)))
143 #define GNEWVEC(T, N) ((T *) gmalloc (sizeof (T) * (N)))
145 #define GNEWVAR(T, S) ((T *) gmalloc ((S)))
147 #define GOBNEW(T) ((T *) gcse_alloc (sizeof (T)))
148 #define GOBNEWVAR(T, S) ((T *) gcse_alloc ((S)))
150 /* Cover function to xmalloc to record bytes allocated. */
153 gmalloc (size_t size)
156 return xmalloc (size);
159 /* Cover function to obstack_alloc. */
162 gcse_alloc (unsigned long size)
165 return obstack_alloc (&gcse_obstack, size);
168 /* Allocate memory for the reg/memory set tracking tables.
169 This is called at the start of each pass. */
172 alloc_gcse_mem (void)
174 /* Allocate vars to track sets of regs. */
175 reg_set_bitmap = ALLOC_REG_SET (NULL);
178 /* Free memory allocated by alloc_gcse_mem. */
183 FREE_REG_SET (reg_set_bitmap);
186 /* Return nonzero if register X is unchanged from INSN to the end
187 of INSN's basic block. */
190 reg_available_p (const_rtx x, const_rtx insn ATTRIBUTE_UNUSED)
192 return ! REGNO_REG_SET_P (reg_set_bitmap, REGNO (x));
195 /* Hash a set of register REGNO.
197 Sets are hashed on the register that is set. This simplifies the PRE copy
200 ??? May need to make things more elaborate. Later, as necessary. */
203 hash_set (int regno, int hash_table_size)
208 return hash % hash_table_size;
211 /* Return nonzero if exp1 is equivalent to exp2. */
214 expr_equiv_p (const_rtx x, const_rtx y)
216 return exp_equiv_p (x, y, 0, true);
219 /* Insert pattern X in INSN in the hash table.
220 X is a SET of a reg to either another reg or a constant.
221 If it is already present, record it as the last occurrence in INSN's
225 insert_set_in_table (rtx x, rtx insn, struct hash_table_d *table)
229 struct expr *cur_expr, *last_expr = NULL;
230 struct occr *cur_occr;
232 gcc_assert (GET_CODE (x) == SET && REG_P (SET_DEST (x)));
234 hash = hash_set (REGNO (SET_DEST (x)), table->size);
236 cur_expr = table->table[hash];
239 while (cur_expr && 0 == (found = expr_equiv_p (cur_expr->expr, x)))
241 /* If the expression isn't found, save a pointer to the end of
243 last_expr = cur_expr;
244 cur_expr = cur_expr->next_same_hash;
249 cur_expr = GOBNEW (struct expr);
250 bytes_used += sizeof (struct expr);
251 if (table->table[hash] == NULL)
252 /* This is the first pattern that hashed to this index. */
253 table->table[hash] = cur_expr;
255 /* Add EXPR to end of this hash chain. */
256 last_expr->next_same_hash = cur_expr;
258 /* Set the fields of the expr element.
259 We must copy X because it can be modified when copy propagation is
260 performed on its operands. */
261 cur_expr->expr = copy_rtx (x);
262 cur_expr->bitmap_index = table->n_elems++;
263 cur_expr->next_same_hash = NULL;
264 cur_expr->avail_occr = NULL;
267 /* Now record the occurrence. */
268 cur_occr = cur_expr->avail_occr;
271 && BLOCK_FOR_INSN (cur_occr->insn) == BLOCK_FOR_INSN (insn))
273 /* Found another instance of the expression in the same basic block.
274 Prefer this occurrence to the currently recorded one. We want
275 the last one in the block and the block is scanned from start
277 cur_occr->insn = insn;
281 /* First occurrence of this expression in this basic block. */
282 cur_occr = GOBNEW (struct occr);
283 bytes_used += sizeof (struct occr);
284 cur_occr->insn = insn;
285 cur_occr->next = cur_expr->avail_occr;
286 cur_expr->avail_occr = cur_occr;
290 /* Determine whether the rtx X should be treated as a constant for CPROP.
291 Since X might be inserted more than once we have to take care that it
295 gcse_constant_p (const_rtx x)
297 return CONSTANT_P (x) && (GET_CODE (x) != CONST || shared_const_p (x));
300 /* Scan pattern PAT of INSN and add an entry to the hash TABLE (set or
304 hash_scan_set (rtx pat, rtx insn, struct hash_table_d *table)
306 rtx src = SET_SRC (pat);
307 rtx dest = SET_DEST (pat);
310 && ! HARD_REGISTER_P (dest)
311 && reg_available_p (dest, insn)
312 && can_copy_p (GET_MODE (dest)))
314 /* See if a REG_EQUAL note shows this equivalent to a simpler expression.
316 This allows us to do a single CPROP pass and still eliminate
317 redundant constants, addresses or other expressions that are
318 constructed with multiple instructions.
320 However, keep the original SRC if INSN is a simple reg-reg move. In
321 In this case, there will almost always be a REG_EQUAL note on the
322 insn that sets SRC. By recording the REG_EQUAL value here as SRC
323 for INSN, we miss copy propagation opportunities.
325 Note that this does not impede profitable constant propagations. We
326 "look through" reg-reg sets in lookup_avail_set. */
327 rtx note = find_reg_equal_equiv_note (insn);
329 && REG_NOTE_KIND (note) == REG_EQUAL
331 && gcse_constant_p (XEXP (note, 0)))
332 src = XEXP (note, 0), pat = gen_rtx_SET (VOIDmode, dest, src);
334 /* Record sets for constant/copy propagation. */
337 && ! HARD_REGISTER_P (src)
338 && reg_available_p (src, insn))
339 || gcse_constant_p (src))
340 insert_set_in_table (pat, insn, table);
344 /* Process INSN and add hash table entries as appropriate.
346 Only available expressions that set a single pseudo-reg are recorded.
348 Single sets in a PARALLEL could be handled, but it's an extra complication
349 that isn't dealt with right now. The trick is handling the CLOBBERs that
350 are also in the PARALLEL. Later.
352 If SET_P is nonzero, this is for the assignment hash table,
353 otherwise it is for the expression hash table. */
356 hash_scan_insn (rtx insn, struct hash_table_d *table)
358 rtx pat = PATTERN (insn);
361 /* Pick out the sets of INSN and for other forms of instructions record
362 what's been modified. */
364 if (GET_CODE (pat) == SET)
365 hash_scan_set (pat, insn, table);
366 else if (GET_CODE (pat) == PARALLEL)
367 for (i = 0; i < XVECLEN (pat, 0); i++)
369 rtx x = XVECEXP (pat, 0, i);
371 if (GET_CODE (x) == SET)
372 hash_scan_set (x, insn, table);
377 dump_hash_table (FILE *file, const char *name, struct hash_table_d *table)
380 /* Flattened out table, so it's printed in proper order. */
381 struct expr **flat_table;
382 unsigned int *hash_val;
385 flat_table = XCNEWVEC (struct expr *, table->n_elems);
386 hash_val = XNEWVEC (unsigned int, table->n_elems);
388 for (i = 0; i < (int) table->size; i++)
389 for (expr = table->table[i]; expr != NULL; expr = expr->next_same_hash)
391 flat_table[expr->bitmap_index] = expr;
392 hash_val[expr->bitmap_index] = i;
395 fprintf (file, "%s hash table (%d buckets, %d entries)\n",
396 name, table->size, table->n_elems);
398 for (i = 0; i < (int) table->n_elems; i++)
399 if (flat_table[i] != 0)
401 expr = flat_table[i];
402 fprintf (file, "Index %d (hash value %d)\n ",
403 expr->bitmap_index, hash_val[i]);
404 print_rtl (file, expr->expr);
405 fprintf (file, "\n");
408 fprintf (file, "\n");
414 /* Record as unavailable all registers that are DEF operands of INSN. */
416 make_set_regs_unavailable (rtx insn)
418 struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
421 for (def_rec = DF_INSN_INFO_DEFS (insn_info); *def_rec; def_rec++)
422 SET_REGNO_REG_SET (reg_set_bitmap, DF_REF_REGNO (*def_rec));
425 /* Top level function to create an assignments hash table.
427 Assignment entries are placed in the hash table if
428 - they are of the form (set (pseudo-reg) src),
429 - src is something we want to perform const/copy propagation on,
430 - none of the operands or target are subsequently modified in the block
432 Currently src must be a pseudo-reg or a const_int.
434 TABLE is the table computed. */
437 compute_hash_table_work (struct hash_table_d *table)
445 /* Reset tables used to keep track of what's not yet invalid [since
446 the end of the block]. */
447 CLEAR_REG_SET (reg_set_bitmap);
449 /* Go over all insns from the last to the first. This is convenient
450 for tracking available registers, i.e. not set between INSN and
451 the end of the basic block BB. */
452 FOR_BB_INSNS_REVERSE (bb, insn)
454 /* Only real insns are interesting. */
455 if (!NONDEBUG_INSN_P (insn))
458 /* Record interesting sets from INSN in the hash table. */
459 hash_scan_insn (insn, table);
461 /* Any registers set in INSN will make SETs above it not AVAIL. */
462 make_set_regs_unavailable (insn);
465 /* Insert implicit sets in the hash table, pretending they appear as
466 insns at the head of the basic block. */
467 if (implicit_sets[bb->index] != NULL_RTX)
468 hash_scan_set (implicit_sets[bb->index], BB_HEAD (bb), table);
472 /* Allocate space for the set/expr hash TABLE.
473 It is used to determine the number of buckets to use. */
476 alloc_hash_table (struct hash_table_d *table)
480 n = get_max_insn_count ();
483 if (table->size < 11)
486 /* Attempt to maintain efficient use of hash table.
487 Making it an odd number is simplest for now.
488 ??? Later take some measurements. */
490 n = table->size * sizeof (struct expr *);
491 table->table = GNEWVAR (struct expr *, n);
494 /* Free things allocated by alloc_hash_table. */
497 free_hash_table (struct hash_table_d *table)
502 /* Compute the hash TABLE for doing copy/const propagation or
503 expression hash table. */
506 compute_hash_table (struct hash_table_d *table)
508 /* Initialize count of number of entries in hash table. */
510 memset (table->table, 0, table->size * sizeof (struct expr *));
512 compute_hash_table_work (table);
515 /* Expression tracking support. */
517 /* Lookup REGNO in the set TABLE. The result is a pointer to the
518 table entry, or NULL if not found. */
521 lookup_set (unsigned int regno, struct hash_table_d *table)
523 unsigned int hash = hash_set (regno, table->size);
526 expr = table->table[hash];
528 while (expr && REGNO (SET_DEST (expr->expr)) != regno)
529 expr = expr->next_same_hash;
534 /* Return the next entry for REGNO in list EXPR. */
537 next_set (unsigned int regno, struct expr *expr)
540 expr = expr->next_same_hash;
541 while (expr && REGNO (SET_DEST (expr->expr)) != regno);
546 /* Reset tables used to keep track of what's still available [since the
547 start of the block]. */
550 reset_opr_set_tables (void)
552 /* Maintain a bitmap of which regs have been set since beginning of
554 CLEAR_REG_SET (reg_set_bitmap);
557 /* Return nonzero if the register X has not been set yet [since the
558 start of the basic block containing INSN]. */
561 reg_not_set_p (const_rtx x, const_rtx insn ATTRIBUTE_UNUSED)
563 return ! REGNO_REG_SET_P (reg_set_bitmap, REGNO (x));
566 /* Record things set by INSN.
567 This data is used by reg_not_set_p. */
570 mark_oprs_set (rtx insn)
572 struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
575 for (def_rec = DF_INSN_INFO_DEFS (insn_info); *def_rec; def_rec++)
576 SET_REGNO_REG_SET (reg_set_bitmap, DF_REF_REGNO (*def_rec));
580 /* Compute copy/constant propagation working variables. */
582 /* Local properties of assignments. */
583 static sbitmap *cprop_pavloc;
584 static sbitmap *cprop_absaltered;
586 /* Global properties of assignments (computed from the local properties). */
587 static sbitmap *cprop_avin;
588 static sbitmap *cprop_avout;
590 /* Allocate vars used for copy/const propagation. N_BLOCKS is the number of
591 basic blocks. N_SETS is the number of sets. */
594 alloc_cprop_mem (int n_blocks, int n_sets)
596 cprop_pavloc = sbitmap_vector_alloc (n_blocks, n_sets);
597 cprop_absaltered = sbitmap_vector_alloc (n_blocks, n_sets);
599 cprop_avin = sbitmap_vector_alloc (n_blocks, n_sets);
600 cprop_avout = sbitmap_vector_alloc (n_blocks, n_sets);
603 /* Free vars used by copy/const propagation. */
606 free_cprop_mem (void)
608 sbitmap_vector_free (cprop_pavloc);
609 sbitmap_vector_free (cprop_absaltered);
610 sbitmap_vector_free (cprop_avin);
611 sbitmap_vector_free (cprop_avout);
614 /* For each block, compute whether X is transparent. X is either an
615 expression or an assignment [though we don't care which, for this context
616 an assignment is treated as an expression]. For each block where an
617 element of X is modified, set the INDX bit in BMAP. */
620 compute_transp (const_rtx x, int indx, sbitmap *bmap)
626 /* repeat is used to turn tail-recursion into iteration since GCC
627 can't do it when there's no return value. */
639 for (def = DF_REG_DEF_CHAIN (REGNO (x));
641 def = DF_REF_NEXT_REG (def))
642 SET_BIT (bmap[DF_REF_BB (def)->index], indx);
663 for (i = GET_RTX_LENGTH (code) - 1, fmt = GET_RTX_FORMAT (code); i >= 0; i--)
667 /* If we are about to do the last recursive call
668 needed at this level, change it into iteration.
669 This function is called enough to be worth it. */
676 compute_transp (XEXP (x, i), indx, bmap);
678 else if (fmt[i] == 'E')
679 for (j = 0; j < XVECLEN (x, i); j++)
680 compute_transp (XVECEXP (x, i, j), indx, bmap);
684 /* Compute the local properties of each recorded expression.
686 Local properties are those that are defined by the block, irrespective of
689 An expression is transparent in a block if its operands are not modified
692 An expression is computed (locally available) in a block if it is computed
693 at least once and expression would contain the same value if the
694 computation was moved to the end of the block.
696 TRANSP and COMP are destination sbitmaps for recording local properties.
697 If NULL, then it is not necessary to compute or record that particular
700 TRANSP is computed as ~TRANSP, since this is really cprop's ABSALTERED. */
703 compute_local_properties (sbitmap *transp, sbitmap *comp,
704 struct hash_table_d *table)
708 /* Initialize any bitmaps that were passed in. */
711 sbitmap_vector_zero (transp, last_basic_block);
715 sbitmap_vector_zero (comp, last_basic_block);
717 for (i = 0; i < table->size; i++)
721 for (expr = table->table[i]; expr != NULL; expr = expr->next_same_hash)
723 int indx = expr->bitmap_index;
726 /* The expression is transparent in this block if it is not killed.
727 We start by assuming all are transparent [none are killed], and
728 then reset the bits for those that are. */
730 compute_transp (expr->expr, indx, transp);
732 /* The occurrences recorded in avail_occr are exactly those that
733 we want to set to nonzero in COMP. */
735 for (occr = expr->avail_occr; occr != NULL; occr = occr->next)
737 SET_BIT (comp[BLOCK_FOR_INSN (occr->insn)->index], indx);
743 /* Hash table support. */
745 /* Top level routine to do the dataflow analysis needed by copy/const
749 compute_cprop_data (void)
751 compute_local_properties (cprop_absaltered, cprop_pavloc, &set_hash_table);
752 compute_available (cprop_pavloc, cprop_absaltered,
753 cprop_avout, cprop_avin);
756 /* Copy/constant propagation. */
758 /* Maximum number of register uses in an insn that we handle. */
761 /* Table of uses found in an insn.
762 Allocated statically to avoid alloc/free complexity and overhead. */
763 static struct reg_use reg_use_table[MAX_USES];
765 /* Index into `reg_use_table' while building it. */
766 static int reg_use_count;
768 /* Set up a list of register numbers used in INSN. The found uses are stored
769 in `reg_use_table'. `reg_use_count' is initialized to zero before entry,
770 and contains the number of uses in the table upon exit.
772 ??? If a register appears multiple times we will record it multiple times.
773 This doesn't hurt anything but it will slow things down. */
776 find_used_regs (rtx *xptr, void *data ATTRIBUTE_UNUSED)
783 /* repeat is used to turn tail-recursion into iteration since GCC
784 can't do it when there's no return value. */
792 if (reg_use_count == MAX_USES)
795 reg_use_table[reg_use_count].reg_rtx = x;
799 /* Recursively scan the operands of this expression. */
801 for (i = GET_RTX_LENGTH (code) - 1, fmt = GET_RTX_FORMAT (code); i >= 0; i--)
805 /* If we are about to do the last recursive call
806 needed at this level, change it into iteration.
807 This function is called enough to be worth it. */
814 find_used_regs (&XEXP (x, i), data);
816 else if (fmt[i] == 'E')
817 for (j = 0; j < XVECLEN (x, i); j++)
818 find_used_regs (&XVECEXP (x, i, j), data);
822 /* Try to replace all non-SET_DEST occurrences of FROM in INSN with TO.
823 Returns nonzero is successful. */
826 try_replace_reg (rtx from, rtx to, rtx insn)
828 rtx note = find_reg_equal_equiv_note (insn);
831 rtx set = single_set (insn);
833 /* Usually we substitute easy stuff, so we won't copy everything.
834 We however need to take care to not duplicate non-trivial CONST
838 validate_replace_src_group (from, to, insn);
839 if (num_changes_pending () && apply_change_group ())
842 /* Try to simplify SET_SRC if we have substituted a constant. */
843 if (success && set && CONSTANT_P (to))
845 src = simplify_rtx (SET_SRC (set));
848 validate_change (insn, &SET_SRC (set), src, 0);
851 /* If there is already a REG_EQUAL note, update the expression in it
852 with our replacement. */
853 if (note != 0 && REG_NOTE_KIND (note) == REG_EQUAL)
854 set_unique_reg_note (insn, REG_EQUAL,
855 simplify_replace_rtx (XEXP (note, 0), from, to));
856 if (!success && set && reg_mentioned_p (from, SET_SRC (set)))
858 /* If above failed and this is a single set, try to simplify the source of
859 the set given our substitution. We could perhaps try this for multiple
860 SETs, but it probably won't buy us anything. */
861 src = simplify_replace_rtx (SET_SRC (set), from, to);
863 if (!rtx_equal_p (src, SET_SRC (set))
864 && validate_change (insn, &SET_SRC (set), src, 0))
867 /* If we've failed perform the replacement, have a single SET to
868 a REG destination and don't yet have a note, add a REG_EQUAL note
869 to not lose information. */
870 if (!success && note == 0 && set != 0 && REG_P (SET_DEST (set)))
871 note = set_unique_reg_note (insn, REG_EQUAL, copy_rtx (src));
874 /* REG_EQUAL may get simplified into register.
875 We don't allow that. Remove that note. This code ought
876 not to happen, because previous code ought to synthesize
877 reg-reg move, but be on the safe side. */
878 if (note && REG_NOTE_KIND (note) == REG_EQUAL && REG_P (XEXP (note, 0)))
879 remove_note (insn, note);
884 /* Find a set of REGNOs that are available on entry to INSN's block. Returns
885 NULL no such set is found. */
888 find_avail_set (int regno, rtx insn)
890 /* SET1 contains the last set found that can be returned to the caller for
891 use in a substitution. */
892 struct expr *set1 = 0;
894 /* Loops are not possible here. To get a loop we would need two sets
895 available at the start of the block containing INSN. i.e. we would
896 need two sets like this available at the start of the block:
898 (set (reg X) (reg Y))
899 (set (reg Y) (reg X))
901 This can not happen since the set of (reg Y) would have killed the
902 set of (reg X) making it unavailable at the start of this block. */
906 struct expr *set = lookup_set (regno, &set_hash_table);
908 /* Find a set that is available at the start of the block
909 which contains INSN. */
912 if (TEST_BIT (cprop_avin[BLOCK_FOR_INSN (insn)->index],
915 set = next_set (regno, set);
918 /* If no available set was found we've reached the end of the
919 (possibly empty) copy chain. */
923 gcc_assert (GET_CODE (set->expr) == SET);
925 src = SET_SRC (set->expr);
927 /* We know the set is available.
928 Now check that SRC is locally anticipatable (i.e. none of the
929 source operands have changed since the start of the block).
931 If the source operand changed, we may still use it for the next
932 iteration of this loop, but we may not use it for substitutions. */
934 if (gcse_constant_p (src) || reg_not_set_p (src, insn))
937 /* If the source of the set is anything except a register, then
938 we have reached the end of the copy chain. */
942 /* Follow the copy chain, i.e. start another iteration of the loop
943 and see if we have an available copy into SRC. */
947 /* SET1 holds the last set that was available and anticipatable at
952 /* Subroutine of cprop_insn that tries to propagate constants into
953 JUMP_INSNS. JUMP must be a conditional jump. If SETCC is non-NULL
954 it is the instruction that immediately precedes JUMP, and must be a
955 single SET of a register. FROM is what we will try to replace,
956 SRC is the constant we will try to substitute for it. Returns nonzero
957 if a change was made. */
960 cprop_jump (basic_block bb, rtx setcc, rtx jump, rtx from, rtx src)
962 rtx new_rtx, set_src, note_src;
963 rtx set = pc_set (jump);
964 rtx note = find_reg_equal_equiv_note (jump);
968 note_src = XEXP (note, 0);
969 if (GET_CODE (note_src) == EXPR_LIST)
972 else note_src = NULL_RTX;
974 /* Prefer REG_EQUAL notes except those containing EXPR_LISTs. */
975 set_src = note_src ? note_src : SET_SRC (set);
977 /* First substitute the SETCC condition into the JUMP instruction,
978 then substitute that given values into this expanded JUMP. */
979 if (setcc != NULL_RTX
980 && !modified_between_p (from, setcc, jump)
981 && !modified_between_p (src, setcc, jump))
984 rtx setcc_set = single_set (setcc);
985 rtx setcc_note = find_reg_equal_equiv_note (setcc);
986 setcc_src = (setcc_note && GET_CODE (XEXP (setcc_note, 0)) != EXPR_LIST)
987 ? XEXP (setcc_note, 0) : SET_SRC (setcc_set);
988 set_src = simplify_replace_rtx (set_src, SET_DEST (setcc_set),
994 new_rtx = simplify_replace_rtx (set_src, from, src);
996 /* If no simplification can be made, then try the next register. */
997 if (rtx_equal_p (new_rtx, SET_SRC (set)))
1000 /* If this is now a no-op delete it, otherwise this must be a valid insn. */
1001 if (new_rtx == pc_rtx)
1005 /* Ensure the value computed inside the jump insn to be equivalent
1006 to one computed by setcc. */
1007 if (setcc && modified_in_p (new_rtx, setcc))
1009 if (! validate_unshare_change (jump, &SET_SRC (set), new_rtx, 0))
1011 /* When (some) constants are not valid in a comparison, and there
1012 are two registers to be replaced by constants before the entire
1013 comparison can be folded into a constant, we need to keep
1014 intermediate information in REG_EQUAL notes. For targets with
1015 separate compare insns, such notes are added by try_replace_reg.
1016 When we have a combined compare-and-branch instruction, however,
1017 we need to attach a note to the branch itself to make this
1018 optimization work. */
1020 if (!rtx_equal_p (new_rtx, note_src))
1021 set_unique_reg_note (jump, REG_EQUAL, copy_rtx (new_rtx));
1025 /* Remove REG_EQUAL note after simplification. */
1027 remove_note (jump, note);
1031 /* Delete the cc0 setter. */
1032 if (setcc != NULL && CC0_P (SET_DEST (single_set (setcc))))
1033 delete_insn (setcc);
1036 global_const_prop_count++;
1037 if (dump_file != NULL)
1040 "GLOBAL CONST-PROP: Replacing reg %d in jump_insn %d with constant ",
1041 REGNO (from), INSN_UID (jump));
1042 print_rtl (dump_file, src);
1043 fprintf (dump_file, "\n");
1045 purge_dead_edges (bb);
1047 /* If a conditional jump has been changed into unconditional jump, remove
1048 the jump and make the edge fallthru - this is always called in
1050 if (new_rtx != pc_rtx && simplejump_p (jump))
1055 FOR_EACH_EDGE (e, ei, bb->succs)
1056 if (e->dest != EXIT_BLOCK_PTR
1057 && BB_HEAD (e->dest) == JUMP_LABEL (jump))
1059 e->flags |= EDGE_FALLTHRU;
1069 constprop_register (rtx insn, rtx from, rtx to)
1073 /* Check for reg or cc0 setting instructions followed by
1074 conditional branch instructions first. */
1075 if ((sset = single_set (insn)) != NULL
1077 && any_condjump_p (NEXT_INSN (insn)) && onlyjump_p (NEXT_INSN (insn)))
1079 rtx dest = SET_DEST (sset);
1080 if ((REG_P (dest) || CC0_P (dest))
1081 && cprop_jump (BLOCK_FOR_INSN (insn), insn, NEXT_INSN (insn), from, to))
1085 /* Handle normal insns next. */
1086 if (NONJUMP_INSN_P (insn)
1087 && try_replace_reg (from, to, insn))
1090 /* Try to propagate a CONST_INT into a conditional jump.
1091 We're pretty specific about what we will handle in this
1092 code, we can extend this as necessary over time.
1094 Right now the insn in question must look like
1095 (set (pc) (if_then_else ...)) */
1096 else if (any_condjump_p (insn) && onlyjump_p (insn))
1097 return cprop_jump (BLOCK_FOR_INSN (insn), NULL, insn, from, to);
1101 /* Perform constant and copy propagation on INSN.
1102 The result is nonzero if a change was made. */
1105 cprop_insn (rtx insn)
1107 struct reg_use *reg_used;
1115 note_uses (&PATTERN (insn), find_used_regs, NULL);
1117 note = find_reg_equal_equiv_note (insn);
1119 /* We may win even when propagating constants into notes. */
1121 find_used_regs (&XEXP (note, 0), NULL);
1123 for (reg_used = ®_use_table[0]; reg_use_count > 0;
1124 reg_used++, reg_use_count--)
1126 unsigned int regno = REGNO (reg_used->reg_rtx);
1130 /* If the register has already been set in this block, there's
1131 nothing we can do. */
1132 if (! reg_not_set_p (reg_used->reg_rtx, insn))
1135 /* Find an assignment that sets reg_used and is available
1136 at the start of the block. */
1137 set = find_avail_set (regno, insn);
1142 /* ??? We might be able to handle PARALLELs. Later. */
1143 gcc_assert (GET_CODE (pat) == SET);
1145 src = SET_SRC (pat);
1147 /* Constant propagation. */
1148 if (gcse_constant_p (src))
1150 if (constprop_register (insn, reg_used->reg_rtx, src))
1153 global_const_prop_count++;
1154 if (dump_file != NULL)
1156 fprintf (dump_file, "GLOBAL CONST-PROP: Replacing reg %d in ", regno);
1157 fprintf (dump_file, "insn %d with constant ", INSN_UID (insn));
1158 print_rtl (dump_file, src);
1159 fprintf (dump_file, "\n");
1161 if (INSN_DELETED_P (insn))
1165 else if (REG_P (src)
1166 && REGNO (src) >= FIRST_PSEUDO_REGISTER
1167 && REGNO (src) != regno)
1169 if (try_replace_reg (reg_used->reg_rtx, src, insn))
1172 global_copy_prop_count++;
1173 if (dump_file != NULL)
1175 fprintf (dump_file, "GLOBAL COPY-PROP: Replacing reg %d in insn %d",
1176 regno, INSN_UID (insn));
1177 fprintf (dump_file, " with reg %d\n", REGNO (src));
1180 /* The original insn setting reg_used may or may not now be
1181 deletable. We leave the deletion to flow. */
1182 /* FIXME: If it turns out that the insn isn't deletable,
1183 then we may have unnecessarily extended register lifetimes
1184 and made things worse. */
1189 if (changed && DEBUG_INSN_P (insn))
1195 /* Like find_used_regs, but avoid recording uses that appear in
1196 input-output contexts such as zero_extract or pre_dec. This
1197 restricts the cases we consider to those for which local cprop
1198 can legitimately make replacements. */
1201 local_cprop_find_used_regs (rtx *xptr, void *data)
1208 switch (GET_CODE (x))
1212 case STRICT_LOW_PART:
1221 /* Can only legitimately appear this early in the context of
1222 stack pushes for function arguments, but handle all of the
1223 codes nonetheless. */
1227 /* Setting a subreg of a register larger than word_mode leaves
1228 the non-written words unchanged. */
1229 if (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (x))) > BITS_PER_WORD)
1237 find_used_regs (xptr, data);
1240 /* Try to perform local const/copy propagation on X in INSN. */
1243 do_local_cprop (rtx x, rtx insn)
1245 rtx newreg = NULL, newcnst = NULL;
1247 /* Rule out USE instructions and ASM statements as we don't want to
1248 change the hard registers mentioned. */
1250 && (REGNO (x) >= FIRST_PSEUDO_REGISTER
1251 || (GET_CODE (PATTERN (insn)) != USE
1252 && asm_noperands (PATTERN (insn)) < 0)))
1254 cselib_val *val = cselib_lookup (x, GET_MODE (x), 0, VOIDmode);
1255 struct elt_loc_list *l;
1259 for (l = val->locs; l; l = l->next)
1261 rtx this_rtx = l->loc;
1264 if (gcse_constant_p (this_rtx))
1266 if (REG_P (this_rtx) && REGNO (this_rtx) >= FIRST_PSEUDO_REGISTER
1267 /* Don't copy propagate if it has attached REG_EQUIV note.
1268 At this point this only function parameters should have
1269 REG_EQUIV notes and if the argument slot is used somewhere
1270 explicitly, it means address of parameter has been taken,
1271 so we should not extend the lifetime of the pseudo. */
1272 && (!(note = find_reg_note (l->setting_insn, REG_EQUIV, NULL_RTX))
1273 || ! MEM_P (XEXP (note, 0))))
1276 if (newcnst && constprop_register (insn, x, newcnst))
1278 if (dump_file != NULL)
1280 fprintf (dump_file, "LOCAL CONST-PROP: Replacing reg %d in ",
1282 fprintf (dump_file, "insn %d with constant ",
1284 print_rtl (dump_file, newcnst);
1285 fprintf (dump_file, "\n");
1287 local_const_prop_count++;
1290 else if (newreg && newreg != x && try_replace_reg (x, newreg, insn))
1292 if (dump_file != NULL)
1295 "LOCAL COPY-PROP: Replacing reg %d in insn %d",
1296 REGNO (x), INSN_UID (insn));
1297 fprintf (dump_file, " with reg %d\n", REGNO (newreg));
1299 local_copy_prop_count++;
1306 /* Do local const/copy propagation (i.e. within each basic block). */
1309 local_cprop_pass (void)
1313 struct reg_use *reg_used;
1314 bool changed = false;
1319 FOR_BB_INSNS (bb, insn)
1323 rtx note = find_reg_equal_equiv_note (insn);
1327 note_uses (&PATTERN (insn), local_cprop_find_used_regs,
1330 local_cprop_find_used_regs (&XEXP (note, 0), NULL);
1332 for (reg_used = ®_use_table[0]; reg_use_count > 0;
1333 reg_used++, reg_use_count--)
1335 if (do_local_cprop (reg_used->reg_rtx, insn))
1341 if (INSN_DELETED_P (insn))
1344 while (reg_use_count);
1346 cselib_process_insn (insn);
1349 /* Forget everything at the end of a basic block. */
1350 cselib_clear_table ();
1358 /* Similar to get_condition, only the resulting condition must be
1359 valid at JUMP, instead of at EARLIEST.
1361 This differs from noce_get_condition in ifcvt.c in that we prefer not to
1362 settle for the condition variable in the jump instruction being integral.
1363 We prefer to be able to record the value of a user variable, rather than
1364 the value of a temporary used in a condition. This could be solved by
1365 recording the value of *every* register scanned by canonicalize_condition,
1366 but this would require some code reorganization. */
1369 fis_get_condition (rtx jump)
1371 return get_condition (jump, NULL, false, true);
1374 /* Check the comparison COND to see if we can safely form an implicit set from
1375 it. COND is either an EQ or NE comparison. */
1378 implicit_set_cond_p (const_rtx cond)
1380 const enum machine_mode mode = GET_MODE (XEXP (cond, 0));
1381 const_rtx cst = XEXP (cond, 1);
1383 /* We can't perform this optimization if either operand might be or might
1384 contain a signed zero. */
1385 if (HONOR_SIGNED_ZEROS (mode))
1387 /* It is sufficient to check if CST is or contains a zero. We must
1388 handle float, complex, and vector. If any subpart is a zero, then
1389 the optimization can't be performed. */
1390 /* ??? The complex and vector checks are not implemented yet. We just
1391 always return zero for them. */
1392 if (GET_CODE (cst) == CONST_DOUBLE)
1395 REAL_VALUE_FROM_CONST_DOUBLE (d, cst);
1396 if (REAL_VALUES_EQUAL (d, dconst0))
1403 return gcse_constant_p (cst);
1406 /* Find the implicit sets of a function. An "implicit set" is a constraint
1407 on the value of a variable, implied by a conditional jump. For example,
1408 following "if (x == 2)", the then branch may be optimized as though the
1409 conditional performed an "explicit set", in this example, "x = 2". This
1410 function records the set patterns that are implicit at the start of each
1413 FIXME: This would be more effective if critical edges are pre-split. As
1414 it is now, we can't record implicit sets for blocks that have
1415 critical successor edges. This results in missed optimizations
1416 and in more (unnecessary) work in cfgcleanup.c:thread_jump(). */
1419 find_implicit_sets (void)
1421 basic_block bb, dest;
1427 /* Check for more than one successor. */
1428 if (EDGE_COUNT (bb->succs) > 1)
1430 cond = fis_get_condition (BB_END (bb));
1433 && (GET_CODE (cond) == EQ || GET_CODE (cond) == NE)
1434 && REG_P (XEXP (cond, 0))
1435 && REGNO (XEXP (cond, 0)) >= FIRST_PSEUDO_REGISTER
1436 && implicit_set_cond_p (cond))
1438 dest = GET_CODE (cond) == EQ ? BRANCH_EDGE (bb)->dest
1439 : FALLTHRU_EDGE (bb)->dest;
1442 /* Record nothing for a critical edge. */
1443 && single_pred_p (dest)
1444 && dest != EXIT_BLOCK_PTR)
1446 new_rtx = gen_rtx_SET (VOIDmode, XEXP (cond, 0),
1448 implicit_sets[dest->index] = new_rtx;
1451 fprintf(dump_file, "Implicit set of reg %d in ",
1452 REGNO (XEXP (cond, 0)));
1453 fprintf(dump_file, "basic block %d\n", dest->index);
1461 fprintf (dump_file, "Found %d implicit sets\n", count);
1464 /* Bypass conditional jumps. */
1466 /* The value of last_basic_block at the beginning of the jump_bypass
1467 pass. The use of redirect_edge_and_branch_force may introduce new
1468 basic blocks, but the data flow analysis is only valid for basic
1469 block indices less than bypass_last_basic_block. */
1471 static int bypass_last_basic_block;
1473 /* Find a set of REGNO to a constant that is available at the end of basic
1474 block BB. Returns NULL if no such set is found. Based heavily upon
1477 static struct expr *
1478 find_bypass_set (int regno, int bb)
1480 struct expr *result = 0;
1485 struct expr *set = lookup_set (regno, &set_hash_table);
1489 if (TEST_BIT (cprop_avout[bb], set->bitmap_index))
1491 set = next_set (regno, set);
1497 gcc_assert (GET_CODE (set->expr) == SET);
1499 src = SET_SRC (set->expr);
1500 if (gcse_constant_p (src))
1506 regno = REGNO (src);
1512 /* Subroutine of bypass_block that checks whether a pseudo is killed by
1513 any of the instructions inserted on an edge. Jump bypassing places
1514 condition code setters on CFG edges using insert_insn_on_edge. This
1515 function is required to check that our data flow analysis is still
1516 valid prior to commit_edge_insertions. */
1519 reg_killed_on_edge (const_rtx reg, const_edge e)
1523 for (insn = e->insns.r; insn; insn = NEXT_INSN (insn))
1524 if (INSN_P (insn) && reg_set_p (reg, insn))
1530 /* Subroutine of bypass_conditional_jumps that attempts to bypass the given
1531 basic block BB which has more than one predecessor. If not NULL, SETCC
1532 is the first instruction of BB, which is immediately followed by JUMP_INSN
1533 JUMP. Otherwise, SETCC is NULL, and JUMP is the first insn of BB.
1534 Returns nonzero if a change was made.
1536 During the jump bypassing pass, we may place copies of SETCC instructions
1537 on CFG edges. The following routine must be careful to pay attention to
1538 these inserted insns when performing its transformations. */
1541 bypass_block (basic_block bb, rtx setcc, rtx jump)
1546 int may_be_loop_header;
1550 insn = (setcc != NULL) ? setcc : jump;
1552 /* Determine set of register uses in INSN. */
1554 note_uses (&PATTERN (insn), find_used_regs, NULL);
1555 note = find_reg_equal_equiv_note (insn);
1557 find_used_regs (&XEXP (note, 0), NULL);
1559 may_be_loop_header = false;
1560 FOR_EACH_EDGE (e, ei, bb->preds)
1561 if (e->flags & EDGE_DFS_BACK)
1563 may_be_loop_header = true;
1568 for (ei = ei_start (bb->preds); (e = ei_safe_edge (ei)); )
1572 if (e->flags & EDGE_COMPLEX)
1578 /* We can't redirect edges from new basic blocks. */
1579 if (e->src->index >= bypass_last_basic_block)
1585 /* The irreducible loops created by redirecting of edges entering the
1586 loop from outside would decrease effectiveness of some of the following
1587 optimizations, so prevent this. */
1588 if (may_be_loop_header
1589 && !(e->flags & EDGE_DFS_BACK))
1595 for (i = 0; i < reg_use_count; i++)
1597 struct reg_use *reg_used = ®_use_table[i];
1598 unsigned int regno = REGNO (reg_used->reg_rtx);
1599 basic_block dest, old_dest;
1603 set = find_bypass_set (regno, e->src->index);
1608 /* Check the data flow is valid after edge insertions. */
1609 if (e->insns.r && reg_killed_on_edge (reg_used->reg_rtx, e))
1612 src = SET_SRC (pc_set (jump));
1615 src = simplify_replace_rtx (src,
1616 SET_DEST (PATTERN (setcc)),
1617 SET_SRC (PATTERN (setcc)));
1619 new_rtx = simplify_replace_rtx (src, reg_used->reg_rtx,
1620 SET_SRC (set->expr));
1622 /* Jump bypassing may have already placed instructions on
1623 edges of the CFG. We can't bypass an outgoing edge that
1624 has instructions associated with it, as these insns won't
1625 get executed if the incoming edge is redirected. */
1627 if (new_rtx == pc_rtx)
1629 edest = FALLTHRU_EDGE (bb);
1630 dest = edest->insns.r ? NULL : edest->dest;
1632 else if (GET_CODE (new_rtx) == LABEL_REF)
1634 dest = BLOCK_FOR_INSN (XEXP (new_rtx, 0));
1635 /* Don't bypass edges containing instructions. */
1636 edest = find_edge (bb, dest);
1637 if (edest && edest->insns.r)
1643 /* Avoid unification of the edge with other edges from original
1644 branch. We would end up emitting the instruction on "both"
1647 if (dest && setcc && !CC0_P (SET_DEST (PATTERN (setcc)))
1648 && find_edge (e->src, dest))
1654 && dest != EXIT_BLOCK_PTR)
1656 redirect_edge_and_branch_force (e, dest);
1658 /* Copy the register setter to the redirected edge.
1659 Don't copy CC0 setters, as CC0 is dead after jump. */
1662 rtx pat = PATTERN (setcc);
1663 if (!CC0_P (SET_DEST (pat)))
1664 insert_insn_on_edge (copy_insn (pat), e);
1667 if (dump_file != NULL)
1669 fprintf (dump_file, "JUMP-BYPASS: Proved reg %d "
1670 "in jump_insn %d equals constant ",
1671 regno, INSN_UID (jump));
1672 print_rtl (dump_file, SET_SRC (set->expr));
1673 fprintf (dump_file, "\nBypass edge from %d->%d to %d\n",
1674 e->src->index, old_dest->index, dest->index);
1687 /* Find basic blocks with more than one predecessor that only contain a
1688 single conditional jump. If the result of the comparison is known at
1689 compile-time from any incoming edge, redirect that edge to the
1690 appropriate target. Returns nonzero if a change was made.
1692 This function is now mis-named, because we also handle indirect jumps. */
1695 bypass_conditional_jumps (void)
1703 /* Note we start at block 1. */
1704 if (ENTRY_BLOCK_PTR->next_bb == EXIT_BLOCK_PTR)
1707 bypass_last_basic_block = last_basic_block;
1708 mark_dfs_back_edges ();
1711 FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR->next_bb->next_bb,
1712 EXIT_BLOCK_PTR, next_bb)
1714 /* Check for more than one predecessor. */
1715 if (!single_pred_p (bb))
1718 FOR_BB_INSNS (bb, insn)
1719 if (DEBUG_INSN_P (insn))
1721 else if (NONJUMP_INSN_P (insn))
1725 if (GET_CODE (PATTERN (insn)) != SET)
1728 dest = SET_DEST (PATTERN (insn));
1729 if (REG_P (dest) || CC0_P (dest))
1734 else if (JUMP_P (insn))
1736 if ((any_condjump_p (insn) || computed_jump_p (insn))
1737 && onlyjump_p (insn))
1738 changed |= bypass_block (bb, setcc, insn);
1741 else if (INSN_P (insn))
1746 /* If we bypassed any register setting insns, we inserted a
1747 copy on the redirected edge. These need to be committed. */
1749 commit_edge_insertions ();
1754 /* Return true if the graph is too expensive to optimize. PASS is the
1755 optimization about to be performed. */
1758 is_too_expensive (const char *pass)
1760 /* Trying to perform global optimizations on flow graphs which have
1761 a high connectivity will take a long time and is unlikely to be
1762 particularly useful.
1764 In normal circumstances a cfg should have about twice as many
1765 edges as blocks. But we do not want to punish small functions
1766 which have a couple switch statements. Rather than simply
1767 threshold the number of blocks, uses something with a more
1768 graceful degradation. */
1769 if (n_edges > 20000 + n_basic_blocks * 4)
1771 warning (OPT_Wdisabled_optimization,
1772 "%s: %d basic blocks and %d edges/basic block",
1773 pass, n_basic_blocks, n_edges / n_basic_blocks);
1778 /* If allocating memory for the cprop bitmap would take up too much
1779 storage it's better just to disable the optimization. */
1781 * SBITMAP_SET_SIZE (max_reg_num ())
1782 * sizeof (SBITMAP_ELT_TYPE)) > MAX_GCSE_MEMORY)
1784 warning (OPT_Wdisabled_optimization,
1785 "%s: %d basic blocks and %d registers",
1786 pass, n_basic_blocks, max_reg_num ());
1795 /* Main function for the CPROP pass. */
1798 one_cprop_pass (void)
1802 /* Return if there's nothing to do, or it is too expensive. */
1803 if (n_basic_blocks <= NUM_FIXED_BLOCKS + 1
1804 || is_too_expensive (_ ("const/copy propagation disabled")))
1807 global_const_prop_count = local_const_prop_count = 0;
1808 global_copy_prop_count = local_copy_prop_count = 0;
1811 gcc_obstack_init (&gcse_obstack);
1814 /* Do a local const/copy propagation pass first. The global pass
1815 only handles global opportunities.
1816 If the local pass changes something, remove any unreachable blocks
1817 because the CPROP global dataflow analysis may get into infinite
1818 loops for CFGs with unreachable blocks.
1820 FIXME: This local pass should not be necessary after CSE (but for
1821 some reason it still is). It is also (proven) not necessary
1822 to run the local pass right after FWPWOP.
1824 FIXME: The global analysis would not get into infinite loops if it
1825 would use the DF solver (via df_simple_dataflow) instead of
1826 the solver implemented in this file. */
1827 if (local_cprop_pass ())
1829 delete_unreachable_blocks ();
1833 /* Determine implicit sets. */
1834 implicit_sets = XCNEWVEC (rtx, last_basic_block);
1835 find_implicit_sets ();
1837 alloc_hash_table (&set_hash_table);
1838 compute_hash_table (&set_hash_table);
1840 /* Free implicit_sets before peak usage. */
1841 free (implicit_sets);
1842 implicit_sets = NULL;
1845 dump_hash_table (dump_file, "SET", &set_hash_table);
1846 if (set_hash_table.n_elems > 0)
1851 alloc_cprop_mem (last_basic_block, set_hash_table.n_elems);
1852 compute_cprop_data ();
1854 FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR->next_bb->next_bb, EXIT_BLOCK_PTR, next_bb)
1856 /* Reset tables used to keep track of what's still valid [since
1857 the start of the block]. */
1858 reset_opr_set_tables ();
1860 FOR_BB_INSNS (bb, insn)
1863 changed |= cprop_insn (insn);
1865 /* Keep track of everything modified by this insn. */
1866 /* ??? Need to be careful w.r.t. mods done to INSN.
1867 Don't call mark_oprs_set if we turned the
1868 insn into a NOTE. */
1869 if (! NOTE_P (insn))
1870 mark_oprs_set (insn);
1874 changed |= bypass_conditional_jumps ();
1878 free_hash_table (&set_hash_table);
1880 obstack_free (&gcse_obstack, NULL);
1884 fprintf (dump_file, "CPROP of %s, %d basic blocks, %d bytes needed, ",
1885 current_function_name (), n_basic_blocks, bytes_used);
1886 fprintf (dump_file, "%d local const props, %d local copy props, ",
1887 local_const_prop_count, local_copy_prop_count);
1888 fprintf (dump_file, "%d global const props, %d global copy props\n\n",
1889 global_const_prop_count, global_copy_prop_count);
1896 /* All the passes implemented in this file. Each pass has its
1897 own gate and execute function, and at the end of the file a
1898 pass definition for passes.c.
1900 We do not construct an accurate cfg in functions which call
1901 setjmp, so none of these passes runs if the function calls
1903 FIXME: Should just handle setjmp via REG_SETJMP notes. */
1906 gate_rtl_cprop (void)
1908 return optimize > 0 && flag_gcse
1909 && !cfun->calls_setjmp
1914 execute_rtl_cprop (void)
1917 delete_unreachable_blocks ();
1918 df_set_flags (DF_LR_RUN_DCE);
1920 changed = one_cprop_pass ();
1921 flag_rerun_cse_after_global_opts |= changed;
1927 struct rtl_opt_pass pass_rtl_cprop =
1932 gate_rtl_cprop, /* gate */
1933 execute_rtl_cprop, /* execute */
1936 0, /* static_pass_number */
1937 TV_CPROP, /* tv_id */
1938 PROP_cfglayout, /* properties_required */
1939 0, /* properties_provided */
1940 0, /* properties_destroyed */
1941 0, /* todo_flags_start */
1942 TODO_df_finish | TODO_verify_rtl_sharing |
1944 TODO_verify_flow | TODO_ggc_collect /* todo_flags_finish */