Hi, This is a boring one. An almost-perfect %s/gcse/cprop/g except for flag_gcse, and a few other random cleanups. Hardly noteworthy. This goes in after the cprop_cleanup_2.diff patch as obvious unless someone objects.
Ciao! Steven
* cprop.c: s/gcse/cprop/ everywhere except for flag_gcse. (gcse_obstack): Renamed to cprop_obstack. (GNEW, GNEWVEC, GNEWVAR): Remove. (gmalloc): Remove. (alloc_hash_table): Use XNEWVAR instead of GNEWVAR. (GOBNEW, GOBNEWVAR): Adjust for gcse_obstack renaming. (gcse_alloc): Likewise, and rename to cprop_alloc. (alloc_gcse_men, free_gcse_mem): Remove. (gcse_constant_p): Rename to cprop_constant_p, and adjust all callers. (compute_hash_table_work): Allocate and free reg_set_bitmap here. (one_cprop_pass): Likewise. Adjust for gcse_obstack renaming. *** cprop.c.v3 2011-03-31 23:16:27.000000000 +0200 --- cprop.c 2011-03-31 23:26:06.000000000 +0200 *************** along with GCC; see the file COPYING3. *** 51,57 **** /* An obstack for our working variables. */ ! static struct obstack gcse_obstack; struct reg_use {rtx reg_rtx; }; --- 51,57 ---- /* An obstack for our working variables. */ ! static struct obstack cprop_obstack; struct reg_use {rtx reg_rtx; }; *************** static int global_const_prop_count; *** 138,186 **** static int global_copy_prop_count; ! #define GNEW(T) ((T *) gmalloc (sizeof (T))) ! ! #define GNEWVEC(T, N) ((T *) gmalloc (sizeof (T) * (N))) ! ! #define GNEWVAR(T, S) ((T *) gmalloc ((S))) ! ! #define GOBNEW(T) ((T *) gcse_alloc (sizeof (T))) ! #define GOBNEWVAR(T, S) ((T *) gcse_alloc ((S))) ! ! /* Cover function to xmalloc to record bytes allocated. */ ! ! static void * ! gmalloc (size_t size) ! { ! bytes_used += size; ! return xmalloc (size); ! } /* Cover function to obstack_alloc. */ static void * ! gcse_alloc (unsigned long size) { bytes_used += size; ! return obstack_alloc (&gcse_obstack, size); ! } ! ! /* Allocate memory for the reg/memory set tracking tables. ! This is called at the start of each pass. */ ! ! static void ! alloc_gcse_mem (void) ! { ! /* Allocate vars to track sets of regs. */ ! reg_set_bitmap = ALLOC_REG_SET (NULL); ! } ! ! /* Free memory allocated by alloc_gcse_mem. */ ! ! static void ! free_gcse_mem (void) ! { ! FREE_REG_SET (reg_set_bitmap); } /* Return nonzero if register X is unchanged from INSN to the end --- 138,153 ---- static int global_copy_prop_count; ! #define GOBNEW(T) ((T *) cprop_alloc (sizeof (T))) ! #define GOBNEWVAR(T, S) ((T *) cprop_alloc ((S))) /* Cover function to obstack_alloc. */ static void * ! cprop_alloc (unsigned long size) { bytes_used += size; ! return obstack_alloc (&cprop_obstack, size); } /* Return nonzero if register X is unchanged from INSN to the end *************** insert_set_in_table (rtx x, rtx insn, st *** 292,298 **** is sharable. */ static bool ! gcse_constant_p (const_rtx x) { return CONSTANT_P (x) && (GET_CODE (x) != CONST || shared_const_p (x)); } --- 259,265 ---- is sharable. */ static bool ! cprop_constant_p (const_rtx x) { return CONSTANT_P (x) && (GET_CODE (x) != CONST || shared_const_p (x)); } *************** hash_scan_set (rtx pat, rtx insn, struct *** 328,334 **** if (note != 0 && REG_NOTE_KIND (note) == REG_EQUAL && !REG_P (src) ! && gcse_constant_p (XEXP (note, 0))) src = XEXP (note, 0), pat = gen_rtx_SET (VOIDmode, dest, src); /* Record sets for constant/copy propagation. */ --- 295,301 ---- if (note != 0 && REG_NOTE_KIND (note) == REG_EQUAL && !REG_P (src) ! && cprop_constant_p (XEXP (note, 0))) src = XEXP (note, 0), pat = gen_rtx_SET (VOIDmode, dest, src); /* Record sets for constant/copy propagation. */ *************** hash_scan_set (rtx pat, rtx insn, struct *** 336,342 **** && src != dest && ! HARD_REGISTER_P (src) && reg_available_p (src, insn)) ! || gcse_constant_p (src)) insert_set_in_table (pat, insn, table); } } --- 303,309 ---- && src != dest && ! HARD_REGISTER_P (src) && reg_available_p (src, insn)) ! || cprop_constant_p (src)) insert_set_in_table (pat, insn, table); } } *************** compute_hash_table_work (struct hash_tab *** 438,443 **** --- 405,413 ---- { basic_block bb; + /* Allocate vars to track sets of regs. */ + reg_set_bitmap = ALLOC_REG_SET (NULL); + FOR_EACH_BB (bb) { rtx insn; *************** compute_hash_table_work (struct hash_tab *** 467,472 **** --- 437,444 ---- if (implicit_sets[bb->index] != NULL_RTX) hash_scan_set (implicit_sets[bb->index], BB_HEAD (bb), table); } + + FREE_REG_SET (reg_set_bitmap); } /* Allocate space for the set/expr hash TABLE. *************** alloc_hash_table (struct hash_table_d *t *** 488,494 **** ??? Later take some measurements. */ table->size |= 1; n = table->size * sizeof (struct expr *); ! table->table = GNEWVAR (struct expr *, n); } /* Free things allocated by alloc_hash_table. */ --- 460,466 ---- ??? Later take some measurements. */ table->size |= 1; n = table->size * sizeof (struct expr *); ! table->table = XNEWVAR (struct expr *, n); } /* Free things allocated by alloc_hash_table. */ *************** find_avail_set (int regno, rtx insn) *** 931,937 **** If the source operand changed, we may still use it for the next iteration of this loop, but we may not use it for substitutions. */ ! if (gcse_constant_p (src) || reg_not_set_p (src, insn)) set1 = set; /* If the source of the set is anything except a register, then --- 903,909 ---- If the source operand changed, we may still use it for the next iteration of this loop, but we may not use it for substitutions. */ ! if (cprop_constant_p (src) || reg_not_set_p (src, insn)) set1 = set; /* If the source of the set is anything except a register, then *************** cprop_insn (rtx insn) *** 1145,1151 **** src = SET_SRC (pat); /* Constant propagation. */ ! if (gcse_constant_p (src)) { if (constprop_register (insn, reg_used->reg_rtx, src)) { --- 1117,1123 ---- src = SET_SRC (pat); /* Constant propagation. */ ! if (cprop_constant_p (src)) { if (constprop_register (insn, reg_used->reg_rtx, src)) { *************** do_local_cprop (rtx x, rtx insn) *** 1261,1267 **** rtx this_rtx = l->loc; rtx note; ! if (gcse_constant_p (this_rtx)) newcnst = this_rtx; if (REG_P (this_rtx) && REGNO (this_rtx) >= FIRST_PSEUDO_REGISTER /* Don't copy propagate if it has attached REG_EQUIV note. --- 1233,1239 ---- rtx this_rtx = l->loc; rtx note; ! if (cprop_constant_p (this_rtx)) newcnst = this_rtx; if (REG_P (this_rtx) && REGNO (this_rtx) >= FIRST_PSEUDO_REGISTER /* Don't copy propagate if it has attached REG_EQUIV note. *************** implicit_set_cond_p (const_rtx cond) *** 1400,1406 **** return 0; } ! return gcse_constant_p (cst); } /* Find the implicit sets of a function. An "implicit set" is a constraint --- 1372,1378 ---- return 0; } ! return cprop_constant_p (cst); } /* Find the implicit sets of a function. An "implicit set" is a constraint *************** find_bypass_set (int regno, int bb) *** 1497,1503 **** gcc_assert (GET_CODE (set->expr) == SET); src = SET_SRC (set->expr); ! if (gcse_constant_p (src)) result = set; if (! REG_P (src)) --- 1469,1475 ---- gcc_assert (GET_CODE (set->expr) == SET); src = SET_SRC (set->expr); ! if (cprop_constant_p (src)) result = set; if (! REG_P (src)) *************** one_cprop_pass (void) *** 1808,1815 **** global_copy_prop_count = local_copy_prop_count = 0; bytes_used = 0; ! gcc_obstack_init (&gcse_obstack); ! alloc_gcse_mem (); /* Do a local const/copy propagation pass first. The global pass only handles global opportunities. --- 1780,1786 ---- global_copy_prop_count = local_copy_prop_count = 0; bytes_used = 0; ! gcc_obstack_init (&cprop_obstack); /* Do a local const/copy propagation pass first. The global pass only handles global opportunities. *************** one_cprop_pass (void) *** 1824,1830 **** FIXME: The global analysis would not get into infinite loops if it would use the DF solver (via df_simple_dataflow) instead of the solver implemented in this file. */ ! if (local_cprop_pass ()) { delete_unreachable_blocks (); df_analyze (); --- 1795,1802 ---- FIXME: The global analysis would not get into infinite loops if it would use the DF solver (via df_simple_dataflow) instead of the solver implemented in this file. */ ! changed |= local_cprop_pass (); ! if (changed) { delete_unreachable_blocks (); df_analyze (); *************** one_cprop_pass (void) *** 1851,1856 **** --- 1823,1831 ---- alloc_cprop_mem (last_basic_block, set_hash_table.n_elems); compute_cprop_data (); + /* Allocate vars to track sets of regs. */ + reg_set_bitmap = ALLOC_REG_SET (NULL); + FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR->next_bb->next_bb, EXIT_BLOCK_PTR, next_bb) { /* Reset tables used to keep track of what's still valid [since *************** one_cprop_pass (void) *** 1872,1883 **** } changed |= bypass_conditional_jumps (); free_cprop_mem (); } free_hash_table (&set_hash_table); ! free_gcse_mem (); ! obstack_free (&gcse_obstack, NULL); if (dump_file) { --- 1847,1859 ---- } changed |= bypass_conditional_jumps (); + + FREE_REG_SET (reg_set_bitmap); free_cprop_mem (); } free_hash_table (&set_hash_table); ! obstack_free (&cprop_obstack, NULL); if (dump_file) {