Commit 3fc8ae70 authored by Michael Beck's avatar Michael Beck
Browse files

Add ~x + 1 = -x algebraic simplification

[r15014]
parent 05064375
......@@ -80,7 +80,8 @@ enum firmstat_optimizations_t {
FS_OPT_MUX_TO_SHR, /**< Mux(a > b, a, b) = a >> b */
FS_OPT_IDEM_UNARY, /**< Idempotent unary operation */
FS_OPT_MINUS_NOT, /**< -(~x) = x + 1 */
FS_OPT_NOT_MINUS_1, /**< ~(x-1) = -x */
FS_OPT_NOT_MINUS_1, /**< ~(x - 1) = -x */
FS_OPT_NOT_PLUS_1, /**< ~x + 1 = -x */
FS_OPT_CONST_PHI, /**< Constant evaluation on Phi */
FS_BE_IA32_LEA, /**< Lea was created */
FS_BE_IA32_LOAD_LEA, /**< Load merged with a Lea */
......
......@@ -1993,6 +1993,14 @@ static ir_node *transform_node_Add(ir_node *n) {
DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_MUL_A_X_A);
}
}
/* Here we rely on constants be on the RIGHT side */
else if (is_Not(a) && classify_Const(b) == CNST_ONE) {
/* ~x + 1 = -x */
ir_node *op = get_Not_op(a);
ir_node *blk = get_irn_n(n, -1);
n = new_rd_Minus(get_irn_dbg_info(n), current_ir_graph, blk, op, mode);
DBG_OPT_ALGSIM0(oldn, n, FS_OPT_NOT_PLUS_1);
}
}
return n;
} /* transform_node_Add */
......
......@@ -98,7 +98,8 @@ static const struct {
{ FS_OPT_MUX_TO_SHR, "algebraic simplification: Mux(a > b, a, b) = a >> b" },
{ FS_OPT_IDEM_UNARY, "algebraic simplification: Idempotent unary operation" },
{ FS_OPT_MINUS_NOT, "algebraic simplification: -(~x) = x + 1" },
{ FS_OPT_NOT_MINUS_1, "algebraic simplification: ~(x-1) = -x" },
{ FS_OPT_NOT_MINUS_1, "algebraic simplification: ~(x - 1) = -x" },
{ FS_OPT_NOT_PLUS_1, "algebraic simplification: ~x + 1 = -x" },
{ FS_OPT_CONST_PHI, "constant evaluation on Phi node" },
{ FS_BE_IA32_LEA, "ia32 Backend transformation: Lea was created" },
{ FS_BE_IA32_LOAD_LEA, "ia32 Backend transformation: Load merged with a Lea" },
......
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