Commit feae70ad authored by yb9976's avatar yb9976
Browse files

Use bit information to improve Cmp optimization.

parent 33c65969
...@@ -4896,13 +4896,19 @@ is_bittest: { ...@@ -4896,13 +4896,19 @@ is_bittest: {
* be optimized, see this: * be optimized, see this:
* -MININT < 0 =/=> MININT > 0 !!! * -MININT < 0 =/=> MININT > 0 !!!
*/ */
if (is_Minus(left) && if (is_Minus(left)) {
(!mode_overflow_on_unary_Minus(mode) || ir_node *op = get_Minus_op(left);
(mode_is_int(mode) && (is_relation_equal || is_relation_less_greater)))) { bitinfo *b = get_bitinfo(op);
ir_tarval *max = get_mode_max(mode);
if (!mode_overflow_on_unary_Minus(mode) ||
(mode_is_int(mode) && (is_relation_equal || is_relation_less_greater)) ||
(get_mode_arithmetic(mode) == irma_twos_complement && b != NULL &&
(!tarval_is_all_one(tarval_or(max, b->z)) ||
!tarval_is_null(tarval_and(b->o, max))))) {
tv = tarval_neg(tv); tv = tarval_neg(tv);
if (tarval_is_constant(tv)) { if (tarval_is_constant(tv)) {
left = get_Minus_op(left); left = op;
if (mode_is_int(mode) && (is_relation_equal || is_relation_less_greater)) { if (mode_is_int(mode) && (is_relation_equal || is_relation_less_greater)) {
relation = is_relation_equal ? ir_relation_equal relation = is_relation_equal ? ir_relation_equal
: ir_relation_less_greater; : ir_relation_less_greater;
...@@ -4912,6 +4918,7 @@ is_bittest: { ...@@ -4912,6 +4918,7 @@ is_bittest: {
changedc = true; changedc = true;
DBG_OPT_ALGSIM0(n, n, FS_OPT_CMP_OP_C); DBG_OPT_ALGSIM0(n, n, FS_OPT_CMP_OP_C);
} }
}
} else if (is_Not(left) && (is_relation_equal || is_relation_less_greater)) { } else if (is_Not(left) && (is_relation_equal || is_relation_less_greater)) {
/* Not(a) ==/!= c ==> a ==/!= Not(c) */ /* Not(a) ==/!= c ==> a ==/!= Not(c) */
tv = tarval_not(tv); tv = tarval_not(tv);
......
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