Commit 737e2130 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Refactor ia32_transform_lea_to_add_or_shl() a bit.

[r15722]
parent e0a758e4
......@@ -260,16 +260,7 @@ static void ia32_transform_lea_to_add_or_shl(ir_node *node, ia32_code_gen_t *cg)
}
#endif
op1 = base;
if(cg->isa->opt & IA32_OPT_INCDEC) {
if(is_am_one(node)) {
goto make_inc;
}
if(is_am_minus_one(node)) {
goto make_dec;
}
}
op2 = create_immediate_from_am(cg, node);
goto make_add;
goto make_add_immediate;
}
if(scale == 0 && !has_immediates) {
op1 = base;
......@@ -280,28 +271,19 @@ static void ia32_transform_lea_to_add_or_shl(ir_node *node, ia32_code_gen_t *cg)
return;
} else if(out_reg == index_reg) {
if(base == NULL) {
if(has_immediates && scale == 0) {
op1 = index;
if(cg->isa->opt & IA32_OPT_INCDEC) {
if(is_am_one(node)) {
goto make_inc;
}
if(is_am_minus_one(node)) {
goto make_dec;
}
}
op2 = create_immediate_from_am(cg, node);
goto make_add;
} else if(!has_immediates && scale > 0) {
op1 = index;
op2 = create_immediate_from_int(cg, scale);
goto make_shl;
} else if(!has_immediates) {
if(has_immediates && scale == 0) {
op1 = index;
goto make_add_immediate;
} else if(!has_immediates && scale > 0) {
op1 = index;
op2 = create_immediate_from_int(cg, scale);
goto make_shl;
} else if(!has_immediates) {
#ifdef DEBUG_libfirm
ir_fprintf(stderr, "Optimisation warning: found lea which is "
"just a copy\n");
#endif
}
}
} else if(scale == 0 && !has_immediates) {
op1 = index;
op2 = base;
......@@ -314,6 +296,25 @@ static void ia32_transform_lea_to_add_or_shl(ir_node *node, ia32_code_gen_t *cg)
return;
}
make_add_immediate:
if(cg->isa->opt & IA32_OPT_INCDEC) {
if(is_am_one(node)) {
dbgi = get_irn_dbg_info(node);
block = get_nodes_block(node);
res = new_rd_ia32_Inc(dbgi, irg, block, op1);
arch_set_irn_register(arch_env, res, out_reg);
goto exchange;
}
if(is_am_minus_one(node)) {
dbgi = get_irn_dbg_info(node);
block = get_nodes_block(node);
res = new_rd_ia32_Dec(dbgi, irg, block, op1);
arch_set_irn_register(arch_env, res, out_reg);
goto exchange;
}
}
op2 = create_immediate_from_am(cg, node);
make_add:
dbgi = get_irn_dbg_info(node);
block = get_nodes_block(node);
......@@ -324,20 +325,6 @@ make_add:
set_ia32_commutative(res);
goto exchange;
make_inc:
dbgi = get_irn_dbg_info(node);
block = get_nodes_block(node);
res = new_rd_ia32_Inc(dbgi, irg, block, op1);
arch_set_irn_register(arch_env, res, out_reg);
goto exchange;
make_dec:
dbgi = get_irn_dbg_info(node);
block = get_nodes_block(node);
res = new_rd_ia32_Dec(dbgi, irg, block, op1);
arch_set_irn_register(arch_env, res, out_reg);
goto exchange;
make_shl:
dbgi = get_irn_dbg_info(node);
block = get_nodes_block(node);
......
Supports Markdown
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