Open liushuyu opened 2 months ago
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 f16
s as f32
s).
Which target(s) have you encountered this on?
I tried this on powerpc64le-unknown-linux-gnu
I have encountered an infinite recursion when doing
f16
arithmetics on "no-f16-f128" platforms due to questionable LLVM optimizations.
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 have encountered an infinite recursion when doing
f16
arithmetics on "no-f16-f128" platforms due to questionable LLVM optimizations.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 compiler_builtins
and LLVM 19
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
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 (storingf16
and readingi16
).I did not open a pull request because I hope someone could come up with a much better idea.