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@xxxxxxxxx> --- simplify.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simplify.c b/simplify.c index 9a24058f6e55..a306828c1c4b 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) -- 2.30.0