[llvm] Change `fp128` lowering to use `f128` functions by default (PR #76558)

Trevor Gross via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 28 11:27:14 PDT 2025


================
@@ -39,7 +39,7 @@ define double @f5(double %x, double %y) {
 
 define fp128 @f6(fp128 %x, fp128 %y) {
 ; CHECK-LABEL: f6:
-; CHECK: brasl %r14, powl at PLT
+; CHECK: brasl %r14, powf128 at PLT
----------------
tgross35 wrote:

The logic I have with that function is that if available, *f128 should be preferred over *l if because that is always correct for `fp128`. *l would be incorrect in the unusual case that the math library was compiled with a different `-mlong-double` flag. On s390x (and others where l-d is f128) the *f128 versions are only used on glibc targets, which this test is showing, because glibc aliases the *f128 and *l functions when it knows `long double` is binary128.

The downside of course is that compiling for glibc but bringing your own libm will need to add aliases as well. This seems acceptable to me because it should be the library's responsibility to indicate that it expects `long double` to be the same as `_Float128` rather than anything else. (Also per @arsenm on Discord LLVM assumes that the libm from your libc is used, or at least has the same interfaces).

If you're fine with the change then I can update this tests showing that a musl target is unaffected. Or if you would prefer I can drop the `isGNUEnvironment` check and always use *l on s390x, since it's less likely to be a problem here.

https://github.com/llvm/llvm-project/pull/76558


More information about the llvm-commits mailing list