-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Miscompile of 1 << ZEXT(CTTZ(X)) #94824
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
Labels
Comments
@llvm/issue-subscribers-backend-x86 Author: None (meheff)
The IR below miscompiles on x86 (at least). I believe the root cause is https://github.com//pull/85066 which performs the following optimization:
I think the ZEXT confuses things such that the value X=0 is incorrectly computed. IR:
Good llc built at 765206e
Bad llc built at 6f2c610 This produces 0 for input 0, result should be 0x100.
|
CC @dtcxzyw |
The patch description for a previous bug fix says
But the code seems to check that VT is larger than ShiftVT.
|
dtcxzyw
added a commit
that referenced
this issue
Jun 8, 2024
The pr description in #94008 mismatches with the code. > + When VT is smaller than ShiftVT, it is safe to use trunc. > + When VT is larger than ShiftVT, it is safe to use zext iff `is_zero_poison` is true (i.e., `opcode == ISD::CTTZ_ZERO_UNDEF`). See also the counterexample `src_shl_cttz2 -> tgt_shl_cttz2` in the alive2 proofs. Closes #94824.
nekoshirro
pushed a commit
to nekoshirro/Alchemist-LLVM
that referenced
this issue
Jun 9, 2024
The pr description in llvm#94008 mismatches with the code. > + When VT is smaller than ShiftVT, it is safe to use trunc. > + When VT is larger than ShiftVT, it is safe to use zext iff `is_zero_poison` is true (i.e., `opcode == ISD::CTTZ_ZERO_UNDEF`). See also the counterexample `src_shl_cttz2 -> tgt_shl_cttz2` in the alive2 proofs. Closes llvm#94824. Signed-off-by: Hafidz Muzakky <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The IR below miscompiles on x86 (at least). I believe the root cause is #85066 which performs the following optimization:
I think the ZEXT confuses things such that the value X=0 is incorrectly computed.
IR:
Good llc built at 765206e
Bad llc built at 6f2c610
This produces 0 for input 0, result should be 0x100.
The text was updated successfully, but these errors were encountered: