Commit 445d6c9b authored by Matthias Braun's avatar Matthias Braun
Browse files

slightly simplify lea(x>>2,x>>2,4) matcher

parent 2aba2bc9
...@@ -375,35 +375,36 @@ void x86_create_address_mode(x86_address_t *addr, ir_node *node, ...@@ -375,35 +375,36 @@ void x86_create_address_mode(x86_address_t *addr, ir_node *node,
/* (x & 0xFFFFFFFC) + (x >> 2) -> lea(x >> 2, x >> 2, 4) */ /* (x & 0xFFFFFFFC) + (x >> 2) -> lea(x >> 2, x >> 2, 4) */
if (left != NULL && right != NULL) { if (left != NULL && right != NULL) {
ir_node *and = NULL; ir_node *and;
ir_node *shr = NULL; ir_node *shr;
if (is_And(left) && (is_Shr(right) || is_Shrs(right))) { if (is_And(left) && (is_Shr(right) || is_Shrs(right))) {
and = left; and = left;
shr = right; shr = right;
} else if (is_And(right) && (is_Shr(left) || is_Shrs(left))) { goto tryit;
}
if (is_And(right) && (is_Shr(left) || is_Shrs(left))) {
and = right; and = right;
shr = left; shr = left;
} tryit:
if (get_And_left(and) == get_binop_left(shr)) {
if (and != NULL && get_And_left(and) == get_binop_left(shr)) { ir_node *and_right = get_And_right(and);
ir_node *and_right = get_And_right(and); ir_node *shr_right = get_binop_right(shr);
ir_node *shr_right = get_binop_right(shr);
if (is_Const(and_right) && is_Const(shr_right)) {
if (is_Const(and_right) && is_Const(shr_right)) { ir_tarval *and_mask = get_Const_tarval(and_right);
ir_tarval *and_mask = get_Const_tarval(and_right); ir_tarval *shift_amount = get_Const_tarval(shr_right);
ir_tarval *shift_amount = get_Const_tarval(shr_right); ir_mode *mode = get_irn_mode(and);
ir_mode *mode = get_irn_mode(and); ir_tarval *all_one = get_mode_all_one(mode);
ir_tarval *all_one = get_mode_all_one(mode); ir_tarval *shift_mask = tarval_shl(tarval_shr(all_one, shift_amount), shift_amount);
ir_tarval *shift_mask = tarval_shl(tarval_shr(all_one, shift_amount), shift_amount); assert(tarval_is_long(shift_amount));
assert(tarval_is_long(shift_amount)); long val = get_tarval_long(shift_amount);
long val = get_tarval_long(shift_amount);
if (and_mask == shift_mask && val >= 0 && val <= 3) {
if (and_mask == shift_mask && val >= 0 && val <= 3) { addr->base = shr;
addr->base = shr; addr->index = shr;
addr->index = shr; addr->scale = val;
addr->scale = val; return;
return; }
} }
} }
} }
......
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