Commit 50f0f366 by Eric Botcazou Committed by Eric Botcazou

re PR rtl-optimization/33638 (wrong code with -O2 -fforce-addr)

	PR rtl-optimization/33638
	* dse.c (struct insn_info): Remove 'stack_read' field,
	add 'stack_pointer_based' field.
	(record_store): For a store with non-constant base, record
	whether it is stack pointer based.
	(scan_insn): For the call to a const function, remove stack
	pointer based stores from the list of local active stores.
	(scan_reads_nospill): Delete code dealing with const functions.

From-SVN: r129226
parent e494bf2c
2007-10-11 Eric Botcazou <ebotcazou@libertysurf.fr>
PR rtl-optimization/33638
* dse.c (struct insn_info): Remove 'stack_read' field,
add 'stack_pointer_based' field.
(record_store): For a store with non-constant base, record
whether it is stack pointer based.
(scan_insn): For the call to a const function, remove stack
pointer based stores from the list of local active stores.
(scan_reads_nospill): Delete code dealing with const functions.
2007-10-10 Peter Bergner <bergner@vnet.ibm.com> 2007-10-10 Peter Bergner <bergner@vnet.ibm.com>
* ra-conflict.c (partial_bitnum, max_bitnum): Change type of variables * ra-conflict.c (partial_bitnum, max_bitnum): Change type of variables
...@@ -284,12 +284,11 @@ struct insn_info ...@@ -284,12 +284,11 @@ struct insn_info
contains a wild read, the use_rec will be null. */ contains a wild read, the use_rec will be null. */
bool wild_read; bool wild_read;
/* This field is set for const function calls. Const functions /* This field is only used for the processing of const functions.
cannot read memory, but they can read the stack because that is These functions cannot read memory, but they can read the stack
where they may get their parms. So having this set is less because that is where they may get their parms. It is set to
severe than a wild read, it just means that all of the stores to true if the insn may contain a stack pointer based store. */
the stack are killed rather than all stores. */ bool stack_pointer_based;
bool stack_read;
/* This is true if any of the sets within the store contains a /* This is true if any of the sets within the store contains a
cselib base. Such stores can only be deleted by the local cselib base. Such stores can only be deleted by the local
...@@ -941,8 +940,9 @@ add_wild_read (bb_info_t bb_info) ...@@ -941,8 +940,9 @@ add_wild_read (bb_info_t bb_info)
} }
/* Return true if X is a constant or one of the registers that behaves /* Return true if X is a constant or one of the registers that behave
as a constant over the life of a function. */ as a constant over the life of a function. This is equivalent to
!rtx_varies_p for memory addresses. */
static bool static bool
const_or_frame_p (rtx x) const_or_frame_p (rtx x)
...@@ -1245,8 +1245,15 @@ record_store (rtx body, bb_info_t bb_info) ...@@ -1245,8 +1245,15 @@ record_store (rtx body, bb_info_t bb_info)
} }
else else
{ {
store_info = pool_alloc (cse_store_info_pool); rtx base_term = find_base_term (XEXP (mem, 0));
if (!base_term
|| (GET_CODE (base_term) == ADDRESS
&& GET_MODE (base_term) == Pmode
&& XEXP (base_term, 0) == stack_pointer_rtx))
insn_info->stack_pointer_based = true;
insn_info->contains_cselib_groups = true; insn_info->contains_cselib_groups = true;
store_info = pool_alloc (cse_store_info_pool);
group_id = -1; group_id = -1;
if (dump_file) if (dump_file)
...@@ -1948,9 +1955,10 @@ scan_insn (bb_info_t bb_info, rtx insn) ...@@ -1948,9 +1955,10 @@ scan_insn (bb_info_t bb_info, rtx insn)
if (CALL_P (insn)) if (CALL_P (insn))
{ {
insn_info->cannot_delete = true; insn_info->cannot_delete = true;
/* Const functions cannot do anything bad i.e. read memory, /* Const functions cannot do anything bad i.e. read memory,
however, they can read their parameters which may have been however, they can read their parameters which may have
pushed onto the stack. */ been pushed onto the stack. */
if (CONST_OR_PURE_CALL_P (insn) && !pure_call_p (insn)) if (CONST_OR_PURE_CALL_P (insn) && !pure_call_p (insn))
{ {
insn_info_t i_ptr = active_local_stores; insn_info_t i_ptr = active_local_stores;
...@@ -1961,15 +1969,8 @@ scan_insn (bb_info_t bb_info, rtx insn) ...@@ -1961,15 +1969,8 @@ scan_insn (bb_info_t bb_info, rtx insn)
while (i_ptr) while (i_ptr)
{ {
store_info_t store_info = i_ptr->store_rec; /* Remove the stack pointer based stores. */
if (i_ptr->stack_pointer_based)
/* Skip the clobbers. */
while (!store_info->is_set)
store_info = store_info->next;
/* Remove the frame related stores. */
if (store_info->group_id >= 0
&& VEC_index (group_info_t, rtx_group_vec, store_info->group_id)->frame_related)
{ {
if (dump_file) if (dump_file)
dump_insn_info ("removing from active", i_ptr); dump_insn_info ("removing from active", i_ptr);
...@@ -1983,14 +1984,12 @@ scan_insn (bb_info_t bb_info, rtx insn) ...@@ -1983,14 +1984,12 @@ scan_insn (bb_info_t bb_info, rtx insn)
last = i_ptr; last = i_ptr;
i_ptr = i_ptr->next_local_store; i_ptr = i_ptr->next_local_store;
} }
insn_info->stack_read = true;
return;
} }
/* Every other call, including pure functions may read memory. */ else
add_wild_read (bb_info); /* Every other call, including pure functions, may read memory. */
add_wild_read (bb_info);
return; return;
} }
...@@ -2492,18 +2491,6 @@ scan_reads_nospill (insn_info_t insn_info, bitmap gen, bitmap kill) ...@@ -2492,18 +2491,6 @@ scan_reads_nospill (insn_info_t insn_info, bitmap gen, bitmap kill)
int i; int i;
group_info_t group; group_info_t group;
/* For const function calls kill the stack related stores. */
if (insn_info->stack_read)
{
for (i = 0; VEC_iterate (group_info_t, rtx_group_vec, i, group); i++)
if (group->process_globally && group->frame_related)
{
if (kill)
bitmap_ior_into (kill, group->group_kill);
bitmap_and_compl_into (gen, group->group_kill);
}
}
while (read_info) while (read_info)
{ {
for (i = 0; VEC_iterate (group_info_t, rtx_group_vec, i, group); i++) for (i = 0; VEC_iterate (group_info_t, rtx_group_vec, i, group); i++)
......
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