cse.c: Use rtx_insn

gcc/
	* cse.c (struct qty_table_elem): Strengthen field "const_insn"
	from rtx to rtx_insn *.
	(struct change_cc_mode_args): Likewise for field "insn".
	(this_insn): Strengthen from rtx to rtx_insn *.
	(make_new_qty): Replace use of NULL_RTX with NULL when dealing
	with insn.
	(validate_canon_reg): Strengthen param "insn" from rtx to
	rtx_insn *.
	(canon_reg): Likewise.
	(fold_rtx): Likewise.  Replace use of NULL_RTX with NULL when
	dealing with insn.
	(record_jump_equiv): Strengthen param "insn" from rtx to
	rtx_insn *.
	(try_back_substitute_reg): Likewise, also for locals "prev",
	"bb_head".
	(find_sets_in_insn): Likewise for param "insn".
	(canonicalize_insn): Likewise.
	(cse_insn): Likewise.  Add a checked cast.
	(invalidate_from_clobbers): Likewise for param "insn".
	(invalidate_from_sets_and_clobbers): Likewise.
	(cse_process_notes_1): Replace use of NULL_RTX with NULL when
	dealing with insn.
	(cse_prescan_path): Strengthen local "insn" from rtx to
	rtx_insn *.
	(cse_extended_basic_block): Likewise for locals "insn" and
	"prev_insn".
	(cse_main): Likewise for param "f".
	(check_for_label_ref): Likewise for local "insn".
	(set_live_p): Likewise for second param ("insn").
	(insn_live_p): Likewise for first param ("insn") and for local
	"next".
	(cse_change_cc_mode_insn): Likewise for first param "insn".
	(cse_change_cc_mode_insns): Likewise for first and second params
	"start" and "end".
	(cse_cc_succs): Likewise for locals "insns", "last_insns", "insn"
	and "end".
	(cse_condition_code_reg): Likewise for locals "last_insn", "insn",
	"cc_src_insn".

From-SVN: r214315
This commit is contained in:
David Malcolm 2014-08-22 14:05:24 +00:00 committed by David Malcolm
parent 7e114fadf1
commit 204688845f
2 changed files with 91 additions and 49 deletions

View File

@ -1,3 +1,44 @@
2014-08-22 David Malcolm <dmalcolm@redhat.com>
* cse.c (struct qty_table_elem): Strengthen field "const_insn"
from rtx to rtx_insn *.
(struct change_cc_mode_args): Likewise for field "insn".
(this_insn): Strengthen from rtx to rtx_insn *.
(make_new_qty): Replace use of NULL_RTX with NULL when dealing
with insn.
(validate_canon_reg): Strengthen param "insn" from rtx to
rtx_insn *.
(canon_reg): Likewise.
(fold_rtx): Likewise. Replace use of NULL_RTX with NULL when
dealing with insn.
(record_jump_equiv): Strengthen param "insn" from rtx to
rtx_insn *.
(try_back_substitute_reg): Likewise, also for locals "prev",
"bb_head".
(find_sets_in_insn): Likewise for param "insn".
(canonicalize_insn): Likewise.
(cse_insn): Likewise. Add a checked cast.
(invalidate_from_clobbers): Likewise for param "insn".
(invalidate_from_sets_and_clobbers): Likewise.
(cse_process_notes_1): Replace use of NULL_RTX with NULL when
dealing with insn.
(cse_prescan_path): Strengthen local "insn" from rtx to
rtx_insn *.
(cse_extended_basic_block): Likewise for locals "insn" and
"prev_insn".
(cse_main): Likewise for param "f".
(check_for_label_ref): Likewise for local "insn".
(set_live_p): Likewise for second param ("insn").
(insn_live_p): Likewise for first param ("insn") and for local
"next".
(cse_change_cc_mode_insn): Likewise for first param "insn".
(cse_change_cc_mode_insns): Likewise for first and second params
"start" and "end".
(cse_cc_succs): Likewise for locals "insns", "last_insns", "insn"
and "end".
(cse_condition_code_reg): Likewise for locals "last_insn", "insn",
"cc_src_insn".
2014-08-22 Alexander Ivchenko <alexander.ivchenko@intel.com> 2014-08-22 Alexander Ivchenko <alexander.ivchenko@intel.com>
Maxim Kuznetsov <maxim.kuznetsov@intel.com> Maxim Kuznetsov <maxim.kuznetsov@intel.com>
Anna Tikhonova <anna.tikhonova@intel.com> Anna Tikhonova <anna.tikhonova@intel.com>

View File

