[llvm] Added fix to enable constant folding that is missing for math library functions (scalbln , scalbn, ldexp) (PR #169893)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 28 05:20:47 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h b/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
index 72b8f4b42..67d6bb133 100644
--- a/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
+++ b/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
@@ -216,7 +216,7 @@ private:
Value *optimizeFdim(CallInst *CI, IRBuilderBase &B);
Value *foldLdexp(CallInst *CI, IRBuilderBase &B);
-
+
// Wrapper for all floating point library call optimizations
Value *optimizeFloatingPointLibCall(CallInst *CI, LibFunc Func,
IRBuilderBase &B);
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 702705ec0..809af8d3f 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -2469,24 +2469,24 @@ Value *LibCallSimplifier::optimizePow(CallInst *Pow, IRBuilderBase &B) {
return nullptr;
}
-Value *LibCallSimplifier::foldLdexp(CallInst *CI,IRBuilderBase &B) {
+Value *LibCallSimplifier::foldLdexp(CallInst *CI, IRBuilderBase &B) {
- Type*RequiredType = CI->getType();
- if(!RequiredType->isFPOrFPVectorTy())
+ Type *RequiredType = CI->getType();
+ if (!RequiredType->isFPOrFPVectorTy())
return nullptr;
- Value*x = CI->getArgOperand(0);
- Value*exp = CI->getArgOperand(1);
- Module*M = CI->getModule();
+ Value *x = CI->getArgOperand(0);
+ Value *exp = CI->getArgOperand(1);
+ Module *M = CI->getModule();
+
+ Function *ldexpDecl = llvm::Intrinsic::getOrInsertDeclaration(
+ M, Intrinsic::ldexp, {RequiredType, exp->getType()});
- Function*ldexpDecl = llvm::Intrinsic::getOrInsertDeclaration(M, Intrinsic::ldexp,{RequiredType, exp->getType()});
-
CallInst *NewCall = B.CreateCall(ldexpDecl, {x, exp}, CI->getName());
NewCall->setAttributes(CI->getAttributes());
return copyFlags(*CI, NewCall);
}
-
Value *LibCallSimplifier::optimizeExp2(CallInst *CI, IRBuilderBase &B) {
Module *M = CI->getModule();
Function *Callee = CI->getCalledFunction();
``````````
</details>
https://github.com/llvm/llvm-project/pull/169893
More information about the llvm-commits
mailing list