-
Notifications
You must be signed in to change notification settings - Fork 11.6k
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
[InstCombine] likely incorrect optimization of sitofp/fptosi roundtrip #55150
Comments
(I should have added that you don't need to believe alive2 about the change in output, we verified this independently, splitting the roundtrip across functions to defeat the backend optimizations)
|
Looks like an off-by-one error. LLVM doesn't do the optimization for i55, and I think the transformation is correct for i53. |
this sounds right to me |
The instcombine bug appears to go back to before LLVM 3.9: |
This overlaps with at least some existing tests, but the smaller types should be faster for alive2 to verify. We know that at least one of these is currently wrong (miscompile) as shown in #55150.
The same fold was added to DAGCombiner around the same time, so that's why it shows up in codegen too: I can push another patch for that once we have an approved patch for instcombine. |
Adapted from tests for IR in D124692. Also see #55150
Copied from x86 tests for multi-target coverage. Also, provides coverage for target-specific asm testing for Alive2 or its follow-ons. See #55150 and D124692
This is the codegen equivalent of D124692. As shown in #55150 - the existing fold may be wrong when converting to a signed value. This is a quick fix to avoid the miscompile. https://alive2.llvm.org/ce/z/KtaDmd Differential Revision: https://reviews.llvm.org/D124771
As shown in llvm/llvm-project#55150 - the existing fold may be wrong when converting to a signed value. This is a quick fix to avoid the miscompile. I added tests/comments for all of the signed/unsigned combinations at either side of the boundary width, and tried to confirm with Alive2: https://alive2.llvm.org/ce/z/3p9DSu There are already some TODO items in the test file that suggest possible refinements, so the regression with ui->FP->si is probably ok. It seems unlikely that we'd see these kind of edge cases with non-byte-width integer types in real code. The potential miscompile went undetected for several years. This and 747c6a0c734e fixes #55150. Differential Revision: https://reviews.llvm.org/D124692
here's a test case that lives in llvm/test/Transforms/InstCombine/sitofp.ll:
it is also performed by the x64 and arm64 backends (https://godbolt.org/z/fT15zMncK). since it is capable of changing the value that is returned, we believe it to be incorrect in the absence of fast math flags.
the alive2 compiler explorer instance times out on it, but this is the output:
cc @aqjune @nunoplopes @ryan-berger @nbushehri @zhengyang92
The text was updated successfully, but these errors were encountered: