aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/simplify.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-01-06 22:43:42 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-01-26 22:49:11 +0100
commit33fda43cf26ce3e312e6cb4882821117b68056a2 (patch)
treefe46bd4a7aa2e6d42d1f920872ca6aa8e25442c7 /simplify.c
parent1cac46932aa290e4192ed178a26b0da6486d8cd3 (diff)
downloadsparse-dev-33fda43cf26ce3e312e6cb4882821117b68056a2.tar.gz
cmps: fix simplification of sext(x) + signed compare of {SMAX,SMIN}
Commit a1c1b9236d5d ("cmp: simplify sext(x) cmps {SMAX,SMIN}") had a double error (wrong size and wrong compare direction) which was hidden because of too narrow testcases. So, fix the simplification and extend the testcases. Fixes: a1c1b9236d5d4af1681a45ced26f8350bd7721c2 Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'simplify.c')
-rw-r--r--simplify.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/simplify.c b/simplify.c
index 2f6f41c2..9a24058f 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1239,13 +1239,13 @@ static int simplify_compare_constant(struct instruction *insn, long long value)
}
break;
case OP_SET_LT: case OP_SET_LE:
- if (value >= sign_bit(osize))
+ if (value < sign_bit(size))
return replace_with_value(insn, 1);
else
return replace_with_value(insn, 0);
break;
case OP_SET_GE: case OP_SET_GT:
- if (value >= sign_bit(osize))
+ if (value < sign_bit(size))
return replace_with_value(insn, 0);
else
return replace_with_value(insn, 1);