Commit 89688f61 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

arm, be, ia32, sparc: Do not go on with peephole optimization of IncSP, when...

arm, be, ia32, sparc: Do not go on with peephole optimization of IncSP, when be_peephole_IncSP_IncSP() succeeded.

The current IncSP was removed in this case and we now would operate on its predecessor IncSP.
This is wrong, e.g. when asking for currently free registers.
This corrects backend/incsp_pop.c, which was broken on ia32.
It was wrongly assumed that a certain register was free and could be used to turn an IncSP into a Pop.
parent f617d134
......@@ -44,7 +44,8 @@ static bool allowed_arm_immediate(int offset, arm_vals *result)
static void peephole_be_IncSP(ir_node *node)
{
/* first optimize incsp->incsp combinations */
node = be_peephole_IncSP_IncSP(node);
if (be_peephole_IncSP_IncSP(node))
return;
int offset = be_get_IncSP_offset(node);
/* can be transformed into Add OR Sub */
......
......@@ -374,18 +374,14 @@ bool be_can_move_up(ir_heights_t *heights, const ir_node *node,
return true;
}
/*
* Tries to optimize a beIncSP node with its previous IncSP node.
* Must be run from a be_peephole_opt() context.
*/
ir_node *be_peephole_IncSP_IncSP(ir_node *node)
bool be_peephole_IncSP_IncSP(ir_node *node)
{
ir_node *pred = be_get_IncSP_pred(node);
if (!be_is_IncSP(pred))
return node;
return false;
if (!be_has_only_one_user(pred))
return node;
return false;
/* add node offset to pred and remove our IncSP */
int curr_offs = be_get_IncSP_offset(node);
......@@ -394,7 +390,7 @@ ir_node *be_peephole_IncSP_IncSP(ir_node *node)
be_set_IncSP_offset(pred, offs);
be_peephole_exchange(node, pred);
return pred;
return true;
}
void be_peephole_opt(ir_graph *irg)
......
......@@ -46,9 +46,9 @@ ir_node *be_peephole_to_tuple(ir_node *node);
*
* @param node a be_IncSP node
*
* @return the new IncSP node or node itself
* @return whether @p node was removed
*/
ir_node *be_peephole_IncSP_IncSP(ir_node *node);
bool be_peephole_IncSP_IncSP(ir_node *node);
bool be_has_only_one_user(ir_node *node);
......
......@@ -647,7 +647,8 @@ static void peephole_be_IncSP(ir_node *node)
const arch_register_t *esp = &ia32_registers[REG_ESP];
/* first optimize incsp->incsp combinations */
node = be_peephole_IncSP_IncSP(node);
if (be_peephole_IncSP_IncSP(node))
return;
/* transform IncSP->Store combinations to Push where possible */
peephole_IncSP_Store_to_push(node);
......
......@@ -454,8 +454,7 @@ static void finish_sparc_Stf(ir_node *node)
static void peephole_be_IncSP(ir_node *node)
{
node = be_peephole_IncSP_IncSP(node);
if (!be_is_IncSP(node))
if (be_peephole_IncSP_IncSP(node))
return;
ir_node *pred = be_get_IncSP_pred(node);
......
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