aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-01-26 00:24:13 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-01-26 22:49:11 +0100
commitd7af8d6cc223559ece17c435dcdbd04f9ef74d3d (patch)
tree4e0959b50e3e66dad9f7a25a061914759742b02a
parent33fda43cf26ce3e312e6cb4882821117b68056a2 (diff)
downloadsparse-d7af8d6cc223559ece17c435dcdbd04f9ef74d3d.tar.gz
cmpu: fix canonicalization of unsigned (x {<,>=} C) --> (x {<=,>} C-1)
In Sparse, the PSEUDO_VALUEs are required to be truncated at their effective size. For example, for a 32-bit instruction and Sparse using 64-bit integers, a pseudo of -1 must contain the value 0x00000000ffffffff, not 0xffffffffffffffff. Add the missing truncation in the canonicalization here. Fixes: c355e5ac5dce35f3d95c30cd5e2e9a5074c38437 Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--simplify.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/simplify.c b/simplify.c
index 9a24058f..a306828c 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1178,7 +1178,7 @@ static int simplify_compare_constant(struct instruction *insn, long long value)
else if (value == bits) // (x < ~0) --> (x != ~0)
return replace_binop_value(insn, OP_SET_NE, value);
else // (x < y) --> (x <= (y-1))
- changed |= replace_binop_value(insn, OP_SET_BE, value - 1);
+ changed |= replace_binop_value(insn, OP_SET_BE, (value - 1) & bits);
break;
case OP_SET_AE:
if (!value) // (x >= 0) --> 1
@@ -1188,7 +1188,7 @@ static int simplify_compare_constant(struct instruction *insn, long long value)
else if (value == bits) // (x >= ~0) --> (x == ~0)
return replace_binop_value(insn, OP_SET_EQ, value);
else // (x >= y) --> (x > (y-1)
- changed |= replace_binop_value(insn, OP_SET_A, value - 1);
+ changed |= replace_binop_value(insn, OP_SET_A, (value - 1) & bits);
break;
case OP_SET_BE:
if (!value) // (x <= 0) --> (x == 0)