Commit 9c4ae675 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

ia32: Generate better code for '~(1 << x)'.

'mov $~1, %r; rol x, %r' is shorter than 'mov $1, %r; shl x, %r; not %r'.
parent 438c74ad
......@@ -3,6 +3,7 @@ libFirm 1.22.1 (2016-01-07)
* Fix cmake/make build
* Support PIC with PLT for ELF (amd64)
* Add `ia32-get_ip={pop,thunk}`
* Generate 'mov $~1, %r; rol x, %r' for '~(1 << x)' (ia32)
* Bugfixes
libFirm 1.22.0 (2015-12-31)
......
......@@ -2072,6 +2072,18 @@ static ir_node *gen_Not(ir_node *node)
{
assert(get_irn_mode(node) != mode_b); /* should be lowered already */
ir_node *op = get_Not_op(node);
if (is_Shl_1(op)) {
/* ~(1 << x) -> Rol(~1, x) */
dbg_info *const dbgi = get_irn_dbg_info(node);
ir_node *const block = be_transform_nodes_block(node);
x86_imm32_t const imm = { .offset = -2 };
ir_node *const m2 = new_bd_ia32_Const(NULL, block, &imm);
ir_node *const val = get_Shl_right(op);
ir_node *const new_val = be_transform_node(val);
return new_bd_ia32_Rol(dbgi, block, m2, new_val);
}
return gen_unop(node, op, new_bd_ia32_Not, match_mode_neutral);
}
......
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