This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
gcse cleanup
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>, gcc-patches at gcc dot gnu dot org, patches at x86-64 dot org, rth at cygnus dot com
- Subject: gcse cleanup
- From: Jan Hubicka <jh at suse dot cz>
- Date: Fri, 18 May 2001 11:09:35 +0200
Hi,
this patch simplifies cprop somewhat by using note_uses infrastructure bit.
Honza
Fri May 18 11:07:58 CEST 2001 Jan Hubicka <jh@suse.cz>
* 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.
Index: gcse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/gcse.c,v
retrieving revision 1.130
diff -c -3 -p -r1.130 gcse.c
*** gcse.c 2001/05/11 22:07:58 1.130
--- gcse.c 2001/05/18 09:04:09
*************** static void compute_transpout PARAMS ((v
*** 616,622 ****
static void compute_local_properties PARAMS ((sbitmap *, sbitmap *, sbitmap *,
int));
static void compute_cprop_data PARAMS ((void));
! static void find_used_regs PARAMS ((rtx));
static int try_replace_reg PARAMS ((rtx, rtx, rtx));
static struct expr *find_avail_set PARAMS ((int, rtx));
static int cprop_jump PARAMS ((rtx, rtx, rtx));
--- 616,622 ----
static void compute_local_properties PARAMS ((sbitmap *, sbitmap *, sbitmap *,
int));
static void compute_cprop_data PARAMS ((void));
! static void find_used_regs PARAMS ((rtx *, void *));
static int try_replace_reg PARAMS ((rtx, rtx, rtx));
static struct expr *find_avail_set PARAMS ((int, rtx));
static int cprop_jump PARAMS ((rtx, rtx, rtx));
*************** static int reg_use_count;
*** 3937,3992 ****
This doesn't hurt anything but it will slow things down. */
static void
! find_used_regs (x)
! rtx x;
{
int i, j;
enum rtx_code code;
const char *fmt;
/* repeat is used to turn tail-recursion into iteration since GCC
can't do it when there's no return value. */
repeat:
-
if (x == 0)
return;
code = GET_CODE (x);
! switch (code)
{
- case REG:
if (reg_use_count == MAX_USES)
return;
reg_use_table[reg_use_count].reg_rtx = x;
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. */
--- 3937,3965 ----
This doesn't hurt anything but it will slow things down. */
static void
! find_used_regs (xptr, data)
! rtx *xptr;
! void *data ATTRIBUTE_UNUSED;
{
int i, j;
enum rtx_code code;
const char *fmt;
+ rtx x = *xptr;
/* repeat is used to turn tail-recursion into iteration since GCC
can't do it when there's no return value. */
repeat:
if (x == 0)
return;
code = GET_CODE (x);
! if (REG_P (x))
{
if (reg_use_count == MAX_USES)
return;
reg_use_table[reg_use_count].reg_rtx = x;
reg_use_count++;
}
/* Recursively scan the operands of this expression. */
*************** find_used_regs (x)
*** 4004,4014 ****
goto repeat;
}
! find_used_regs (XEXP (x, i));
}
else if (fmt[i] == 'E')
for (j = 0; j < XVECLEN (x, i); j++)
! find_used_regs (XVECEXP (x, i, j));
}
}
--- 3977,3987 ----
goto repeat;
}
! find_used_regs (&XEXP (x, i), data);
}
else if (fmt[i] == 'E')
for (j = 0; j < XVECLEN (x, i); j++)
! find_used_regs (&XVECEXP (x, i, j), data);
}
}
*************** cprop_insn (insn, alter_jumps)
*** 4237,4255 ****
int changed = 0;
rtx note;
! /* Only propagate into SETs. Note that a conditional jump is a
! SET with pc_rtx as the destination. */
! if (GET_CODE (insn) != INSN && GET_CODE (insn) != JUMP_INSN)
return 0;
reg_use_count = 0;
! find_used_regs (PATTERN (insn));
note = find_reg_equal_equiv_note (insn);
/* We may win even when propagating constants into notes. */
if (note)
! find_used_regs (XEXP (note, 0));
for (reg_used = ®_use_table[0]; reg_use_count > 0;
reg_used++, reg_use_count--)
--- 4200,4216 ----
int changed = 0;
rtx note;
! if (!INSN_P (insn))
return 0;
reg_use_count = 0;
! note_uses (&PATTERN (insn), find_used_regs, NULL);
note = find_reg_equal_equiv_note (insn);
/* We may win even when propagating constants into notes. */
if (note)
! find_used_regs (&XEXP (note, 0), NULL);
for (reg_used = ®_use_table[0]; reg_use_count > 0;
reg_used++, reg_use_count--)