-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
A miscompilation with -C lto -O -C target-cpu=haswell #45145
Comments
Since the haswell version is completely constant folded and the program contains a float->int cast, I suspect #10184 is at fault. No idea why it depends on the target CPU though. |
It also works fine without |
log₂(1E10) is 33 and a little bit, so whatever value it ends up being, it should fit into u64 just fine and therefore no cast-related UB should be happening. |
These are results with various target-cpu supported by LLVM:
|
It's fine with 1.18, but not 1.19, which corresponds to the LLVM-4 update. I also have a RHEL7 machine, with EPEL7's rust-1.20 + llvm3.9, and it works fine. So it seems clearly to be an LLVM regression. |
FWIW, this can be just However, adding a |
Fixed in #47828 |
This small program solves the Euler problem n.97:
If I compile it with normal compilation arguments like this it works correctly:
rustc -C lto -O -C target-cpu=haswell e97.rs
If I compile it with -C target-cpu=native or like this, it asserts at run time:
rustc -C lto -O -C target-cpu=haswell e97.rs
The asm compiling with:
rustc -C lto -O --emit asm e97.rs
The asm compiling with:
rustc -C lto -O -C target-cpu=haswell --emit asm e97.rs
The text was updated successfully, but these errors were encountered: