New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
incorrect instcombine fold for icmp sgt #41543
Comments
assigned to @LebedevRI |
Nice! Thank you for reporting! And same for llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sle-to-icmp-sle.ll |
For reference, the commit that introduced this specific test change was: We missed a precondition. Not sure if it's worth using value tracking (isKnownNonZero) to preserve the cases that could still be reduced: https://rise4fun.com/Alive/5gkT Pre: C1 != 0 |
|
Checked other folds there, with other edge-cases (0, -1), everything else seems fine now.. |
Extended Description
The following instcombine rewrite seems incorrect (test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sgt-to-icmp-sgt.ll):
define i1 @cv0_GOOD(i8 %y) {
%0:
%x = call i8 @gen8()
%tmp0 = lshr i8 255, %y
%tmp1 = and i8 %tmp0, %x
%ret = icmp sgt i8 %x, %tmp1
ret i1 %ret
}
=>
define i1 @cv0_GOOD(i8 %y) {
%0:
%x = call i8 @gen8()
%tmp0 = lshr i8 255, %y
%1 = icmp sgt i8 %x, %tmp0
ret i1 %1
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
i8 %y = #x00 (0)
Source:
i8 %x = #x7f (127, -129)
i8 %tmp0 = #xff (255, -1)
i8 %tmp1 = #x7f (127, -129)
i1 %ret = #x0 (0)
Target:
i8 %x = #x7f (127, -129)
i8 %tmp0 = #xff (255, -1)
i1 %1 = #x1 (1)
Source value: #x0 (0)
Target value: #x1 (1)
The text was updated successfully, but these errors were encountered: