+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.
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);
}
/* 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;
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;
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. */
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);
}
\f
/* A subroutine of nonlocal_mentioned_p, returns 1 if *LOC mentions
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
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);
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)