llvm.org GIT mirror llvm / fd06cb2
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342542 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 1 year, 9 months ago
2 changed file(s) with 19 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
745745 LibFunc DoubleFn, LibFunc FloatFn,
746746 LibFunc LongDoubleFn) {
747747 switch (Ty->getTypeID()) {
748 case Type::HalfTyID:
749 return false;
748750 case Type::FloatTyID:
749751 return TLI->has(FloatFn);
750752 case Type::DoubleTyID:
7777 ret double %div
7878 }
7979
80 define half @fdiv_cosf16_sinf16_reassoc(half %a) {
81 ; CHECK-LABEL: @fdiv_cosf16_sinf16_reassoc(
82 ; CHECK-NEXT: [[TMP1:%.*]] = call reassoc half @llvm.cos.f16(half [[A:%.*]])
83 ; CHECK-NEXT: [[TMP2:%.*]] = call reassoc half @llvm.sin.f16(half [[A]])
84 ; CHECK-NEXT: [[DIV:%.*]] = fdiv reassoc half [[TMP1]], [[TMP2]]
85 ; CHECK-NEXT: ret half [[DIV]]
86 ;
87 %1 = call reassoc half @llvm.cos.f16(half %a)
88 %2 = call reassoc half @llvm.sin.f16(half %a)
89 %div = fdiv reassoc half %1, %2
90 ret half %div
91 }
92
8093 define float @fdiv_cosf_sinf_reassoc(float %a) {
8194 ; CHECK-LABEL: @fdiv_cosf_sinf_reassoc(
8295 ; CHECK-NEXT: [[TANF:%.*]] = call reassoc float @tanf(float [[A:%.*]]) #1
101114 ret fp128 %div
102115 }
103116
117 declare half @llvm.cos.f16(half) #1
118 declare float @llvm.cos.f32(float) #1
104119 declare double @llvm.cos.f64(double) #1
105 declare float @llvm.cos.f32(float) #1
106120 declare fp128 @llvm.cos.fp128(fp128) #1
107121
122 declare half @llvm.sin.f16(half) #1
123 declare float @llvm.sin.f32(float) #1
108124 declare double @llvm.sin.f64(double) #1
109 declare float @llvm.sin.f32(float) #1
110125 declare fp128 @llvm.sin.fp128(fp128) #1
111126
112127 declare void @use(double)