Skip to content

Commit 189d471

Browse files
farzonlFarzon Lotfi
and
Farzon Lotfi
authored
[clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (#94559)
Relanding this PR now that #90503 has merged. with `FTAN` landing in [TargetLoweringBase.cpp:L1021](https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/TargetLoweringBase.cpp#L1020C23-L1021C63 ) There is now a llvm tan intrinsic 32\64\128 Expand case for all llvm backends. In LLVM, the `llvm.experimental.constrained.cos` and `llvm.experimental.constrained.sin` intrinsics are used for performing cosine and sine calculations with additional constraints on floating-point operations. This behavior is expected for all floating-point math intrinsics. This change adds these constraints for the `tan` intrinsic. - `Builtins.td` - replace TanF128 with F16F128MathTemplate - `CGBuiltin.cpp` - map existing tan builtins to `tan` and `constrained_tan` intrinsic - `ConstrainedOps.def` map tan and constrained_tan to an ISDOpcode. resolves #91421 --------- Co-authored-by: Farzon Lotfi <[email protected]>
1 parent 1737814 commit 189d471

26 files changed

+1437
-21
lines changed

clang/include/clang/Basic/Builtins.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,11 @@ def SqrtF16F128 : Builtin, F16F128MathTemplate {
482482
let Prototype = "T(T)";
483483
}
484484

485-
def TanF128 : Builtin {
486-
let Spellings = ["__builtin_tanf128"];
485+
def TanF16F128 : Builtin, F16F128MathTemplate {
486+
let Spellings = ["__builtin_tan"];
487487
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
488488
ConstIgnoringErrnoAndExceptions];
489-
let Prototype = "__float128(__float128)";
489+
let Prototype = "T(T)";
490490
}
491491

492492
def TanhF128 : Builtin {

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,6 +2923,18 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
29232923
SetSqrtFPAccuracy(Call);
29242924
return RValue::get(Call);
29252925
}
2926+
2927+
case Builtin::BItan:
2928+
case Builtin::BItanf:
2929+
case Builtin::BItanl:
2930+
case Builtin::BI__builtin_tan:
2931+
case Builtin::BI__builtin_tanf:
2932+
case Builtin::BI__builtin_tanf16:
2933+
case Builtin::BI__builtin_tanl:
2934+
case Builtin::BI__builtin_tanf128:
2935+
return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(
2936+
*this, E, Intrinsic::tan, Intrinsic::experimental_constrained_tan));
2937+
29262938
case Builtin::BItrunc:
29272939
case Builtin::BItruncf:
29282940
case Builtin::BItruncl:

clang/test/CodeGen/X86/math-builtins.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,10 @@ __builtin_sqrt(f); __builtin_sqrtf(f); __builtin_sqrtl(f); __builtin_
674674

675675
__builtin_tan(f); __builtin_tanf(f); __builtin_tanl(f); __builtin_tanf128(f);
676676

677-
// NO__ERRNO: declare double @tan(double noundef) [[READNONE]]
678-
// NO__ERRNO: declare float @tanf(float noundef) [[READNONE]]
679-
// NO__ERRNO: declare x86_fp80 @tanl(x86_fp80 noundef) [[READNONE]]
680-
// NO__ERRNO: declare fp128 @tanf128(fp128 noundef) [[READNONE]]
677+
// NO__ERRNO: declare double @llvm.tan.f64(double) [[READNONE_INTRINSIC]]
678+
// NO__ERRNO: declare float @llvm.tan.f32(float) [[READNONE_INTRINSIC]]
679+
// NO__ERRNO: declare x86_fp80 @llvm.tan.f80(x86_fp80) [[READNONE_INTRINSIC]]
680+
// NO__ERRNO: declare fp128 @llvm.tan.f128(fp128) [[READNONE_INTRINSIC]]
681681
// HAS_ERRNO: declare double @tan(double noundef) [[NOT_READNONE]]
682682
// HAS_ERRNO: declare float @tanf(float noundef) [[NOT_READNONE]]
683683
// HAS_ERRNO: declare x86_fp80 @tanl(x86_fp80 noundef) [[NOT_READNONE]]

clang/test/CodeGen/constrained-math-builtins.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c, _
183183
// CHECK: call x86_fp80 @llvm.experimental.constrained.sqrt.f80(x86_fp80 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
184184
// CHECK: call fp128 @llvm.experimental.constrained.sqrt.f128(fp128 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
185185

186+
__builtin_tan(f); __builtin_tanf(f); __builtin_tanl(f); __builtin_tanf128(f);
187+
188+
// CHECK: call double @llvm.experimental.constrained.tan.f64(double %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
189+
// CHECK: call float @llvm.experimental.constrained.tan.f32(float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
190+
// CHECK: call x86_fp80 @llvm.experimental.constrained.tan.f80(x86_fp80 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
191+
// CHECK: call fp128 @llvm.experimental.constrained.tan.f128(fp128 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
192+
193+
186194
__builtin_trunc(f); __builtin_truncf(f); __builtin_truncl(f); __builtin_truncf128(f);
187195

188196
// CHECK: call double @llvm.experimental.constrained.trunc.f64(double %{{.*}}, metadata !"fpexcept.strict")
@@ -315,6 +323,11 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c, _
315323
// CHECK: declare x86_fp80 @llvm.experimental.constrained.sqrt.f80(x86_fp80, metadata, metadata)
316324
// CHECK: declare fp128 @llvm.experimental.constrained.sqrt.f128(fp128, metadata, metadata)
317325

326+
// CHECK: declare double @llvm.experimental.constrained.tan.f64(double, metadata, metadata)
327+
// CHECK: declare float @llvm.experimental.constrained.tan.f32(float, metadata, metadata)
328+
// CHECK: declare x86_fp80 @llvm.experimental.constrained.tan.f80(x86_fp80, metadata, metadata)
329+
// CHECK: declare fp128 @llvm.experimental.constrained.tan.f128(fp128, metadata, metadata)
330+
318331
// CHECK: declare double @llvm.experimental.constrained.trunc.f64(double, metadata)
319332
// CHECK: declare float @llvm.experimental.constrained.trunc.f32(float, metadata)
320333
// CHECK: declare x86_fp80 @llvm.experimental.constrained.trunc.f80(x86_fp80, metadata)

clang/test/CodeGen/math-libcalls.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -662,15 +662,15 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
662662

663663
tan(f); tanf(f); tanl(f);
664664

665-
// NO__ERRNO: declare double @tan(double noundef) [[READNONE]]
666-
// NO__ERRNO: declare float @tanf(float noundef) [[READNONE]]
667-
// NO__ERRNO: declare x86_fp80 @tanl(x86_fp80 noundef) [[READNONE]]
665+
// NO__ERRNO: declare double @llvm.tan.f64(double) [[READNONE_INTRINSIC]]
666+
// NO__ERRNO: declare float @llvm.tan.f32(float) [[READNONE_INTRINSIC]]
667+
// NO__ERRNO: declare x86_fp80 @llvm.tan.f80(x86_fp80) [[READNONE_INTRINSIC]]
668668
// HAS_ERRNO: declare double @tan(double noundef) [[NOT_READNONE]]
669669
// HAS_ERRNO: declare float @tanf(float noundef) [[NOT_READNONE]]
670670
// HAS_ERRNO: declare x86_fp80 @tanl(x86_fp80 noundef) [[NOT_READNONE]]
671-
// HAS_MAYTRAP: declare double @tan(double noundef) [[NOT_READNONE]]
672-
// HAS_MAYTRAP: declare float @tanf(float noundef) [[NOT_READNONE]]
673-
// HAS_MAYTRAP: declare x86_fp80 @tanl(x86_fp80 noundef) [[NOT_READNONE]]
671+
// HAS_MAYTRAP: declare double @llvm.experimental.constrained.tan.f64(
672+
// HAS_MAYTRAP: declare float @llvm.experimental.constrained.tan.f32(
673+
// HAS_MAYTRAP: declare x86_fp80 @llvm.experimental.constrained.tan.f80(
674674

675675
tanh(f); tanhf(f); tanhl(f);
676676

clang/test/CodeGenOpenCL/builtins-f16.cl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ void test_half_builtins(half h0, half h1, half h2, int i0) {
6666
// CHECK: call half @llvm.sqrt.f16(half %h0)
6767
res = __builtin_sqrtf16(h0);
6868

69+
// CHECK: call half @llvm.tan.f16(half %h0)
70+
res = __builtin_tanf16(h0);
71+
6972
// CHECK: call half @llvm.trunc.f16(half %h0)
7073
res = __builtin_truncf16(h0);
7174

llvm/docs/LangRef.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26244,6 +26244,42 @@ same values as the libm ``cos`` functions would, and handles error
2624426244
conditions in the same way.
2624526245

2624626246

26247+
'``llvm.experimental.constrained.tan``' Intrinsic
26248+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26249+
26250+
Syntax:
26251+
"""""""
26252+
26253+
::
26254+
26255+
declare <type>
26256+
@llvm.experimental.constrained.tan(<type> <op1>,
26257+
metadata <rounding mode>,
26258+
metadata <exception behavior>)
26259+
26260+
Overview:
26261+
"""""""""
26262+
26263+
The '``llvm.experimental.constrained.tan``' intrinsic returns the tangent of the
26264+
first operand.
26265+
26266+
Arguments:
26267+
""""""""""
26268+
26269+
The first argument and the return type are floating-point numbers of the same
26270+
type.
26271+
26272+
The second and third arguments specify the rounding mode and exception
26273+
behavior as described above.
26274+
26275+
Semantics:
26276+
""""""""""
26277+
26278+
This function returns the tangent of the specified operand, returning the
26279+
same values as the libm ``tan`` functions would, and handles error
26280+
conditions in the same way.
26281+
26282+
2624726283
'``llvm.experimental.constrained.exp``' Intrinsic
2624826284
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2624926285

llvm/include/llvm/IR/ConstrainedOps.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ DAG_FUNCTION(round, 1, 0, experimental_constrained_round, FROUND)
9595
DAG_FUNCTION(roundeven, 1, 0, experimental_constrained_roundeven, FROUNDEVEN)
9696
DAG_FUNCTION(sin, 1, 1, experimental_constrained_sin, FSIN)
9797
DAG_FUNCTION(sqrt, 1, 1, experimental_constrained_sqrt, FSQRT)
98+
DAG_FUNCTION(tan, 1, 1, experimental_constrained_tan, FTAN)
9899
DAG_FUNCTION(trunc, 1, 0, experimental_constrained_trunc, FTRUNC)
99100

100101
// This is definition for fmuladd intrinsic function, that is converted into

llvm/include/llvm/IR/Intrinsics.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,10 @@ let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn, IntrStrictFP] in
12181218
[ LLVMMatchType<0>,
12191219
llvm_metadata_ty,
12201220
llvm_metadata_ty ]>;
1221+
def int_experimental_constrained_tan : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1222+
[ LLVMMatchType<0>,
1223+
llvm_metadata_ty,
1224+
llvm_metadata_ty ]>;
12211225
def int_experimental_constrained_pow : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
12221226
[ LLVMMatchType<0>,
12231227
LLVMMatchType<0>,

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -728,14 +728,14 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
728728
setOperationAction(ISD::FCOPYSIGN, MVT::bf16, Promote);
729729
}
730730

731-
for (auto Op : {ISD::FREM, ISD::FPOW, ISD::FPOWI,
732-
ISD::FCOS, ISD::FSIN, ISD::FSINCOS,
733-
ISD::FTAN, ISD::FEXP, ISD::FEXP2,
734-
ISD::FEXP10, ISD::FLOG, ISD::FLOG2,
735-
ISD::FLOG10, ISD::STRICT_FREM, ISD::STRICT_FPOW,
736-
ISD::STRICT_FPOWI, ISD::STRICT_FCOS, ISD::STRICT_FSIN,
737-
ISD::STRICT_FEXP, ISD::STRICT_FEXP2, ISD::STRICT_FLOG,
738-
ISD::STRICT_FLOG2, ISD::STRICT_FLOG10}) {
731+
for (auto Op : {ISD::FREM, ISD::FPOW, ISD::FPOWI,
732+
ISD::FCOS, ISD::FSIN, ISD::FSINCOS,
733+
ISD::FTAN, ISD::FEXP, ISD::FEXP2,
734+
ISD::FEXP10, ISD::FLOG, ISD::FLOG2,
735+
ISD::FLOG10, ISD::STRICT_FREM, ISD::STRICT_FPOW,
736+
ISD::STRICT_FPOWI, ISD::STRICT_FCOS, ISD::STRICT_FSIN,
737+
ISD::STRICT_FEXP, ISD::STRICT_FEXP2, ISD::STRICT_FLOG,
738+
ISD::STRICT_FLOG2, ISD::STRICT_FLOG10, ISD::STRICT_FTAN}) {
739739
setOperationAction(Op, MVT::f16, Promote);
740740
setOperationAction(Op, MVT::v4f16, Expand);
741741
setOperationAction(Op, MVT::v8f16, Expand);

llvm/test/Assembler/fp-intrinsics-attr.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ define void @func(double %a, double %b, double %c, i32 %i) strictfp {
8585
metadata !"round.dynamic",
8686
metadata !"fpexcept.strict")
8787

88+
%tan = call double @llvm.experimental.constrained.tan.f64(
89+
double %a,
90+
metadata !"round.dynamic",
91+
metadata !"fpexcept.strict")
92+
8893
%pow = call double @llvm.experimental.constrained.pow.f64(
8994
double %a, double %b,
9095
metadata !"round.dynamic",
@@ -244,6 +249,9 @@ declare double @llvm.experimental.constrained.sin.f64(double, metadata, metadata
244249
declare double @llvm.experimental.constrained.cos.f64(double, metadata, metadata)
245250
; CHECK: @llvm.experimental.constrained.cos.f64({{.*}}) #[[ATTR1]]
246251

252+
declare double @llvm.experimental.constrained.tan.f64(double, metadata, metadata)
253+
; CHECK: @llvm.experimental.constrained.tan.f64({{.*}}) #[[ATTR1]]
254+
247255
declare double @llvm.experimental.constrained.pow.f64(double, double, metadata, metadata)
248256
; CHECK: @llvm.experimental.constrained.pow.f64({{.*}}) #[[ATTR1]]
249257

llvm/test/CodeGen/AArch64/fp-intrinsics-fp16.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,21 @@ define half @cos_f16(half %x) #0 {
338338
ret half %val
339339
}
340340

341+
define half @tan_f16(half %x) #0 {
342+
; CHECK-LABEL: tan_f16:
343+
; CHECK: // %bb.0:
344+
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
345+
; CHECK-NEXT: .cfi_def_cfa_offset 16
346+
; CHECK-NEXT: .cfi_offset w30, -16
347+
; CHECK-NEXT: fcvt s0, h0
348+
; CHECK-NEXT: bl tanf
349+
; CHECK-NEXT: fcvt h0, s0
350+
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
351+
; CHECK-NEXT: ret
352+
%val = call half @llvm.experimental.constrained.tan.f16(half %x, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
353+
ret half %val
354+
}
355+
341356
define half @pow_f16(half %x, half %y) #0 {
342357
; CHECK-LABEL: pow_f16:
343358
; CHECK: // %bb.0:
@@ -1147,6 +1162,7 @@ declare half @llvm.experimental.constrained.sqrt.f16(half, metadata, metadata)
11471162
declare half @llvm.experimental.constrained.powi.f16(half, i32, metadata, metadata)
11481163
declare half @llvm.experimental.constrained.sin.f16(half, metadata, metadata)
11491164
declare half @llvm.experimental.constrained.cos.f16(half, metadata, metadata)
1165+
declare half @llvm.experimental.constrained.tan.f16(half, metadata, metadata)
11501166
declare half @llvm.experimental.constrained.pow.f16(half, half, metadata, metadata)
11511167
declare half @llvm.experimental.constrained.log.f16(half, metadata, metadata)
11521168
declare half @llvm.experimental.constrained.log10.f16(half, metadata, metadata)

llvm/test/CodeGen/AArch64/fp-intrinsics.ll

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ define float @cos_f32(float %x) #0 {
146146
ret float %val
147147
}
148148

149+
; CHECK-LABEL: tan_f32:
150+
; CHECK: bl tanf
151+
define float @tan_f32(float %x) #0 {
152+
%val = call float @llvm.experimental.constrained.tan.f32(float %x, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
153+
ret float %val
154+
}
155+
149156
; CHECK-LABEL: pow_f32:
150157
; CHECK: bl powf
151158
define float @pow_f32(float %x, float %y) #0 {
@@ -630,6 +637,13 @@ define double @cos_f64(double %x) #0 {
630637
ret double %val
631638
}
632639

640+
; CHECK-LABEL: tan_f64:
641+
; CHECK: bl tan
642+
define double @tan_f64(double %x) #0 {
643+
%val = call double @llvm.experimental.constrained.tan.f64(double %x, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
644+
ret double %val
645+
}
646+
633647
; CHECK-LABEL: pow_f64:
634648
; CHECK: bl pow
635649
define double @pow_f64(double %x, double %y) #0 {
@@ -1114,6 +1128,13 @@ define fp128 @cos_f128(fp128 %x) #0 {
11141128
ret fp128 %val
11151129
}
11161130

1131+
; CHECK-LABEL: tan_f128:
1132+
; CHECK: bl tanl
1133+
define fp128 @tan_f128(fp128 %x) #0 {
1134+
%val = call fp128 @llvm.experimental.constrained.tan.f128(fp128 %x, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
1135+
ret fp128 %val
1136+
}
1137+
11171138
; CHECK-LABEL: pow_f128:
11181139
; CHECK: bl powl
11191140
define fp128 @pow_f128(fp128 %x, fp128 %y) #0 {
@@ -1491,6 +1512,13 @@ define <1 x double> @cos_v1f64(<1 x double> %x, <1 x double> %y) #0 {
14911512
ret <1 x double> %val
14921513
}
14931514

1515+
; CHECK-LABEL: tan_v1f64:
1516+
; CHECK: bl tan
1517+
define <1 x double> @tan_v1f64(<1 x double> %x, <1 x double> %y) #0 {
1518+
%val = call <1 x double> @llvm.experimental.constrained.tan.v1f64(<1 x double> %x, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
1519+
ret <1 x double> %val
1520+
}
1521+
14941522
; CHECK-LABEL: pow_v1f64:
14951523
; CHECK: bl pow
14961524
define <1 x double> @pow_v1f64(<1 x double> %x, <1 x double> %y) #0 {
@@ -1555,6 +1583,7 @@ declare float @llvm.experimental.constrained.sqrt.f32(float, metadata, metadata)
15551583
declare float @llvm.experimental.constrained.powi.f32(float, i32, metadata, metadata)
15561584
declare float @llvm.experimental.constrained.sin.f32(float, metadata, metadata)
15571585
declare float @llvm.experimental.constrained.cos.f32(float, metadata, metadata)
1586+
declare float @llvm.experimental.constrained.tan.f32(float, metadata, metadata)
15581587
declare float @llvm.experimental.constrained.pow.f32(float, float, metadata, metadata)
15591588
declare float @llvm.experimental.constrained.log.f32(float, metadata, metadata)
15601589
declare float @llvm.experimental.constrained.log10.f32(float, metadata, metadata)
@@ -1599,6 +1628,7 @@ declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadat
15991628
declare double @llvm.experimental.constrained.powi.f64(double, i32, metadata, metadata)
16001629
declare double @llvm.experimental.constrained.sin.f64(double, metadata, metadata)
16011630
declare double @llvm.experimental.constrained.cos.f64(double, metadata, metadata)
1631+
declare double @llvm.experimental.constrained.tan.f64(double, metadata, metadata)
16021632
declare double @llvm.experimental.constrained.pow.f64(double, double, metadata, metadata)
16031633
declare double @llvm.experimental.constrained.log.f64(double, metadata, metadata)
16041634
declare double @llvm.experimental.constrained.log10.f64(double, metadata, metadata)
@@ -1643,6 +1673,7 @@ declare fp128 @llvm.experimental.constrained.sqrt.f128(fp128, metadata, metadata
16431673
declare fp128 @llvm.experimental.constrained.powi.f128(fp128, i32, metadata, metadata)
16441674
declare fp128 @llvm.experimental.constrained.sin.f128(fp128, metadata, metadata)
16451675
declare fp128 @llvm.experimental.constrained.cos.f128(fp128, metadata, metadata)
1676+
declare fp128 @llvm.experimental.constrained.tan.f128(fp128, metadata, metadata)
16461677
declare fp128 @llvm.experimental.constrained.pow.f128(fp128, fp128, metadata, metadata)
16471678
declare fp128 @llvm.experimental.constrained.log.f128(fp128, metadata, metadata)
16481679
declare fp128 @llvm.experimental.constrained.log10.f128(fp128, metadata, metadata)

llvm/test/CodeGen/ARM/fp-intrinsics.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ define float @cos_f32(float %x) #0 {
139139
ret float %val
140140
}
141141

142+
; CHECK-LABEL: tan_f32:
143+
; CHECK: bl tanf
144+
define float @tan_f32(float %x) #0 {
145+
%val = call float @llvm.experimental.constrained.tan.f32(float %x, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
146+
ret float %val
147+
}
148+
142149
; CHECK-LABEL: pow_f32:
143150
; CHECK: bl powf
144151
define float @pow_f32(float %x, float %y) #0 {
@@ -596,6 +603,13 @@ define double @cos_f64(double %x) #0 {
596603
ret double %val
597604
}
598605

606+
; CHECK-LABEL: tan_f64:
607+
; CHECK: bl tan
608+
define double @tan_f64(double %x) #0 {
609+
%val = call double @llvm.experimental.constrained.tan.f64(double %x, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
610+
ret double %val
611+
}
612+
599613
; CHECK-LABEL: pow_f64:
600614
; CHECK: bl pow
601615
define double @pow_f64(double %x, double %y) #0 {
@@ -1023,6 +1037,7 @@ declare float @llvm.experimental.constrained.sqrt.f32(float, metadata, metadata)
10231037
declare float @llvm.experimental.constrained.powi.f32(float, i32, metadata, metadata)
10241038
declare float @llvm.experimental.constrained.sin.f32(float, metadata, metadata)
10251039
declare float @llvm.experimental.constrained.cos.f32(float, metadata, metadata)
1040+
declare float @llvm.experimental.constrained.tan.f32(float, metadata, metadata)
10261041
declare float @llvm.experimental.constrained.pow.f32(float, float, metadata, metadata)
10271042
declare float @llvm.experimental.constrained.log.f32(float, metadata, metadata)
10281043
declare float @llvm.experimental.constrained.log10.f32(float, metadata, metadata)
@@ -1056,6 +1071,7 @@ declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadat
10561071
declare double @llvm.experimental.constrained.powi.f64(double, i32, metadata, metadata)
10571072
declare double @llvm.experimental.constrained.sin.f64(double, metadata, metadata)
10581073
declare double @llvm.experimental.constrained.cos.f64(double, metadata, metadata)
1074+
declare double @llvm.experimental.constrained.tan.f64(double, metadata, metadata)
10591075
declare double @llvm.experimental.constrained.pow.f64(double, double, metadata, metadata)
10601076
declare double @llvm.experimental.constrained.log.f64(double, metadata, metadata)
10611077
declare double @llvm.experimental.constrained.log10.f64(double, metadata, metadata)

0 commit comments

Comments
 (0)