re PR rtl-optimization/8967 (Making class data members `const' pessimizes code)

PR optimization/8967
	* alias.c (write_dependence_p): Modify to take an additional constp
	argument that controls whether the UNCHANGING_RTX_P flags are used.
	(anti_dependence, output_dependence): Adjust write_dependence_p
	callers to pass this additional argument, to return the same result.
	(unchanging_anti_dependence): New variant of anti_dependence that
	ignores the UNCHANGING_RTX_P property on memory references.
	* rtl.h (unchaning_anti_dependence): Prototype here.
	* flow.c (init_propagate_block): Place fake constant mem writes on
	the mem_set_list so that dead writes to const variables are deleted.
	(insn_dead_p): Change anti_dependence to unchanging_anti_dependence.
	(mark_used_regs): Likewise.

From-SVN: r71332
This commit is contained in:
Roger Sayle 2003-09-12 15:07:50 +00:00 committed by Roger Sayle
parent f0f4da3220
commit d2399d7515
4 changed files with 44 additions and 22 deletions

View File

@ -1,3 +1,18 @@
2003-09-12 Roger Sayle <roger@eyesopen.com>
PR optimization/8967
* alias.c (write_dependence_p): Modify to take an additional constp
argument that controls whether the UNCHANGING_RTX_P flags are used.
(anti_dependence, output_dependence): Adjust write_dependence_p
callers to pass this additional argument, to return the same result.
(unchanging_anti_dependence): New variant of anti_dependence that
ignores the UNCHANGING_RTX_P property on memory references.
* rtl.h (unchaning_anti_dependence): Prototype here.
* flow.c (init_propagate_block): Place fake constant mem writes on
the mem_set_list so that dead writes to const variables are deleted.
(insn_dead_p): Change anti_dependence to unchanging_anti_dependence.
(mark_used_regs): Likewise.
2003-09-12 Richard Sandiford <rsandifo@redhat.com>
* config/mcore/mcore-protos.h (mcore_r15_operand_p): Declare.

View File

@ -110,7 +110,7 @@ static bool nonoverlapping_component_refs_p (tree, tree);
static tree decl_for_component_ref (tree);
static rtx adjust_offset_for_component_ref (tree, rtx);
static int nonoverlapping_memrefs_p (rtx, rtx);
static int write_dependence_p (rtx, rtx, int);
static int write_dependence_p (rtx, rtx, int, int);
static int nonlocal_mentioned_p_1 (rtx *, void *);
static int nonlocal_mentioned_p (rtx);
@ -2202,10 +2202,11 @@ canon_true_dependence (rtx mem, enum machine_mode mem_mode, rtx mem_addr,
}
/* Returns nonzero if a write to X might alias a previous read from
(or, if WRITEP is nonzero, a write to) MEM. */
(or, if WRITEP is nonzero, a write to) MEM. If CONSTP is non-zero,
honor the RTX_UNCHANGING_P flags on X and MEM. */
static int
write_dependence_p (rtx mem, rtx x, int writep)
write_dependence_p (rtx mem, rtx x, int writep, int constp)
{
rtx x_addr, mem_addr;
rtx fixed_scalar;
@ -2224,15 +2225,18 @@ write_dependence_p (rtx mem, rtx x, int writep)
if (DIFFERENT_ALIAS_SETS_P (x, mem))
return 0;
/* Unchanging memory can't conflict with non-unchanging memory. */
if (RTX_UNCHANGING_P (x) != RTX_UNCHANGING_P (mem))
return 0;
if (constp)
{
/* Unchanging memory can't conflict with non-unchanging memory. */
if (RTX_UNCHANGING_P (x) != RTX_UNCHANGING_P (mem))
return 0;
/* If MEM is an unchanging read, then it can't possibly conflict with
the store to X, because there is at most one store to MEM, and it must
have occurred somewhere before MEM. */
if (! writep && RTX_UNCHANGING_P (mem))
return 0;
/* If MEM is an unchanging read, then it can't possibly conflict with
the store to X, because there is at most one store to MEM, and it
must have occurred somewhere before MEM. */
if (! writep && RTX_UNCHANGING_P (mem))
return 0;
}
if (nonoverlapping_memrefs_p (x, mem))
return 0;
@ -2273,7 +2277,7 @@ write_dependence_p (rtx mem, rtx x, int writep)
int
anti_dependence (rtx mem, rtx x)
{
return write_dependence_p (mem, x, /*writep=*/0);
return write_dependence_p (mem, x, /*writep=*/0, /*constp*/1);
}
/* Output dependence: X is written after store in MEM takes place. */
@ -2281,7 +2285,16 @@ anti_dependence (rtx mem, rtx x)
int
output_dependence (rtx mem, rtx x)
{
return write_dependence_p (mem, x, /*writep=*/1);
return write_dependence_p (mem, x, /*writep=*/1, /*constp*/1);
}
/* Unchanging anti dependence: Like anti_dependence but ignores
the UNCHANGING_RTX_P property on const variable references. */
int
unchanging_anti_dependence (rtx mem, rtx x)
{
return write_dependence_p (mem, x, /*writep=*/0, /*constp*/0);
}
/* A subroutine of nonlocal_mentioned_p, returns 1 if *LOC mentions

View File

@ -1974,13 +1974,6 @@ init_propagate_block_info (basic_block bb, regset live, regset local_set,
rtx mem = SET_DEST (set);
rtx canon_mem = canon_rtx (mem);
/* This optimization is performed by faking a store to the
memory at the end of the block. This doesn't work for
unchanging memories because multiple stores to unchanging
memory is illegal and alias analysis doesn't consider it. */
if (RTX_UNCHANGING_P (canon_mem))
continue;
if (XEXP (canon_mem, 0) == frame_pointer_rtx
|| (GET_CODE (XEXP (canon_mem, 0)) == PLUS
&& XEXP (XEXP (canon_mem, 0), 0) == frame_pointer_rtx
@ -2152,7 +2145,7 @@ insn_dead_p (struct propagate_block_info *pbi, rtx x, int call_ok,
rtx_equal_p does not check the alias set or flags, we also
must have the potential for them to conflict (anti_dependence). */
for (temp = pbi->mem_set_list; temp != 0; temp = XEXP (temp, 1))
if (anti_dependence (r, XEXP (temp, 0)))
if (unchanging_anti_dependence (r, XEXP (temp, 0)))
{
rtx mem = XEXP (temp, 0);
@ -3730,7 +3723,7 @@ mark_used_regs (struct propagate_block_info *pbi, rtx x, rtx cond, rtx insn)
while (temp)
{
next = XEXP (temp, 1);
if (anti_dependence (XEXP (temp, 0), x))
if (unchanging_anti_dependence (XEXP (temp, 0), x))
{
/* Splice temp out of the list. */
if (prev)

View File

@ -2253,6 +2253,7 @@ extern int canon_true_dependence (rtx, enum machine_mode, rtx, rtx,
extern int read_dependence (rtx, rtx);
extern int anti_dependence (rtx, rtx);
extern int output_dependence (rtx, rtx);
extern int unchanging_anti_dependence (rtx, rtx);
extern void mark_constant_function (void);
extern void init_alias_once (void);
extern void init_alias_analysis (void);