[llvm] [SimplifyLibCalls] Combine sin/cos libcall pairs into llvm.sincos (PR #184760)
Kito Cheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 5 01:50:53 PST 2026
https://github.com/kito-cheng updated https://github.com/llvm/llvm-project/pull/184760
>From 2b6c8bb9bd72ae0c530d37d051a6d285a7d0680d Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito.cheng at sifive.com>
Date: Fri, 27 Feb 2026 09:49:01 +0800
Subject: [PATCH 1/2] [SimplifyLibCalls] Combine sin/cos libcall pairs into
llvm.sincos
When both sin(x) and cos(x) are called with the same argument in a
function, replace them with a single llvm.sincos intrinsic call.
This is analogous to the existing sinpi/cospi -> sincospi_stret
optimization. The two optimizations now share a unified code path
via optimizeSinCos() with an IsPi flag.
Also remove the completed sincos TODO from Target/README.txt.
---
.../llvm/Transforms/Utils/SimplifyLibCalls.h | 5 +-
llvm/lib/Target/README.txt | 15 --
.../lib/Transforms/Utils/SimplifyLibCalls.cpp | 93 +++++++++---
llvm/test/Transforms/InstCombine/sincos.ll | 136 ++++++++++++++++++
4 files changed, 210 insertions(+), 39 deletions(-)
create mode 100644 llvm/test/Transforms/InstCombine/sincos.ll
diff --git a/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h b/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
index df98131a54ca9..14da88a66fd61 100644
--- a/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
+++ b/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
@@ -210,6 +210,8 @@ class LibCallSimplifier {
Value *optimizeFMod(CallInst *CI, IRBuilderBase &B);
Value *mergeSqrtToExp(CallInst *CI, IRBuilderBase &B);
Value *optimizeSinCosPi(CallInst *CI, bool IsSin, IRBuilderBase &B);
+ Value *optimizeSinCos(CallInst *CI, bool IsSin, IRBuilderBase &B,
+ bool IsPi = false);
Value *optimizeTrigInversionPairs(CallInst *CI, IRBuilderBase &B);
Value *optimizeSymmetric(CallInst *CI, LibFunc Func, IRBuilderBase &B);
Value *optimizeRemquo(CallInst *CI, IRBuilderBase &B);
@@ -247,7 +249,8 @@ class LibCallSimplifier {
void classifyArgUse(Value *Val, Function *F, bool IsFloat,
SmallVectorImpl<CallInst *> &SinCalls,
SmallVectorImpl<CallInst *> &CosCalls,
- SmallVectorImpl<CallInst *> &SinCosCalls);
+ SmallVectorImpl<CallInst *> &SinCosCalls,
+ bool IsPi);
Value *optimizePrintFString(CallInst *CI, IRBuilderBase &B);
Value *optimizeSPrintFString(CallInst *CI, IRBuilderBase &B);
Value *optimizeSnPrintFString(CallInst *CI, IRBuilderBase &B);
diff --git a/llvm/lib/Target/README.txt b/llvm/lib/Target/README.txt
index adf75c3368677..4d98a5fac3984 100644
--- a/llvm/lib/Target/README.txt
+++ b/llvm/lib/Target/README.txt
@@ -132,21 +132,6 @@ emit:
//===---------------------------------------------------------------------===//
-Combine: a = sin(x), b = cos(x) into a,b = sincos(x).
-
-Expand these to calls of sin/cos and stores:
- double sincos(double x, double *sin, double *cos);
- float sincosf(float x, float *sin, float *cos);
- long double sincosl(long double x, long double *sin, long double *cos);
-
-Doing so could allow SROA of the destination pointers. See also:
-http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17687
-
-This is now easily doable with MRVs. We could even make an intrinsic for this
-if anyone cared enough about sincos.
-
-//===---------------------------------------------------------------------===//
-
quantum_sigma_x in 462.libquantum contains the following loop:
for(i=0; i<reg->size; i++)
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 3b68afe8700dd..4ce540c4376e2 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -2941,9 +2941,10 @@ static bool isTrigLibCall(CallInst *CI) {
return CI->doesNotThrow() && CI->doesNotAccessMemory();
}
-static bool insertSinCosCall(IRBuilderBase &B, Function *OrigCallee, Value *Arg,
- bool UseFloat, Value *&Sin, Value *&Cos,
- Value *&SinCos, const TargetLibraryInfo *TLI) {
+static bool insertSinCosPiCall(IRBuilderBase &B, Function *OrigCallee,
+ Value *Arg, bool UseFloat, Value *&Sin,
+ Value *&Cos, Value *&SinCos,
+ const TargetLibraryInfo *TLI) {
Module *M = OrigCallee->getParent();
Type *ArgTy = Arg->getType();
Type *ResTy;
@@ -3051,7 +3052,13 @@ Value *LibCallSimplifier::optimizeSymmetric(CallInst *CI, LibFunc Func,
}
}
-Value *LibCallSimplifier::optimizeSinCosPi(CallInst *CI, bool IsSin, IRBuilderBase &B) {
+Value *LibCallSimplifier::optimizeSinCosPi(CallInst *CI, bool IsSin,
+ IRBuilderBase &B) {
+ return optimizeSinCos(CI, IsSin, B, /*IsPi=*/true);
+}
+
+Value *LibCallSimplifier::optimizeSinCos(CallInst *CI, bool IsSin,
+ IRBuilderBase &B, bool IsPi) {
// Make sure the prototype is as expected, otherwise the rest of the
// function is probably invalid and likely to abort.
if (!isTrigLibCall(CI))
@@ -3067,21 +3074,41 @@ Value *LibCallSimplifier::optimizeSinCosPi(CallInst *CI, bool IsSin, IRBuilderBa
bool IsFloat = Arg->getType()->isFloatTy();
- // Look for all compatible sinpi, cospi and sincospi calls with the same
+ // Look for all compatible sin/cos (or sinpi/cospi) calls with the same
// argument. If there are enough (in some sense) we can make the
// substitution.
Function *F = CI->getFunction();
for (User *U : Arg->users())
- classifyArgUse(U, F, IsFloat, SinCalls, CosCalls, SinCosCalls);
+ classifyArgUse(U, F, IsFloat, SinCalls, CosCalls, SinCosCalls, IsPi);
- // It's only worthwhile if both sinpi and cospi are actually used.
+ // It's only worthwhile if both sin and cos are actually used.
if (SinCalls.empty() || CosCalls.empty())
return nullptr;
Value *Sin, *Cos, *SinCos;
- if (!insertSinCosCall(B, CI->getCalledFunction(), Arg, IsFloat, Sin, Cos,
- SinCos, TLI))
- return nullptr;
+ if (IsPi) {
+ // For sinpi/cospi, use platform-specific __sincospi_stret libcall.
+ if (!insertSinCosPiCall(B, CI->getCalledFunction(), Arg, IsFloat, Sin, Cos,
+ SinCos, TLI))
+ return nullptr;
+ } else {
+ // For sin/cos, use the llvm.sincos intrinsic.
+ IRBuilderBase::InsertPointGuard Guard(B);
+ if (Instruction *ArgInst = dyn_cast<Instruction>(Arg)) {
+ B.SetInsertPoint(ArgInst->getParent(), ++ArgInst->getIterator());
+ } else {
+ BasicBlock &EntryBB = B.GetInsertBlock()->getParent()->getEntryBlock();
+ B.SetInsertPoint(&EntryBB, EntryBB.begin());
+ }
+
+ Module *M = CI->getModule();
+ Type *ArgTy = Arg->getType();
+ Function *SinCosFunc =
+ Intrinsic::getOrInsertDeclaration(M, Intrinsic::sincos, ArgTy);
+ SinCos = B.CreateCall(SinCosFunc, Arg, "sincos");
+ Sin = B.CreateExtractValue(SinCos, 0, "sin");
+ Cos = B.CreateExtractValue(SinCos, 1, "cos");
+ }
auto replaceTrigInsts = [this](SmallVectorImpl<CallInst *> &Calls,
Value *Res) {
@@ -3100,7 +3127,7 @@ void LibCallSimplifier::classifyArgUse(
Value *Val, Function *F, bool IsFloat,
SmallVectorImpl<CallInst *> &SinCalls,
SmallVectorImpl<CallInst *> &CosCalls,
- SmallVectorImpl<CallInst *> &SinCosCalls) {
+ SmallVectorImpl<CallInst *> &SinCosCalls, bool IsPi) {
auto *CI = dyn_cast<CallInst>(Val);
if (!CI || CI->use_empty())
return;
@@ -3117,20 +3144,29 @@ void LibCallSimplifier::classifyArgUse(
!isTrigLibCall(CI))
return;
- if (IsFloat) {
- if (Func == LibFunc_sinpif)
- SinCalls.push_back(CI);
- else if (Func == LibFunc_cospif)
- CosCalls.push_back(CI);
- else if (Func == LibFunc_sincospif_stret)
- SinCosCalls.push_back(CI);
+ if (IsPi) {
+ if (IsFloat) {
+ if (Func == LibFunc_sinpif)
+ SinCalls.push_back(CI);
+ else if (Func == LibFunc_cospif)
+ CosCalls.push_back(CI);
+ else if (Func == LibFunc_sincospif_stret)
+ SinCosCalls.push_back(CI);
+ } else {
+ if (Func == LibFunc_sinpi)
+ SinCalls.push_back(CI);
+ else if (Func == LibFunc_cospi)
+ CosCalls.push_back(CI);
+ else if (Func == LibFunc_sincospi_stret)
+ SinCosCalls.push_back(CI);
+ }
} else {
- if (Func == LibFunc_sinpi)
+ if (Func == LibFunc_sin || Func == LibFunc_sinf ||
+ Func == LibFunc_sinl)
SinCalls.push_back(CI);
- else if (Func == LibFunc_cospi)
+ else if (Func == LibFunc_cos || Func == LibFunc_cosf ||
+ Func == LibFunc_cosl)
CosCalls.push_back(CI);
- else if (Func == LibFunc_sincospi_stret)
- SinCosCalls.push_back(CI);
}
}
@@ -4029,6 +4065,12 @@ Value *LibCallSimplifier::optimizeFloatingPointLibCall(CallInst *CI,
case LibFunc_cospif:
case LibFunc_cospi:
return optimizeSinCosPi(CI, /*IsSin*/false, Builder);
+ case LibFunc_sinf:
+ case LibFunc_sinl:
+ return optimizeSinCos(CI, /*IsSin*/true, Builder);
+ case LibFunc_cosf:
+ case LibFunc_cosl:
+ return optimizeSinCos(CI, /*IsSin*/false, Builder);
case LibFunc_powf:
case LibFunc_pow:
case LibFunc_powl:
@@ -4103,8 +4145,13 @@ Value *LibCallSimplifier::optimizeFloatingPointLibCall(CallInst *CI,
case LibFunc_exp:
case LibFunc_exp10:
case LibFunc_expm1:
- case LibFunc_cos:
case LibFunc_sin:
+ case LibFunc_cos:
+ if (Value *V = optimizeSinCos(CI, Func == LibFunc_sin, Builder))
+ return V;
+ if (UnsafeFPShrink && hasFloatVersion(M, CI->getCalledFunction()->getName()))
+ return optimizeUnaryDoubleFP(CI, Builder, TLI, true);
+ return nullptr;
case LibFunc_tanh:
if (UnsafeFPShrink && hasFloatVersion(M, CI->getCalledFunction()->getName()))
return optimizeUnaryDoubleFP(CI, Builder, TLI, true);
diff --git a/llvm/test/Transforms/InstCombine/sincos.ll b/llvm/test/Transforms/InstCombine/sincos.ll
new file mode 100644
index 0000000000000..00fc060b3287d
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/sincos.ll
@@ -0,0 +1,136 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes=instcombine -S < %s -mtriple=x86_64-apple-macosx10.9 | FileCheck %s --check-prefixes=CHECK,CHECK-DOUBLE-ALIGN8
+; RUN: opt -passes=instcombine -S < %s -mtriple=arm-apple-ios7.0 | FileCheck %s --check-prefixes=CHECK,CHECK-DOUBLE-ALIGN4
+; RUN: opt -passes=instcombine -S < %s -mtriple=x86_64-none-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-DOUBLE-ALIGN8-LINUX
+; REQUIRES: arm-registered-target, x86-registered-target
+
+attributes #0 = { readnone nounwind }
+
+declare float @sinf(float) #0
+declare float @cosf(float) #0
+declare double @sin(double) #0
+declare double @cos(double) #0
+
+ at var32 = global float 0.0
+ at var64 = global double 0.0
+
+; Basic sin+cos combination for float
+define float @sincos_f32() {
+; CHECK-LABEL: @sincos_f32(
+; CHECK-NEXT: [[VAL:%.*]] = load float, ptr @var32, align 4
+; CHECK-NEXT: [[SINCOS:%.*]] = call { float, float } @llvm.sincos.f32(float [[VAL]])
+; CHECK-NEXT: [[SIN:%.*]] = extractvalue { float, float } [[SINCOS]], 0
+; CHECK-NEXT: [[COS:%.*]] = extractvalue { float, float } [[SINCOS]], 1
+; CHECK-NEXT: [[C:%.*]] = call float @cosf(float [[VAL]]) #[[ATTR0:[0-9]+]]
+; CHECK-NEXT: [[RES:%.*]] = fadd float [[SIN]], [[COS]]
+; CHECK-NEXT: ret float [[RES]]
+;
+ %val = load float, ptr @var32
+ %s = call float @sinf(float %val) #0
+ %c = call float @cosf(float %val) #0
+ %res = fadd float %s, %c
+ ret float %res
+}
+
+; Basic sin+cos combination for double
+define double @sincos_f64() {
+; CHECK-DOUBLE-ALIGN8-LABEL: @sincos_f64(
+; CHECK-DOUBLE-ALIGN8-NEXT: [[VAL:%.*]] = load double, ptr @var64, align 8
+; CHECK-DOUBLE-ALIGN8-NEXT: [[SINCOS:%.*]] = call { double, double } @llvm.sincos.f64(double [[VAL]])
+; CHECK-DOUBLE-ALIGN8-NEXT: [[SIN:%.*]] = extractvalue { double, double } [[SINCOS]], 0
+; CHECK-DOUBLE-ALIGN8-NEXT: [[COS:%.*]] = extractvalue { double, double } [[SINCOS]], 1
+; CHECK-DOUBLE-ALIGN8-NEXT: [[C:%.*]] = call double @cos(double [[VAL]]) #[[ATTR0]]
+; CHECK-DOUBLE-ALIGN8-NEXT: [[RES:%.*]] = fadd double [[SIN]], [[COS]]
+; CHECK-DOUBLE-ALIGN8-NEXT: ret double [[RES]]
+;
+; CHECK-DOUBLE-ALIGN4-LABEL: @sincos_f64(
+; CHECK-DOUBLE-ALIGN4-NEXT: [[VAL:%.*]] = load double, ptr @var64, align 4
+; CHECK-DOUBLE-ALIGN4-NEXT: [[SINCOS:%.*]] = call { double, double } @llvm.sincos.f64(double [[VAL]])
+; CHECK-DOUBLE-ALIGN4-NEXT: [[SIN:%.*]] = extractvalue { double, double } [[SINCOS]], 0
+; CHECK-DOUBLE-ALIGN4-NEXT: [[COS:%.*]] = extractvalue { double, double } [[SINCOS]], 1
+; CHECK-DOUBLE-ALIGN4-NEXT: [[C:%.*]] = call double @cos(double [[VAL]]) #[[ATTR0]]
+; CHECK-DOUBLE-ALIGN4-NEXT: [[RES:%.*]] = fadd double [[SIN]], [[COS]]
+; CHECK-DOUBLE-ALIGN4-NEXT: ret double [[RES]]
+;
+; CHECK-DOUBLE-ALIGN8-LINUX-LABEL: @sincos_f64(
+; CHECK-DOUBLE-ALIGN8-LINUX-NEXT: [[VAL:%.*]] = load double, ptr @var64, align 8
+; CHECK-DOUBLE-ALIGN8-LINUX-NEXT: [[SINCOS:%.*]] = call { double, double } @llvm.sincos.f64(double [[VAL]])
+; CHECK-DOUBLE-ALIGN8-LINUX-NEXT: [[SIN:%.*]] = extractvalue { double, double } [[SINCOS]], 0
+; CHECK-DOUBLE-ALIGN8-LINUX-NEXT: [[COS:%.*]] = extractvalue { double, double } [[SINCOS]], 1
+; CHECK-DOUBLE-ALIGN8-LINUX-NEXT: [[C:%.*]] = call double @cos(double [[VAL]]) #[[ATTR0]]
+; CHECK-DOUBLE-ALIGN8-LINUX-NEXT: [[RES:%.*]] = fadd double [[SIN]], [[COS]]
+; CHECK-DOUBLE-ALIGN8-LINUX-NEXT: ret double [[RES]]
+;
+ %val = load double, ptr @var64
+ %s = call double @sin(double %val) #0
+ %c = call double @cos(double %val) #0
+ %res = fadd double %s, %c
+ ret double %res
+}
+
+; Only sin, no cos - should NOT combine
+define float @sin_only_f32(float %x) {
+; CHECK-LABEL: @sin_only_f32(
+; CHECK-NEXT: [[S:%.*]] = call float @sinf(float [[X:%.*]]) #[[ATTR0]]
+; CHECK-NEXT: ret float [[S]]
+;
+ %s = call float @sinf(float %x) #0
+ ret float %s
+}
+
+; Only cos, no sin - should NOT combine
+define float @cos_only_f32(float %x) {
+; CHECK-LABEL: @cos_only_f32(
+; CHECK-NEXT: [[C:%.*]] = call float @cosf(float [[X:%.*]]) #[[ATTR0]]
+; CHECK-NEXT: ret float [[C]]
+;
+ %c = call float @cosf(float %x) #0
+ ret float %c
+}
+
+; Different arguments - should NOT combine
+define float @sincos_different_args(float %x, float %y) {
+; CHECK-LABEL: @sincos_different_args(
+; CHECK-NEXT: [[S:%.*]] = call float @sinf(float [[X:%.*]]) #[[ATTR0]]
+; CHECK-NEXT: [[C:%.*]] = call float @cosf(float [[Y:%.*]]) #[[ATTR0]]
+; CHECK-NEXT: [[RES:%.*]] = fadd float [[S]], [[C]]
+; CHECK-NEXT: ret float [[RES]]
+;
+ %s = call float @sinf(float %x) #0
+ %c = call float @cosf(float %y) #0
+ %res = fadd float %s, %c
+ ret float %res
+}
+
+; Constant argument - should NOT combine
+define float @sincos_const_arg() {
+; CHECK-LABEL: @sincos_const_arg(
+; CHECK-NEXT: [[S:%.*]] = call float @sinf(float 1.000000e+00) #[[ATTR0]]
+; CHECK-NEXT: [[C:%.*]] = call float @cosf(float 1.000000e+00) #[[ATTR0]]
+; CHECK-NEXT: ret float 0x3FF61BBE40000000
+;
+ %s = call float @sinf(float 1.0) #0
+ %c = call float @cosf(float 1.0) #0
+ %res = fadd float %s, %c
+ ret float %res
+}
+
+; Multiple uses of sin and cos results
+define float @sincos_multi_use(float %x) {
+; CHECK-LABEL: @sincos_multi_use(
+; CHECK-NEXT: [[SINCOS:%.*]] = call { float, float } @llvm.sincos.f32(float [[X:%.*]])
+; CHECK-NEXT: [[SIN:%.*]] = extractvalue { float, float } [[SINCOS]], 0
+; CHECK-NEXT: [[COS:%.*]] = extractvalue { float, float } [[SINCOS]], 1
+; CHECK-NEXT: [[C:%.*]] = call float @cosf(float [[X]]) #[[ATTR0]]
+; CHECK-NEXT: [[ADD:%.*]] = fadd float [[SIN]], [[COS]]
+; CHECK-NEXT: [[MUL:%.*]] = fmul float [[SIN]], [[COS]]
+; CHECK-NEXT: [[RES:%.*]] = fadd float [[ADD]], [[MUL]]
+; CHECK-NEXT: ret float [[RES]]
+;
+ %s = call float @sinf(float %x) #0
+ %c = call float @cosf(float %x) #0
+ %add = fadd float %s, %c
+ %mul = fmul float %s, %c
+ %res = fadd float %add, %mul
+ ret float %res
+}
>From 6cbacc50a29f2fe4d2f66bd75ca455dda04dfdcd Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito.cheng at sifive.com>
Date: Thu, 5 Mar 2026 17:49:50 +0800
Subject: [PATCH 2/2] !fixup: Fix clang-format issues in SimplifyLibCalls
---
.../llvm/Transforms/Utils/SimplifyLibCalls.h | 3 +--
.../lib/Transforms/Utils/SimplifyLibCalls.cpp | 22 +++++++++----------
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h b/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
index 14da88a66fd61..e174a1c484eec 100644
--- a/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
+++ b/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
@@ -249,8 +249,7 @@ class LibCallSimplifier {
void classifyArgUse(Value *Val, Function *F, bool IsFloat,
SmallVectorImpl<CallInst *> &SinCalls,
SmallVectorImpl<CallInst *> &CosCalls,
- SmallVectorImpl<CallInst *> &SinCosCalls,
- bool IsPi);
+ SmallVectorImpl<CallInst *> &SinCosCalls, bool IsPi);
Value *optimizePrintFString(CallInst *CI, IRBuilderBase &B);
Value *optimizeSPrintFString(CallInst *CI, IRBuilderBase &B);
Value *optimizeSnPrintFString(CallInst *CI, IRBuilderBase &B);
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 4ce540c4376e2..155a037c9495a 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -3053,7 +3053,7 @@ Value *LibCallSimplifier::optimizeSymmetric(CallInst *CI, LibFunc Func,
}
Value *LibCallSimplifier::optimizeSinCosPi(CallInst *CI, bool IsSin,
- IRBuilderBase &B) {
+ IRBuilderBase &B) {
return optimizeSinCos(CI, IsSin, B, /*IsPi=*/true);
}
@@ -3123,11 +3123,11 @@ Value *LibCallSimplifier::optimizeSinCos(CallInst *CI, bool IsSin,
return IsSin ? Sin : Cos;
}
-void LibCallSimplifier::classifyArgUse(
- Value *Val, Function *F, bool IsFloat,
- SmallVectorImpl<CallInst *> &SinCalls,
- SmallVectorImpl<CallInst *> &CosCalls,
- SmallVectorImpl<CallInst *> &SinCosCalls, bool IsPi) {
+void LibCallSimplifier::classifyArgUse(Value *Val, Function *F, bool IsFloat,
+ SmallVectorImpl<CallInst *> &SinCalls,
+ SmallVectorImpl<CallInst *> &CosCalls,
+ SmallVectorImpl<CallInst *> &SinCosCalls,
+ bool IsPi) {
auto *CI = dyn_cast<CallInst>(Val);
if (!CI || CI->use_empty())
return;
@@ -3161,8 +3161,7 @@ void LibCallSimplifier::classifyArgUse(
SinCosCalls.push_back(CI);
}
} else {
- if (Func == LibFunc_sin || Func == LibFunc_sinf ||
- Func == LibFunc_sinl)
+ if (Func == LibFunc_sin || Func == LibFunc_sinf || Func == LibFunc_sinl)
SinCalls.push_back(CI);
else if (Func == LibFunc_cos || Func == LibFunc_cosf ||
Func == LibFunc_cosl)
@@ -4067,10 +4066,10 @@ Value *LibCallSimplifier::optimizeFloatingPointLibCall(CallInst *CI,
return optimizeSinCosPi(CI, /*IsSin*/false, Builder);
case LibFunc_sinf:
case LibFunc_sinl:
- return optimizeSinCos(CI, /*IsSin*/true, Builder);
+ return optimizeSinCos(CI, /*IsSin*/ true, Builder);
case LibFunc_cosf:
case LibFunc_cosl:
- return optimizeSinCos(CI, /*IsSin*/false, Builder);
+ return optimizeSinCos(CI, /*IsSin*/ false, Builder);
case LibFunc_powf:
case LibFunc_pow:
case LibFunc_powl:
@@ -4149,7 +4148,8 @@ Value *LibCallSimplifier::optimizeFloatingPointLibCall(CallInst *CI,
case LibFunc_cos:
if (Value *V = optimizeSinCos(CI, Func == LibFunc_sin, Builder))
return V;
- if (UnsafeFPShrink && hasFloatVersion(M, CI->getCalledFunction()->getName()))
+ if (UnsafeFPShrink &&
+ hasFloatVersion(M, CI->getCalledFunction()->getName()))
return optimizeUnaryDoubleFP(CI, Builder, TLI, true);
return nullptr;
case LibFunc_tanh:
More information about the llvm-commits
mailing list