-
Notifications
You must be signed in to change notification settings - Fork 213
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
Infinite recursion in __extendhfsf2
and __truncsfhf2
on "no-f16-f128" platforms
#651
Comments
Which target(s) have you encountered this on? |
More specifically, I suspect this might be being caused by llvm/llvm-project#97981 (on several architectures LLVM currently passes |
I tried this on |
Did you discover this by trying to build compiler_builtins, or just by compiling a sample program in Rust? I don't think the latter is currently possible on ppc but just want to check. |
I tried to build a sample program using the nightly Rust but with an updated version of |
Hm, I thought these symbols weren't available from Rust's compiler_builtins because of here https://github.com/rust-lang/rust/blob/53676730146e38e4697b6204c2ee61a9fd6b7e51/library/alloc/Cargo.toml#L15-L16 |
CI in [1] seems to indicate that there are cases where the `f16` infinite recursion bug ([2], [3]) can make its way into what gets called during tests, even though this doesn't seem to be the usual case. In order to make sure that we avoid these completely, just unset `f16_enabled` on any platforms that have the recursion problem. This also refactors the `match` statement to be more in line with `library/std/build.rs`. [1]: rust-lang#729 [2]: llvm/llvm-project#97981 [3]: rust-lang#651
I have encountered an infinite recursion when doing
f16
arithmetics on "no-f16-f128" platforms due to questionable LLVM optimizations.My initial investigation shows this might be due to LLVM being too clever and optimizing the soft-float absolute value conversion to a hard-float one:
When lowering to the machine code, this causes the intrinsic function to call either itself or
__truncsfhf2
, and then__truncsfhf2
will call__extendhfsf2
again, forming an infinite recursion.My current idea is to:
... which will try to prevent LLVM from merging the absolute value masking into the
@llvm.fabs.f16
LLVM intrinsic.However, this idea introduces two extra memory operations (storing
f16
and readingi16
).I did not open a pull request because I hope someone could come up with a much better idea.
The text was updated successfully, but these errors were encountered: