Commit fa7eb6ee authored by yb9976's avatar yb9976
Browse files

Check for equal modes before subtracting them.

This fixes opt/boolopt4.c.
parent fe67e457
......@@ -178,7 +178,7 @@ static ir_node *bool_and(cond_pair* const cpair, ir_node *dst_block)
(rel_hi == ir_relation_equal || rel_hi == ir_relation_greater_equal || rel_hi == ir_relation_greater)) {
/* x >=|>|!= lo && x ==|>=|> hi ==> x ==|>=|> hi */
return cmp_hi;
} else if (tarval_is_one(tarval_sub(tv_hi, tv_lo))) { /* lo + 1 == hi */
} else if (get_tarval_mode(tv_hi) == get_tarval_mode(tv_lo) && tarval_is_one(tarval_sub(tv_hi, tv_lo))) { /* lo + 1 == hi */
if (rel_lo == ir_relation_greater_equal && rel_hi == ir_relation_less) {
/* x >= c && x < c + 1 ==> x == c */
return make_Cmp(dst_block, cmp_lo, ir_relation_equal);
......@@ -309,7 +309,7 @@ static ir_node *bool_or(cond_pair *const cpair, ir_node *dst_block)
(rel_hi == ir_relation_equal || rel_hi == ir_relation_greater_equal || rel_hi == ir_relation_greater)) {
/* x >=|>|!= lo || x ==|>=|> hi ==> x >=|>|!= lo */
return cmp_lo;
} else if (tarval_is_one(tarval_sub(tv_hi, tv_lo))) { /* lo + 1 == hi */
} else if (get_tarval_mode(tv_hi) == get_tarval_mode(tv_lo) && tarval_is_one(tarval_sub(tv_hi, tv_lo))) { /* lo + 1 == hi */
if (rel_lo == ir_relation_less && rel_hi == ir_relation_greater_equal) {
/* x < c || x >= c + 1 ==> x != c */
return make_Cmp(dst_block, cmp_lo, ir_relation_less_greater);
......
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