llvm-project
llvm-project copied to clipboard
[ConstraintEliminationPass] miscompile - Value mismatch on alive2
Reproduction
declare void @llvm.assume(i1 noundef)
define i1 @test(i64 %x) {
entry:
%x.nonneg = icmp sge i64 %x, 0
call void @llvm.assume(i1 %x.nonneg)
%a0 = add nsw i64 %x, -9223372036854775807
%a = add nsw i64 %a0, -1
%a.nonpos = icmp sle i64 %a, 0
call void @llvm.assume(i1 %a.nonpos)
%r = icmp slt i64 %x, 0
ret i1 %r
}
$ alive-tv --disable-undef-input --disable-poison-input evidence/repro.ll --passes=constraint-elimination
...
Transformation doesn't verify!
ERROR: Value mismatch
Example:
i64 %x = #x0000000000000000 (0)
...
alive godbot link: https://alive2.llvm.org/ce/z/bN7AYq
Reproduced on e3bde09850d7be0bfdbd9051f09b887b1d607f38.
Hello, I'm working on this issue. The bug appears to be caused by ConstraintElimination negating an INT64_MIN offset without checking for overflow in ConstraintInfo::getConstraint, which produces an invalid constraint and incorrectly folds %x < 0 to true. I plan to add checked negation and a regression test.