@ -241,7 +241,7 @@ static int next_qty;
struct qty_table_elem struct qty_table_elem
{ {
rtx const_rtx; rtx const_rtx;
rtx const_insn; rtx_insn *const_insn;
rtx comparison_const; rtx comparison_const;
int comparison_qty; int comparison_qty;
unsigned int first_reg, last_reg; unsigned int first_reg, last_reg;
@ -258,7 +258,7 @@ static struct qty_table_elem *qty_table;
cse_change_cc_mode. */ cse_change_cc_mode. */
struct change_cc_mode_args struct change_cc_mode_args
{ {
rtx insn; rtx_insn *insn;
rtx newreg; rtx newreg;
}; };
@ -278,7 +278,7 @@ static enum machine_mode this_insn_cc0_mode, prev_insn_cc0_mode;
/* Insn being scanned. */ /* Insn being scanned. */
static rtx this_insn; static rtx_insn *this_insn;
static bool optimize_this_for_speed_p; static bool optimize_this_for_speed_p;
/* Index by register number, gives the number of the next (or /* Index by register number, gives the number of the next (or
@ -582,19 +582,19 @@ static inline unsigned canon_hash (rtx, enum machine_mode);
static inline unsigned safe_hash (rtx, enum machine_mode); static inline unsigned safe_hash (rtx, enum machine_mode);
static inline unsigned hash_rtx_string (const char *); static inline unsigned hash_rtx_string (const char *);
static rtx canon_reg (rtx, rtx); static rtx canon_reg (rtx, rtx_insn *);
static enum rtx_code find_comparison_args (enum rtx_code, rtx *, rtx *, static enum rtx_code find_comparison_args (enum rtx_code, rtx *, rtx *,
enum machine_mode *, enum machine_mode *,
enum machine_mode *); enum machine_mode *);
static rtx fold_rtx (rtx, rtx); static rtx fold_rtx (rtx, rtx_insn *);
static rtx equiv_constant (rtx); static rtx equiv_constant (rtx);
static void record_jump_equiv (rtx, bool); static void record_jump_equiv (rtx_insn *, bool);
static void record_jump_cond (enum rtx_code, enum machine_mode, rtx, rtx, static void record_jump_cond (enum rtx_code, enum machine_mode, rtx, rtx,
int); int);
static void cse_insn (rtx); static void cse_insn (rtx_insn *);
static void cse_prescan_path (struct cse_basic_block_data *); static void cse_prescan_path (struct cse_basic_block_data *);
static void invalidate_from_clobbers (rtx); static void invalidate_from_clobbers (rtx_insn *);
static void invalidate_from_sets_and_clobbers (rtx); static void invalidate_from_sets_and_clobbers (rtx_insn *);
static rtx cse_process_notes (rtx, rtx, bool *); static rtx cse_process_notes (rtx, rtx, bool *);
static void cse_extended_basic_block (struct cse_basic_block_data *); static void cse_extended_basic_block (struct cse_basic_block_data *);
static int check_for_label_ref (rtx *, void *); static int check_for_label_ref (rtx *, void *);
@ -604,11 +604,11 @@ static struct cse_reg_info * get_cse_reg_info (unsigned int regno);
static int check_dependence (rtx *, void *); static int check_dependence (rtx *, void *);
static void flush_hash_table (void); static void flush_hash_table (void);
static bool insn_live_p (rtx, int *); static bool insn_live_p (rtx_insn *, int *);
static bool set_live_p (rtx, rtx, int *); static bool set_live_p (rtx, rtx_insn *, int *);
static int cse_change_cc_mode (rtx *, void *); static int cse_change_cc_mode (rtx *, void *);
static void cse_change_cc_mode_insn (rtx, rtx); static void cse_change_cc_mode_insn (rtx_insn *, rtx);
static void cse_change_cc_mode_insns (rtx, rtx, rtx); static void cse_change_cc_mode_insns (rtx_insn *, rtx_insn *, rtx);
static enum machine_mode cse_cc_succs (basic_block, basic_block, rtx, rtx, static enum machine_mode cse_cc_succs (basic_block, basic_block, rtx, rtx,
bool); bool);
@ -904,7 +904,7 @@ make_new_qty (unsigned int reg, enum machine_mode mode)
ent->first_reg = reg; ent->first_reg = reg;
ent->last_reg = reg; ent->last_reg = reg;
ent->mode = mode; ent->mode = mode;
ent->const_rtx = ent->const_insn = NULL_RTX; ent->const_rtx = ent->const_insn = NULL;
ent->comparison_code = UNKNOWN; ent->comparison_code = UNKNOWN;
eqv = &reg_eqv_table[reg]; eqv = &reg_eqv_table[reg];
@ -2801,7 +2801,7 @@ exp_equiv_p (const_rtx x, const_rtx y, int validate, bool for_gcse)
the result if necessary. INSN is as for canon_reg. */ the result if necessary. INSN is as for canon_reg. */
static void static void
validate_canon_reg (rtx *xloc, rtx insn) validate_canon_reg (rtx *xloc, rtx_insn *insn)
{ {
if (*xloc) if (*xloc)
{ {
@ -2825,7 +2825,7 @@ validate_canon_reg (rtx *xloc, rtx insn)
generally be discarded since the changes we are making are optional. */ generally be discarded since the changes we are making are optional. */
static rtx static rtx
canon_reg (rtx x, rtx insn) canon_reg (rtx x, rtx_insn *insn)
{ {
int i; int i;
enum rtx_code code; enum rtx_code code;
@ -3104,7 +3104,7 @@ find_comparison_args (enum rtx_code code, rtx *parg1, rtx *parg2,
of X before modifying it. */ of X before modifying it. */
static rtx static rtx
fold_rtx (rtx x, rtx insn) fold_rtx (rtx x, rtx_insn *insn)
{ {
enum rtx_code code; enum rtx_code code;
enum machine_mode mode; enum machine_mode mode;
@ -3580,7 +3580,7 @@ fold_rtx (rtx x, rtx insn)
for (p = p->first_same_value; p; p = p->next_same_value) for (p = p->first_same_value; p; p = p->next_same_value)
if (REG_P (p->exp)) if (REG_P (p->exp))
return simplify_gen_binary (MINUS, mode, folded_arg0, return simplify_gen_binary (MINUS, mode, folded_arg0,
canon_reg (p->exp, NULL_RTX)); canon_reg (p->exp, NULL));
} }
goto from_plus; goto from_plus;
@ -3593,7 +3593,7 @@ fold_rtx (rtx x, rtx insn)
if (y && CONST_INT_P (XEXP (y, 1))) if (y && CONST_INT_P (XEXP (y, 1)))
return fold_rtx (plus_constant (mode, copy_rtx (y), return fold_rtx (plus_constant (mode, copy_rtx (y),
-INTVAL (const_arg1)), -INTVAL (const_arg1)),
NULL_RTX); NULL);
} }
/* Fall through. */ /* Fall through. */
@ -3858,7 +3858,7 @@ equiv_constant (rtx x)
comparison is seen later, we will know its value. */ comparison is seen later, we will know its value. */
static void static void
record_jump_equiv (rtx insn, bool taken) record_jump_equiv (rtx_insn *insn, bool taken)
{ {
int cond_known_true; int cond_known_true;
rtx op0, op1; rtx op0, op1;
@ -4185,7 +4185,7 @@ struct set
This is the last transformation that cse_insn will try to do. */ This is the last transformation that cse_insn will try to do. */
static void static void
try_back_substitute_reg (rtx set, rtx insn) try_back_substitute_reg (rtx set, rtx_insn *insn)
{ {
rtx dest = SET_DEST (set); rtx dest = SET_DEST (set);
rtx src = SET_SRC (set); rtx src = SET_SRC (set);
@ -4201,8 +4201,8 @@ try_back_substitute_reg (rtx set, rtx insn)
{ {
/* Scan for the previous nonnote insn, but stop at a basic /* Scan for the previous nonnote insn, but stop at a basic
block boundary. */ block boundary. */
rtx prev = insn; rtx_insn *prev = insn;
rtx bb_head = BB_HEAD (BLOCK_FOR_INSN (insn)); rtx_insn *bb_head = BB_HEAD (BLOCK_FOR_INSN (insn));
do do
{ {
prev = PREV_INSN (prev); prev = PREV_INSN (prev);
@ -4249,7 +4249,7 @@ try_back_substitute_reg (rtx set, rtx insn)
/* Record all the SETs in this instruction into SETS_PTR, /* Record all the SETs in this instruction into SETS_PTR,
and return the number of recorded sets. */ and return the number of recorded sets. */
static int static int
find_sets_in_insn (rtx insn, struct set **psets) find_sets_in_insn (rtx_insn *insn, struct set **psets)
{ {
struct set *sets = *psets; struct set *sets = *psets;
int n_sets = 0; int n_sets = 0;
@ -4331,7 +4331,7 @@ find_sets_in_insn (rtx insn, struct set **psets)
see canon_reg. */ see canon_reg. */
static void static void
canonicalize_insn (rtx insn, struct set **psets, int n_sets) canonicalize_insn (rtx_insn *insn, struct set **psets, int n_sets)
{ {
struct set *sets = *psets; struct set *sets = *psets;
rtx tem; rtx tem;
@ -4487,7 +4487,7 @@ canonicalize_insn (rtx insn, struct set **psets, int n_sets)
of available values. */ of available values. */
static void static void
cse_insn (rtx insn) cse_insn (rtx_insn *insn)
{ {
rtx x = PATTERN (insn); rtx x = PATTERN (insn);
int i; int i;
@ -5481,7 +5481,7 @@ cse_insn (rtx insn)
} }
delete_insn_and_edges (insn); delete_insn_and_edges (insn);
insn = new_rtx; insn = as_a <rtx_insn *> (new_rtx);
} }
else else
INSN_CODE (insn) = -1; INSN_CODE (insn) = -1;
@ -5984,7 +5984,7 @@ invalidate_memory (void)
alias with something that is SET or CLOBBERed. */ alias with something that is SET or CLOBBERed. */
static void static void
invalidate_from_clobbers (rtx insn) invalidate_from_clobbers (rtx_insn *insn)
{ {
rtx x = PATTERN (insn); rtx x = PATTERN (insn);
@ -6026,7 +6026,7 @@ invalidate_from_clobbers (rtx insn)
alias with something that is SET or CLOBBERed. */ alias with something that is SET or CLOBBERed. */
static void static void
invalidate_from_sets_and_clobbers (rtx insn) invalidate_from_sets_and_clobbers (rtx_insn *insn)
{ {
rtx tem; rtx tem;
rtx x = PATTERN (insn); rtx x = PATTERN (insn);
@ -6154,7 +6154,7 @@ cse_process_notes_1 (rtx x, rtx object, bool *changed)
} }
/* Otherwise, canonicalize this register. */ /* Otherwise, canonicalize this register. */
return canon_reg (x, NULL_RTX); return canon_reg (x, NULL);
default: default:
break; break;
@ -6366,7 +6366,7 @@ cse_prescan_path (struct cse_basic_block_data *data)
for (path_entry = 0; path_entry < path_size; path_entry++) for (path_entry = 0; path_entry < path_size; path_entry++)
{ {
basic_block bb; basic_block bb;
rtx insn; rtx_insn *insn;
bb = data->path[path_entry].bb; bb = data->path[path_entry].bb;
@ -6405,7 +6405,7 @@ cse_extended_basic_block (struct cse_basic_block_data *ebb_data)
for (path_entry = 0; path_entry < path_size; path_entry++) for (path_entry = 0; path_entry < path_size; path_entry++)
{ {
basic_block bb; basic_block bb;
rtx insn; rtx_insn *insn;
bb = ebb_data->path[path_entry].bb; bb = ebb_data->path[path_entry].bb;
@ -6469,7 +6469,8 @@ cse_extended_basic_block (struct cse_basic_block_data *ebb_data)
Here we use fact that nothing expects CC0 to be Here we use fact that nothing expects CC0 to be
valid over an insn, which is true until the final valid over an insn, which is true until the final
pass. */ pass. */
rtx prev_insn, tem; rtx_insn *prev_insn;
rtx tem;
prev_insn = prev_nonnote_nondebug_insn (insn); prev_insn = prev_nonnote_nondebug_insn (insn);
if (prev_insn && NONJUMP_INSN_P (prev_insn) if (prev_insn && NONJUMP_INSN_P (prev_insn)
@ -6560,7 +6561,7 @@ cse_extended_basic_block (struct cse_basic_block_data *ebb_data)
Return 0 otherwise. */ Return 0 otherwise. */
static int static int
cse_main (rtx f ATTRIBUTE_UNUSED, int nregs) cse_main (rtx_insn *f ATTRIBUTE_UNUSED, int nregs)
{ {
struct cse_basic_block_data ebb_data; struct cse_basic_block_data ebb_data;
basic_block bb; basic_block bb;
@ -6657,7 +6658,7 @@ cse_main (rtx f ATTRIBUTE_UNUSED, int nregs)
static int static int
check_for_label_ref (rtx *rtl, void *data) check_for_label_ref (rtx *rtl, void *data)
{ {
rtx insn = (rtx) data; rtx_insn *insn = (rtx_insn *) data;
/* If this insn uses a LABEL_REF and there isn't a REG_LABEL_OPERAND /* If this insn uses a LABEL_REF and there isn't a REG_LABEL_OPERAND
note for it, we must rerun jump since it needs to place the note. If note for it, we must rerun jump since it needs to place the note. If
@ -6811,7 +6812,7 @@ is_dead_reg (rtx x, int *counts)
/* Return true if set is live. */ /* Return true if set is live. */
static bool static bool
set_live_p (rtx set, rtx insn ATTRIBUTE_UNUSED, /* Only used with HAVE_cc0. */ set_live_p (rtx set, rtx_insn *insn ATTRIBUTE_UNUSED, /* Only used with HAVE_cc0. */
int *counts) int *counts)
{ {
#ifdef HAVE_cc0 #ifdef HAVE_cc0
@ -6838,7 +6839,7 @@ set_live_p (rtx set, rtx insn ATTRIBUTE_UNUSED, /* Only used with HAVE_cc0. */
/* Return true if insn is live. */ /* Return true if insn is live. */
static bool static bool
insn_live_p (rtx insn, int *counts) insn_live_p (rtx_insn *insn, int *counts)
{ {
int i; int i;
if (!cfun->can_delete_dead_exceptions && !insn_nothrow_p (insn)) if (!cfun->can_delete_dead_exceptions && !insn_nothrow_p (insn))
@ -6863,7 +6864,7 @@ insn_live_p (rtx insn, int *counts)
} }
else if (DEBUG_INSN_P (insn)) else if (DEBUG_INSN_P (insn))
{ {
rtx next; rtx_insn *next;
for (next = NEXT_INSN (insn); next; next = NEXT_INSN (next)) for (next = NEXT_INSN (insn); next; next = NEXT_INSN (next))
if (NOTE_P (next)) if (NOTE_P (next))
@ -7116,7 +7117,7 @@ cse_change_cc_mode (rtx *loc, void *data)
GET_MODE (NEWREG) in INSN. */ GET_MODE (NEWREG) in INSN. */
static void static void
cse_change_cc_mode_insn (rtx insn, rtx newreg) cse_change_cc_mode_insn (rtx_insn *insn, rtx newreg)
{ {
struct change_cc_mode_args args; struct change_cc_mode_args args;
int success; int success;
@ -7143,9 +7144,9 @@ cse_change_cc_mode_insn (rtx insn, rtx newreg)
any instruction which modifies NEWREG. */ any instruction which modifies NEWREG. */
static void static void
cse_change_cc_mode_insns (rtx start, rtx end, rtx newreg) cse_change_cc_mode_insns (rtx_insn *start, rtx_insn *end, rtx newreg)
{ {
rtx insn; rtx_insn *insn;
for (insn = start; insn != end; insn = NEXT_INSN (insn)) for (insn = start; insn != end; insn = NEXT_INSN (insn))
{ {
@ -7183,9 +7184,9 @@ cse_cc_succs (basic_block bb, basic_block orig_bb, rtx cc_reg, rtx cc_src,
enum machine_mode mode; enum machine_mode mode;
unsigned int insn_count; unsigned int insn_count;
edge e; edge e;
rtx insns[2]; rtx_insn *insns[2];
enum machine_mode modes[2]; enum machine_mode modes[2];
rtx last_insns[2]; rtx_insn *last_insns[2];
unsigned int i; unsigned int i;
rtx newreg; rtx newreg;
edge_iterator ei; edge_iterator ei;
@ -7201,8 +7202,8 @@ cse_cc_succs (basic_block bb, basic_block orig_bb, rtx cc_reg, rtx cc_src,
insn_count = 0; insn_count = 0;
FOR_EACH_EDGE (e, ei, bb->succs) FOR_EACH_EDGE (e, ei, bb->succs)
{ {
rtx insn; rtx_insn *insn;
rtx end; rtx_insn *end;
if (e->flags & EDGE_COMPLEX) if (e->flags & EDGE_COMPLEX)
continue; continue;
@ -7379,10 +7380,10 @@ cse_condition_code_reg (void)
FOR_EACH_BB_FN (bb, cfun) FOR_EACH_BB_FN (bb, cfun)
{ {
rtx last_insn; rtx_insn *last_insn;
rtx cc_reg; rtx cc_reg;
rtx insn; rtx_insn *insn;
rtx cc_src_insn; rtx_insn *cc_src_insn;
rtx cc_src; rtx cc_src;
enum machine_mode mode; enum machine_mode mode;
enum machine_mode orig_mode; enum machine_mode orig_mode;
@ -7407,7 +7408,7 @@ cse_condition_code_reg (void)
else else
continue; continue;
cc_src_insn = NULL_RTX; cc_src_insn = NULL;
cc_src = NULL_RTX; cc_src = NULL_RTX;
for (insn = PREV_INSN (last_insn); for (insn = PREV_INSN (last_insn);
insn && insn != PREV_INSN (BB_HEAD (bb)); insn && insn != PREV_INSN (BB_HEAD (bb));