summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2018-09-19 12:01:38 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2018-09-19 12:01:38 +0000
commite5e1ea79fd2ceff7f5931300165286be018a64c1 (patch)
treefa10b9ac0dea3954626e911f6d05bffba1d9423e
parent86a5e436564b6af8fc209654114fa19dccfae71b (diff)
downloadbcm5719-llvm-e5e1ea79fd2ceff7f5931300165286be018a64c1.tar.gz
bcm5719-llvm-e5e1ea79fd2ceff7f5931300165286be018a64c1.zip
[InstCombine] Don't transform sin/cos -> tanl if for half types
This is still unsafe for long double, we will transform things into tanl even if tanl is for another type. But that's for someone else to fix. llvm-svn: 342542
-rw-r--r--llvm/lib/Transforms/Utils/BuildLibCalls.cpp2
-rw-r--r--llvm/test/Transforms/InstCombine/fdiv-cos-sin.ll19
2 files changed, 19 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
index b782641383a..6eb39e5b959 100644
--- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
@@ -746,6 +746,8 @@ bool llvm::hasUnaryFloatFn(const TargetLibraryInfo *TLI, Type *Ty,
LibFunc DoubleFn, LibFunc FloatFn,
LibFunc LongDoubleFn) {
switch (Ty->getTypeID()) {
+ case Type::HalfTyID:
+ return false;
case Type::FloatTyID:
return TLI->has(FloatFn);
case Type::DoubleTyID:
diff --git a/llvm/test/Transforms/InstCombine/fdiv-cos-sin.ll b/llvm/test/Transforms/InstCombine/fdiv-cos-sin.ll
index 328eae03d60..3284e1f1b1c 100644
--- a/llvm/test/Transforms/InstCombine/fdiv-cos-sin.ll
+++ b/llvm/test/Transforms/InstCombine/fdiv-cos-sin.ll
@@ -78,6 +78,19 @@ define double @fdiv_cos_sin_reassoc(double %a) {
ret double %div
}
+define half @fdiv_cosf16_sinf16_reassoc(half %a) {
+; CHECK-LABEL: @fdiv_cosf16_sinf16_reassoc(
+; CHECK-NEXT: [[TMP1:%.*]] = call reassoc half @llvm.cos.f16(half [[A:%.*]])
+; CHECK-NEXT: [[TMP2:%.*]] = call reassoc half @llvm.sin.f16(half [[A]])
+; CHECK-NEXT: [[DIV:%.*]] = fdiv reassoc half [[TMP1]], [[TMP2]]
+; CHECK-NEXT: ret half [[DIV]]
+;
+ %1 = call reassoc half @llvm.cos.f16(half %a)
+ %2 = call reassoc half @llvm.sin.f16(half %a)
+ %div = fdiv reassoc half %1, %2
+ ret half %div
+}
+
define float @fdiv_cosf_sinf_reassoc(float %a) {
; CHECK-LABEL: @fdiv_cosf_sinf_reassoc(
; CHECK-NEXT: [[TANF:%.*]] = call reassoc float @tanf(float [[A:%.*]]) #1
@@ -102,12 +115,14 @@ define fp128 @fdiv_cosfp128_sinfp128_reassoc(fp128 %a) {
ret fp128 %div
}
-declare double @llvm.cos.f64(double) #1
+declare half @llvm.cos.f16(half) #1
declare float @llvm.cos.f32(float) #1
+declare double @llvm.cos.f64(double) #1
declare fp128 @llvm.cos.fp128(fp128) #1
-declare double @llvm.sin.f64(double) #1
+declare half @llvm.sin.f16(half) #1
declare float @llvm.sin.f32(float) #1
+declare double @llvm.sin.f64(double) #1
declare fp128 @llvm.sin.fp128(fp128) #1
declare void @use(double)
OpenPOWER on IntegriCloud