4deef538ec
PR debug/43092 PR rtl-optimization/43494 * rtl.h (for_each_inc_dec_fn): New type. (for_each_inc_dec): Declare. * rtlanal.c (struct for_each_inc_dec_ops): New type. (for_each_inc_dec_find_inc_dec): New fn. (for_each_inc_dec_find_mem): New fn. (for_each_inc_dec): New fn. * dse.c (struct insn_size): Remove. (replace_inc_dec, replace_inc_dec_mem): Remove. (emit_inc_dec_insn_before): New fn. (check_for_inc_dec): Use it, along with for_each_inc_dec. (canon_address): Pass mem modes to cselib_lookup. * cselib.h (cselib_lookup): Add memmode argument. Adjust callers. (cselib_lookup_from_insn): Likewise. (cselib_subst_to_values): Likewise. * cselib.c (find_slot_memmode): New var. (cselib_find_slot): New fn. Use it instead of htab_find_slot_with_hash everywhere. (entry_and_rtx_equal_p): Use find_slot_memmode. (autoinc_split): New fn. (rtx_equal_for_cselib_p): Rename and implement in terms of... (rtx_equal_for_cselib_1): ... this. Take memmode, pass it on. Deal with autoinc. Special-case recursion into MEMs. (cselib_hash_rtx): Likewise. (cselib_lookup_mem): Infer pmode from address mode. Distinguish address and MEM modes. (cselib_subst_to_values): Add memmode, pass it on. Deal with autoinc. (cselib_lookup): Add memmode argument, pass it on. (cselib_lookup_from_insn): Add memmode. (cselib_invalidate_rtx): Discard obsolete push_operand handling. (struct cselib_record_autoinc_data): New. (cselib_record_autoinc_cb): New fn. (cselib_record_sets): Use it, along with for_each_inc_dec. Pass MEM mode to cselib_lookup. Reset autoinced REGs here instead of... (cselib_process_insn): ... here. * var-tracking.c (replace_expr_with_values, use_type): Pass MEM mode to cselib_lookup. (add_uses): Likewise, also to cselib_subst_to_values. (add_stores): Likewise. * sched-deps.c (add_insn_mem_dependence): Pass mode to cselib_subst_to_values. (sched_analyze_1, sched_analyze_2): Likewise. Adjusted. * gcse.c (do_local_cprop): Adjusted. * postreload.c (reload_cse_simplify_set): Adjusted. (reload_cse_simplify_operands): Adjusted. * sel-sched-dump (debug_mem_addr_value): Pass mode. From-SVN: r169782
101 lines
3.3 KiB
C
101 lines
3.3 KiB
C
/* Common subexpression elimination for GNU compiler.
|
|
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
|
|
1998, 1999, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
|
|
Free Software Foundation, Inc.
|
|
|
|
This file is part of GCC.
|
|
|
|
GCC is free software; you can redistribute it and/or modify it under
|
|
the terms of the GNU General Public License as published by the Free
|
|
Software Foundation; either version 3, or (at your option) any later
|
|
version.
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with GCC; see the file COPYING3. If not see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
/* Describe a value. */
|
|
typedef struct cselib_val_struct {
|
|
/* The hash value. */
|
|
unsigned int hash;
|
|
|
|
/* A unique id assigned to values. */
|
|
int uid;
|
|
|
|
/* A VALUE rtx that points back to this structure. */
|
|
rtx val_rtx;
|
|
|
|
/* All rtl expressions that hold this value at the current time during a
|
|
scan. */
|
|
struct elt_loc_list *locs;
|
|
|
|
/* If this value is used as an address, points to a list of values that
|
|
use it as an address in a MEM. */
|
|
struct elt_list *addr_list;
|
|
|
|
struct cselib_val_struct *next_containing_mem;
|
|
} cselib_val;
|
|
|
|
/* A list of rtl expressions that hold the same value. */
|
|
struct elt_loc_list {
|
|
/* Next element in the list. */
|
|
struct elt_loc_list *next;
|
|
/* An rtl expression that holds the value. */
|
|
rtx loc;
|
|
/* The insn that made the equivalence. */
|
|
rtx setting_insn;
|
|
};
|
|
|
|
/* Describe a single set that is part of an insn. */
|
|
struct cselib_set
|
|
{
|
|
rtx src;
|
|
rtx dest;
|
|
cselib_val *src_elt;
|
|
cselib_val *dest_addr_elt;
|
|
};
|
|
|
|
enum cselib_record_what
|
|
{
|
|
CSELIB_RECORD_MEMORY = 1,
|
|
CSELIB_PRESERVE_CONSTANTS = 2
|
|
};
|
|
|
|
extern void (*cselib_discard_hook) (cselib_val *);
|
|
extern void (*cselib_record_sets_hook) (rtx insn, struct cselib_set *sets,
|
|
int n_sets);
|
|
|
|
extern cselib_val *cselib_lookup (rtx, enum machine_mode,
|
|
int, enum machine_mode);
|
|
extern cselib_val *cselib_lookup_from_insn (rtx, enum machine_mode,
|
|
int, enum machine_mode, rtx);
|
|
extern void cselib_init (int);
|
|
extern void cselib_clear_table (void);
|
|
extern void cselib_finish (void);
|
|
extern void cselib_process_insn (rtx);
|
|
extern enum machine_mode cselib_reg_set_mode (const_rtx);
|
|
extern int rtx_equal_for_cselib_p (rtx, rtx);
|
|
extern int references_value_p (const_rtx, int);
|
|
extern rtx cselib_expand_value_rtx (rtx, bitmap, int);
|
|
typedef rtx (*cselib_expand_callback)(rtx, bitmap, int, void *);
|
|
extern rtx cselib_expand_value_rtx_cb (rtx, bitmap, int,
|
|
cselib_expand_callback, void *);
|
|
extern bool cselib_dummy_expand_value_rtx_cb (rtx, bitmap, int,
|
|
cselib_expand_callback, void *);
|
|
extern rtx cselib_subst_to_values (rtx, enum machine_mode);
|
|
extern void cselib_invalidate_rtx (rtx);
|
|
|
|
extern void cselib_reset_table (unsigned int);
|
|
extern unsigned int cselib_get_next_uid (void);
|
|
extern void cselib_preserve_value (cselib_val *);
|
|
extern bool cselib_preserved_value_p (cselib_val *);
|
|
extern void cselib_preserve_only_values (void);
|
|
extern void cselib_preserve_cfa_base_value (cselib_val *, unsigned int);
|
|
|
|
extern void dump_cselib_table (FILE *);
|