[llvm] fix ConstantFoldFP128 params (PR #98394)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 14:35:49 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-analysis

Author: None (walkingeyerobot)

<details>
<summary>Changes</summary>

I ran into this error while building:
```
llvm/lib/Analysis/ConstantFolding.cpp:2129:16: error: no matching function for call to 'ConstantFoldFP128'
 2129 |         return ConstantFoldFP128(logf128, Op->getValueAPF(), Ty);
      |                ^~~~~~~~~~~~~~~~~
llvm/lib/Analysis/ConstantFolding.cpp:1787:11: note: candidate function not viable: no known conversion from '_Float128 (_Float128) throw()' (aka '__float128 (__float128) throw()') to 'long double (*)(long double)' for 1st argument
 1787 | Constant *ConstantFoldFP128(long double (*NativeFP)(long double),
      |           ^                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
```

I'm pretty sure switching from `long double` to `float128` is correct here, and that certainly makes it work on my machine.

with glibc, logf128 is not available when compiling with clang and it is available with gcc. But, in llvm, has_float128 define isn't set unless you're using clang. So the combination of those means this block ~never actually gets used (unless you're doing something weird like I am).

This fixes what happens when this block is used, but doesn't address it actually being used.

---
Full diff: https://github.com/llvm/llvm-project/pull/98394.diff


1 Files Affected:

- (modified) llvm/lib/Analysis/ConstantFolding.cpp (+1-1) 


``````````diff
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 962880f68f076..ca82f10f1ffd4 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1784,7 +1784,7 @@ Constant *ConstantFoldFP(double (*NativeFP)(double), const APFloat &V,
 }
 
 #if defined(HAS_IEE754_FLOAT128) && defined(HAS_LOGF128)
-Constant *ConstantFoldFP128(long double (*NativeFP)(long double),
+Constant *ConstantFoldFP128(float128 (*NativeFP)(float128),
                             const APFloat &V, Type *Ty) {
   llvm_fenv_clearexcept();
   float128 Result = NativeFP(V.convertToQuad());

``````````

</details>


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


More information about the llvm-commits mailing list