Commit bf6d9fd7 by John Wehle Committed by John Wehle

alias.c: (mark_constant_function): Don't check pure functions.

	* alias.c: (mark_constant_function): Don't check pure functions.
	Initialize and end alias analysis.
	(nonlocal_mentioned_p): Rename from nonlocal_reference_p.
	Don't make a special exception for recursion.  Handle
	UNSPEC_VOLATILE.  Don't assume ASM_OPERANDS is non-local
	unless it's volatile.

	* local-alloc.c (equivalence): New structure.
	(reg_equiv): Define.
	(contains_replace_regs): Remove array and use
	field in reg_equiv.
	(memref_referenced_p): Likewise.
	(no_equiv): Likewise.
	(update_equiv_regs): Likewise.

	(equiv_init_varies_p,
	equiv_init_movable_p): New functions.
	(update_equiv_regs): Use them.  Use rtx_varies_p
	instead of function_invariant_p.  Process insns
	from end to beginning.  Allow a REG_EQUIV insn
	within the same loop as a use to be moved, also
	allow it to be moved out of a loop.  Update
	REG_DEAD notes when substituting into an insn.

From-SVN: r36957
parent cab8e2bd
Fri Oct 20 00:57:00 EDT 2000 John Wehle (john@feith.com)
* alias.c: (mark_constant_function): Don't check pure functions.
Initialize and end alias analysis.
(nonlocal_mentioned_p): Rename from nonlocal_reference_p.
Don't make a special exception for recursion. Handle
UNSPEC_VOLATILE. Don't assume ASM_OPERANDS is non-local
unless it's volatile.
* local-alloc.c (equivalence): New structure.
(reg_equiv): Define.
(contains_replace_regs): Remove array and use
field in reg_equiv.
(memref_referenced_p): Likewise.
(no_equiv): Likewise.
(update_equiv_regs): Likewise.
(equiv_init_varies_p,
equiv_init_movable_p): New functions.
(update_equiv_regs): Use them. Use rtx_varies_p
instead of function_invariant_p. Process insns
from end to beginning. Allow a REG_EQUIV insn
within the same loop as a use to be moved, also
allow it to be moved out of a loop. Update
REG_DEAD notes when substituting into an insn.
2000-10-19 Jim Wilson <wilson@cygnus.com> 2000-10-19 Jim Wilson <wilson@cygnus.com>
* c-decl.c (start_decl): Check for error_mark_node type before using * c-decl.c (start_decl): Check for error_mark_node type before using
......
...@@ -103,7 +103,7 @@ static rtx fixed_scalar_and_varying_struct_p PARAMS ((rtx, rtx, rtx, rtx, ...@@ -103,7 +103,7 @@ static rtx fixed_scalar_and_varying_struct_p PARAMS ((rtx, rtx, rtx, rtx,
int (*) (rtx))); int (*) (rtx)));
static int aliases_everything_p PARAMS ((rtx)); static int aliases_everything_p PARAMS ((rtx));
static int write_dependence_p PARAMS ((rtx, rtx, int)); static int write_dependence_p PARAMS ((rtx, rtx, int));
static int nonlocal_reference_p PARAMS ((rtx)); static int nonlocal_mentioned_p PARAMS ((rtx));
/* Set up all info needed to perform alias analysis on memory references. */ /* Set up all info needed to perform alias analysis on memory references. */
...@@ -1728,11 +1728,11 @@ output_dependence (mem, x) ...@@ -1728,11 +1728,11 @@ output_dependence (mem, x)
return write_dependence_p (mem, x, /*writep=*/1); return write_dependence_p (mem, x, /*writep=*/1);
} }
/* Returns non-zero if X might refer to something which is not /* Returns non-zero if X mentions something which is not
local to the function and is not constant. */ local to the function and is not constant. */
static int static int
nonlocal_reference_p (x) nonlocal_mentioned_p (x)
rtx x; rtx x;
{ {
rtx base; rtx base;
...@@ -1792,13 +1792,7 @@ nonlocal_reference_p (x) ...@@ -1792,13 +1792,7 @@ nonlocal_reference_p (x)
return 1; return 1;
case CALL: case CALL:
/* Recursion introduces no additional considerations. */ /* Non-constant calls and recursion are not local. */
if (GET_CODE (XEXP (x, 0)) == MEM
&& GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF
&& strcmp(XSTR (XEXP (XEXP (x, 0), 0), 0),
IDENTIFIER_POINTER (
DECL_ASSEMBLER_NAME (current_function_decl))) == 0)
return 0;
return 1; return 1;
case MEM: case MEM:
...@@ -1829,10 +1823,16 @@ nonlocal_reference_p (x) ...@@ -1829,10 +1823,16 @@ nonlocal_reference_p (x)
} }
return 1; return 1;
case UNSPEC_VOLATILE:
case ASM_INPUT: case ASM_INPUT:
case ASM_OPERANDS:
return 1; return 1;
case ASM_OPERANDS:
if (MEM_VOLATILE_P (x))
return 1;
/* FALLTHROUGH */
default: default:
break; break;
} }
...@@ -1847,14 +1847,14 @@ nonlocal_reference_p (x) ...@@ -1847,14 +1847,14 @@ nonlocal_reference_p (x)
{ {
if (fmt[i] == 'e' && XEXP (x, i)) if (fmt[i] == 'e' && XEXP (x, i))
{ {
if (nonlocal_reference_p (XEXP (x, i))) if (nonlocal_mentioned_p (XEXP (x, i)))
return 1; return 1;
} }
else if (fmt[i] == 'E') else if (fmt[i] == 'E')
{ {
register int j; register int j;
for (j = 0; j < XVECLEN (x, i); j++) for (j = 0; j < XVECLEN (x, i); j++)
if (nonlocal_reference_p (XVECEXP (x, i, j))) if (nonlocal_mentioned_p (XVECEXP (x, i, j)))
return 1; return 1;
} }
} }
...@@ -1869,22 +1869,34 @@ void ...@@ -1869,22 +1869,34 @@ void
mark_constant_function () mark_constant_function ()
{ {
rtx insn; rtx insn;
int nonlocal_mentioned;
if (TREE_PUBLIC (current_function_decl) if (TREE_PUBLIC (current_function_decl)
|| TREE_READONLY (current_function_decl) || TREE_READONLY (current_function_decl)
|| DECL_IS_PURE (current_function_decl)
|| TREE_THIS_VOLATILE (current_function_decl) || TREE_THIS_VOLATILE (current_function_decl)
|| TYPE_MODE (TREE_TYPE (current_function_decl)) == VOIDmode) || TYPE_MODE (TREE_TYPE (current_function_decl)) == VOIDmode)
return; return;
nonlocal_mentioned = 0;
init_alias_analysis ();
/* Determine if this is a constant function. */ /* Determine if this is a constant function. */
for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
if (INSN_P (insn) && nonlocal_reference_p (insn)) if (INSN_P (insn) && nonlocal_mentioned_p (insn))
return; {
nonlocal_mentioned = 1;
break;
}
end_alias_analysis ();
/* Mark the function. */ /* Mark the function. */
TREE_READONLY (current_function_decl) = 1; if (! nonlocal_mentioned)
TREE_READONLY (current_function_decl) = 1;
} }
......
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