Commit 9e71c818 by Jan Hubicka Committed by Jan Hubicka

gcse.c (try_replace_reg): First try global replace, later try to simplify the expression.

	* gcse.c (try_replace_reg): First try global replace, later try to
	simplify the expression.

	* gcse.c (find_used_regs): Change calling convention; work via
	note_uses.
	(cprop_insn): Update call of find_used_regs; work for CALL_INSNs too.

From-SVN: r42264
parent 24cdff34
Fri May 18 15:39:16 CEST 2001 Jan Hubicka <jh@suse.cz>
* gcse.c (try_replace_reg): First try global replace, later try to
simplify the expression.
* gcse.c (find_used_regs): Change calling convention; work via
note_uses.
(cprop_insn): Update call of find_used_regs; work for CALL_INSNs too.
2001-05-18 Bernd Schmidt <bernds@redhat.com> 2001-05-18 Bernd Schmidt <bernds@redhat.com>
Revert Revert
......
...@@ -616,7 +616,7 @@ static void compute_transpout PARAMS ((void)); ...@@ -616,7 +616,7 @@ static void compute_transpout PARAMS ((void));
static void compute_local_properties PARAMS ((sbitmap *, sbitmap *, sbitmap *, static void compute_local_properties PARAMS ((sbitmap *, sbitmap *, sbitmap *,
int)); int));
static void compute_cprop_data PARAMS ((void)); static void compute_cprop_data PARAMS ((void));
static void find_used_regs PARAMS ((rtx)); static void find_used_regs PARAMS ((rtx *, void *));
static int try_replace_reg PARAMS ((rtx, rtx, rtx)); static int try_replace_reg PARAMS ((rtx, rtx, rtx));
static struct expr *find_avail_set PARAMS ((int, rtx)); static struct expr *find_avail_set PARAMS ((int, rtx));
static int cprop_jump PARAMS ((rtx, rtx, rtx)); static int cprop_jump PARAMS ((rtx, rtx, rtx));
...@@ -3937,56 +3937,29 @@ static int reg_use_count; ...@@ -3937,56 +3937,29 @@ static int reg_use_count;
This doesn't hurt anything but it will slow things down. */ This doesn't hurt anything but it will slow things down. */
static void static void
find_used_regs (x) find_used_regs (xptr, data)
rtx x; rtx *xptr;
void *data ATTRIBUTE_UNUSED;
{ {
int i, j; int i, j;
enum rtx_code code; enum rtx_code code;
const char *fmt; const char *fmt;
rtx x = *xptr;
/* repeat is used to turn tail-recursion into iteration since GCC /* repeat is used to turn tail-recursion into iteration since GCC
can't do it when there's no return value. */ can't do it when there's no return value. */
repeat: repeat:
if (x == 0) if (x == 0)
return; return;
code = GET_CODE (x); code = GET_CODE (x);
switch (code) if (REG_P (x))
{ {
case REG:
if (reg_use_count == MAX_USES) if (reg_use_count == MAX_USES)
return; return;
reg_use_table[reg_use_count].reg_rtx = x; reg_use_table[reg_use_count].reg_rtx = x;
reg_use_count++; reg_use_count++;
return;
case MEM:
x = XEXP (x, 0);
goto repeat;
case PC:
case CC0:
case CONST:
case CONST_INT:
case CONST_DOUBLE:
case SYMBOL_REF:
case LABEL_REF:
case CLOBBER:
case ADDR_VEC:
case ADDR_DIFF_VEC:
case ASM_INPUT: /*FIXME*/
return;
case SET:
if (GET_CODE (SET_DEST (x)) == MEM)
find_used_regs (SET_DEST (x));
x = SET_SRC (x);
goto repeat;
default:
break;
} }
/* Recursively scan the operands of this expression. */ /* Recursively scan the operands of this expression. */
...@@ -4004,11 +3977,11 @@ find_used_regs (x) ...@@ -4004,11 +3977,11 @@ find_used_regs (x)
goto repeat; goto repeat;
} }
find_used_regs (XEXP (x, i)); find_used_regs (&XEXP (x, i), data);
} }
else if (fmt[i] == 'E') else if (fmt[i] == 'E')
for (j = 0; j < XVECLEN (x, i); j++) for (j = 0; j < XVECLEN (x, i); j++)
find_used_regs (XVECEXP (x, i, j)); find_used_regs (&XVECEXP (x, i, j), data);
} }
} }
...@@ -4024,30 +3997,20 @@ try_replace_reg (from, to, insn) ...@@ -4024,30 +3997,20 @@ try_replace_reg (from, to, insn)
int success = 0; int success = 0;
rtx set = single_set (insn); rtx set = single_set (insn);
/* If this is a single set, try to simplify the source of the set given success = validate_replace_src (from, to, insn);
our substitution. We could perhaps try this for multiple SETs, but
it probably won't buy us anything. */ /* If above failed and this is a single set, try to simplify the source of
if (set != 0) the set given our substitution. We could perhaps try this for multiple
SETs, but it probably won't buy us anything. */
if (!success && set != 0)
{ {
src = simplify_replace_rtx (SET_SRC (set), from, to); src = simplify_replace_rtx (SET_SRC (set), from, to);
/* Try this two ways: first just replace SET_SRC. If that doesn't if (!rtx_equal_p (src, SET_SRC (set))
work and this is a PARALLEL, try to replace the whole pattern && validate_change (insn, &SET_SRC (set), src, 0))
with a new SET. */
if (validate_change (insn, &SET_SRC (set), src, 0))
success = 1;
else if (GET_CODE (PATTERN (insn)) == PARALLEL
&& validate_change (insn, &PATTERN (insn),
gen_rtx_SET (VOIDmode, SET_DEST (set),
src),
0))
success = 1; success = 1;
} }
/* Otherwise, try to do a global replacement within the insn. */
if (!success)
success = validate_replace_src (from, to, insn);
/* If we've failed to do replacement, have a single SET, and don't already /* If we've failed to do replacement, have a single SET, and don't already
have a note, add a REG_EQUAL note to not lose information. */ have a note, add a REG_EQUAL note to not lose information. */
if (!success && note == 0 && set != 0) if (!success && note == 0 && set != 0)
...@@ -4237,19 +4200,17 @@ cprop_insn (insn, alter_jumps) ...@@ -4237,19 +4200,17 @@ cprop_insn (insn, alter_jumps)
int changed = 0; int changed = 0;
rtx note; rtx note;
/* Only propagate into SETs. Note that a conditional jump is a if (!INSN_P (insn))
SET with pc_rtx as the destination. */
if (GET_CODE (insn) != INSN && GET_CODE (insn) != JUMP_INSN)
return 0; return 0;
reg_use_count = 0; reg_use_count = 0;
find_used_regs (PATTERN (insn)); note_uses (&PATTERN (insn), find_used_regs, NULL);
note = find_reg_equal_equiv_note (insn); note = find_reg_equal_equiv_note (insn);
/* We may win even when propagating constants into notes. */ /* We may win even when propagating constants into notes. */
if (note) if (note)
find_used_regs (XEXP (note, 0)); find_used_regs (&XEXP (note, 0), NULL);
for (reg_used = &reg_use_table[0]; reg_use_count > 0; for (reg_used = &reg_use_table[0]; reg_use_count > 0;
reg_used++, reg_use_count--) reg_used++, reg_use_count--)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment