Skip to content

Commit a14baec

Browse files
authored
[clang] Emit constraint intrinsics for arc and hyperbolic trig clang builtins (#98949)
## Change(s) - `Builtins.td` - Add f16 support for libm arc and hyperbolic trig functions - `CGBuiltin.cpp` - Emit constraint intrinsics for trig clang builtins ## History This change is part of an implementation of #87367 investigation on supporting IEEE math operations as intrinsics. Which was discussed in this RFC: https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294 This change adds wasm lowering cases for `acos`, `asin`, `atan`, `cosh`, `sinh`, and `tanh`. #70079 #70080 #70081 #70083 #70084 #95966 ## Precursor PR(s) Note this PR needs Merge after: - #98937 - #98755
1 parent def3944 commit a14baec

File tree

7 files changed

+208
-82
lines changed

7 files changed

+208
-82
lines changed

clang/include/clang/Basic/Builtins.td

+18-18
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ class BitInt_Long_LongLongTemplate :
8383
// - _Constant: Argument has to constant-fold to an integer constant expression
8484

8585
// __fp16 and __float128 builtin variants of libc/libm functions.
86-
def AcosF128 : Builtin {
87-
let Spellings = ["__builtin_acosf128"];
86+
def AcosF16F128 : Builtin, F16F128MathTemplate {
87+
let Spellings = ["__builtin_acos"];
8888
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
8989
ConstIgnoringErrnoAndExceptions];
90-
let Prototype = "__float128(__float128)";
90+
let Prototype = "T(T)";
9191
}
9292

9393
def AcoshF128 : Builtin {
@@ -97,11 +97,11 @@ def AcoshF128 : Builtin {
9797
let Prototype = "__float128(__float128)";
9898
}
9999

100-
def AsinF128 : Builtin {
101-
let Spellings = ["__builtin_asinf128"];
100+
def AsinF16F128 : Builtin, F16F128MathTemplate {
101+
let Spellings = ["__builtin_asin"];
102102
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
103103
ConstIgnoringErrnoAndExceptions];
104-
let Prototype = "__float128(__float128)";
104+
let Prototype = "T(T)";
105105
}
106106

107107
def AsinhF128 : Builtin {
@@ -111,11 +111,11 @@ def AsinhF128 : Builtin {
111111
let Prototype = "__float128(__float128)";
112112
}
113113

114-
def AtanF128 : Builtin {
115-
let Spellings = ["__builtin_atanf128"];
114+
def AtanF16F128 : Builtin, F16F128MathTemplate {
115+
let Spellings = ["__builtin_atan"];
116116
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
117117
ConstIgnoringErrnoAndExceptions];
118-
let Prototype = "__float128(__float128)";
118+
let Prototype = "T(T)";
119119
}
120120

121121
def AtanhF128 : Builtin {
@@ -143,10 +143,10 @@ def CosF16F128 : Builtin, F16F128MathTemplate {
143143
let Prototype = "T(T)";
144144
}
145145

146-
def CoshF128 : Builtin {
147-
let Spellings = ["__builtin_coshf128"];
146+
def CoshF16F128 : Builtin, F16F128MathTemplate {
147+
let Spellings = ["__builtin_cosh"];
148148
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
149-
let Prototype = "__float128(__float128)";
149+
let Prototype = "T(T)";
150150
}
151151

152152
def ErfF128 : Builtin {
@@ -468,11 +468,11 @@ def SinF16F128 : Builtin, F16F128MathTemplate {
468468
let Prototype = "T(T)";
469469
}
470470

471-
def SinhF128 : Builtin {
472-
let Spellings = ["__builtin_sinhf128"];
471+
def SinhF16F128 : Builtin, F16F128MathTemplate {
472+
let Spellings = ["__builtin_sinh"];
473473
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
474474
ConstIgnoringErrnoAndExceptions];
475-
let Prototype = "__float128(__float128)";
475+
let Prototype = "T(T)";
476476
}
477477

478478
def SqrtF16F128 : Builtin, F16F128MathTemplate {
@@ -489,11 +489,11 @@ def TanF16F128 : Builtin, F16F128MathTemplate {
489489
let Prototype = "T(T)";
490490
}
491491

492-
def TanhF128 : Builtin {
493-
let Spellings = ["__builtin_tanhf128"];
492+
def TanhF16F128 : Builtin, F16F128MathTemplate {
493+
let Spellings = ["__builtin_tanh"];
494494
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
495495
ConstIgnoringErrnoAndExceptions];
496-
let Prototype = "__float128(__float128)";
496+
let Prototype = "T(T)";
497497
}
498498

499499
def TgammaF128 : Builtin {

clang/lib/CodeGen/CGBuiltin.cpp

+66
Original file line numberDiff line numberDiff line change
@@ -2667,6 +2667,39 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
26672667
}
26682668
if (GenerateIntrinsics) {
26692669
switch (BuiltinIDIfNoAsmLabel) {
2670+
case Builtin::BIacos:
2671+
case Builtin::BIacosf:
2672+
case Builtin::BIacosl:
2673+
case Builtin::BI__builtin_acos:
2674+
case Builtin::BI__builtin_acosf:
2675+
case Builtin::BI__builtin_acosf16:
2676+
case Builtin::BI__builtin_acosl:
2677+
case Builtin::BI__builtin_acosf128:
2678+
return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(
2679+
*this, E, Intrinsic::acos, Intrinsic::experimental_constrained_acos));
2680+
2681+
case Builtin::BIasin:
2682+
case Builtin::BIasinf:
2683+
case Builtin::BIasinl:
2684+
case Builtin::BI__builtin_asin:
2685+
case Builtin::BI__builtin_asinf:
2686+
case Builtin::BI__builtin_asinf16:
2687+
case Builtin::BI__builtin_asinl:
2688+
case Builtin::BI__builtin_asinf128:
2689+
return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(
2690+
*this, E, Intrinsic::asin, Intrinsic::experimental_constrained_asin));
2691+
2692+
case Builtin::BIatan:
2693+
case Builtin::BIatanf:
2694+
case Builtin::BIatanl:
2695+
case Builtin::BI__builtin_atan:
2696+
case Builtin::BI__builtin_atanf:
2697+
case Builtin::BI__builtin_atanf16:
2698+
case Builtin::BI__builtin_atanl:
2699+
case Builtin::BI__builtin_atanf128:
2700+
return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(
2701+
*this, E, Intrinsic::atan, Intrinsic::experimental_constrained_atan));
2702+
26702703
case Builtin::BIceil:
26712704
case Builtin::BIceilf:
26722705
case Builtin::BIceill:
@@ -2702,6 +2735,17 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
27022735
Intrinsic::cos,
27032736
Intrinsic::experimental_constrained_cos));
27042737

2738+
case Builtin::BIcosh:
2739+
case Builtin::BIcoshf:
2740+
case Builtin::BIcoshl:
2741+
case Builtin::BI__builtin_cosh:
2742+
case Builtin::BI__builtin_coshf:
2743+
case Builtin::BI__builtin_coshf16:
2744+
case Builtin::BI__builtin_coshl:
2745+
case Builtin::BI__builtin_coshf128:
2746+
return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(
2747+
*this, E, Intrinsic::cosh, Intrinsic::experimental_constrained_cosh));
2748+
27052749
case Builtin::BIexp:
27062750
case Builtin::BIexpf:
27072751
case Builtin::BIexpl:
@@ -2918,6 +2962,17 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
29182962
Intrinsic::sin,
29192963
Intrinsic::experimental_constrained_sin));
29202964

2965+
case Builtin::BIsinh:
2966+
case Builtin::BIsinhf:
2967+
case Builtin::BIsinhl:
2968+
case Builtin::BI__builtin_sinh:
2969+
case Builtin::BI__builtin_sinhf:
2970+
case Builtin::BI__builtin_sinhf16:
2971+
case Builtin::BI__builtin_sinhl:
2972+
case Builtin::BI__builtin_sinhf128:
2973+
return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(
2974+
*this, E, Intrinsic::sinh, Intrinsic::experimental_constrained_sinh));
2975+
29212976
case Builtin::BIsqrt:
29222977
case Builtin::BIsqrtf:
29232978
case Builtin::BIsqrtl:
@@ -2944,6 +2999,17 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
29442999
return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(
29453000
*this, E, Intrinsic::tan, Intrinsic::experimental_constrained_tan));
29463001

3002+
case Builtin::BItanh:
3003+
case Builtin::BItanhf:
3004+
case Builtin::BItanhl:
3005+
case Builtin::BI__builtin_tanh:
3006+
case Builtin::BI__builtin_tanhf:
3007+
case Builtin::BI__builtin_tanhf16:
3008+
case Builtin::BI__builtin_tanhl:
3009+
case Builtin::BI__builtin_tanhf128:
3010+
return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(
3011+
*this, E, Intrinsic::tanh, Intrinsic::experimental_constrained_tanh));
3012+
29473013
case Builtin::BItrunc:
29483014
case Builtin::BItruncf:
29493015
case Builtin::BItruncl:

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

+24-24
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
168168
/* math */
169169
__builtin_acos(f); __builtin_acosf(f); __builtin_acosl(f); __builtin_acosf128(f);
170170

171-
// NO__ERRNO: declare double @acos(double noundef) [[READNONE]]
172-
// NO__ERRNO: declare float @acosf(float noundef) [[READNONE]]
173-
// NO__ERRNO: declare x86_fp80 @acosl(x86_fp80 noundef) [[READNONE]]
174-
// NO__ERRNO: declare fp128 @acosf128(fp128 noundef) [[READNONE]]
171+
// NO__ERRNO: declare double @llvm.acos.f64(double) [[READNONE_INTRINSIC]]
172+
// NO__ERRNO: declare float @llvm.acos.f32(float) [[READNONE_INTRINSIC]]
173+
// NO__ERRNO: declare x86_fp80 @llvm.acos.f80(x86_fp80) [[READNONE_INTRINSIC]]
174+
// NO__ERRNO: declare fp128 @llvm.acos.f128(fp128) [[READNONE_INTRINSIC]]
175175
// HAS_ERRNO: declare double @acos(double noundef) [[NOT_READNONE]]
176176
// HAS_ERRNO: declare float @acosf(float noundef) [[NOT_READNONE]]
177177
// HAS_ERRNO: declare x86_fp80 @acosl(x86_fp80 noundef) [[NOT_READNONE]]
@@ -190,10 +190,10 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
190190

191191
__builtin_asin(f); __builtin_asinf(f); __builtin_asinl(f); __builtin_asinf128(f);
192192

193-
// NO__ERRNO: declare double @asin(double noundef) [[READNONE]]
194-
// NO__ERRNO: declare float @asinf(float noundef) [[READNONE]]
195-
// NO__ERRNO: declare x86_fp80 @asinl(x86_fp80 noundef) [[READNONE]]
196-
// NO__ERRNO: declare fp128 @asinf128(fp128 noundef) [[READNONE]]
193+
// NO__ERRNO: declare double @llvm.asin.f64(double) [[READNONE_INTRINSIC]]
194+
// NO__ERRNO: declare float @llvm.asin.f32(float) [[READNONE_INTRINSIC]]
195+
// NO__ERRNO: declare x86_fp80 @llvm.asin.f80(x86_fp80) [[READNONE_INTRINSIC]]
196+
// NO__ERRNO: declare fp128 @llvm.asin.f128(fp128) [[READNONE_INTRINSIC]]
197197
// HAS_ERRNO: declare double @asin(double noundef) [[NOT_READNONE]]
198198
// HAS_ERRNO: declare float @asinf(float noundef) [[NOT_READNONE]]
199199
// HAS_ERRNO: declare x86_fp80 @asinl(x86_fp80 noundef) [[NOT_READNONE]]
@@ -212,10 +212,10 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
212212

213213
__builtin_atan(f); __builtin_atanf(f); __builtin_atanl(f); __builtin_atanf128(f);
214214

215-
// NO__ERRNO: declare double @atan(double noundef) [[READNONE]]
216-
// NO__ERRNO: declare float @atanf(float noundef) [[READNONE]]
217-
// NO__ERRNO: declare x86_fp80 @atanl(x86_fp80 noundef) [[READNONE]]
218-
// NO__ERRNO: declare fp128 @atanf128(fp128 noundef) [[READNONE]]
215+
// NO__ERRNO: declare double @llvm.atan.f64(double) [[READNONE_INTRINSIC]]
216+
// NO__ERRNO: declare float @llvm.atan.f32(float) [[READNONE_INTRINSIC]]
217+
// NO__ERRNO: declare x86_fp80 @llvm.atan.f80(x86_fp80) [[READNONE_INTRINSIC]]
218+
// NO__ERRNO: declare fp128 @llvm.atan.f128(fp128) [[READNONE_INTRINSIC]]
219219
// HAS_ERRNO: declare double @atan(double noundef) [[NOT_READNONE]]
220220
// HAS_ERRNO: declare float @atanf(float noundef) [[NOT_READNONE]]
221221
// HAS_ERRNO: declare x86_fp80 @atanl(x86_fp80 noundef) [[NOT_READNONE]]
@@ -267,10 +267,10 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
267267

268268
__builtin_cosh(f); __builtin_coshf(f); __builtin_coshl(f); __builtin_coshf128(f);
269269

270-
// NO__ERRNO: declare double @cosh(double noundef) [[READNONE]]
271-
// NO__ERRNO: declare float @coshf(float noundef) [[READNONE]]
272-
// NO__ERRNO: declare x86_fp80 @coshl(x86_fp80 noundef) [[READNONE]]
273-
// NO__ERRNO: declare fp128 @coshf128(fp128 noundef) [[READNONE]]
270+
// NO__ERRNO: declare double @llvm.cosh.f64(double) [[READNONE_INTRINSIC]]
271+
// NO__ERRNO: declare float @llvm.cosh.f32(float) [[READNONE_INTRINSIC]]
272+
// NO__ERRNO: declare x86_fp80 @llvm.cosh.f80(x86_fp80) [[READNONE_INTRINSIC]]
273+
// NO__ERRNO: declare fp128 @llvm.cosh.f128(fp128) [[READNONE_INTRINSIC]]
274274
// HAS_ERRNO: declare double @cosh(double noundef) [[NOT_READNONE]]
275275
// HAS_ERRNO: declare float @coshf(float noundef) [[NOT_READNONE]]
276276
// HAS_ERRNO: declare x86_fp80 @coshl(x86_fp80 noundef) [[NOT_READNONE]]
@@ -656,10 +656,10 @@ __builtin_sin(f); __builtin_sinf(f); __builtin_sinl(f); __builtin_s
656656

657657
__builtin_sinh(f); __builtin_sinhf(f); __builtin_sinhl(f); __builtin_sinhf128(f);
658658

659-
// NO__ERRNO: declare double @sinh(double noundef) [[READNONE]]
660-
// NO__ERRNO: declare float @sinhf(float noundef) [[READNONE]]
661-
// NO__ERRNO: declare x86_fp80 @sinhl(x86_fp80 noundef) [[READNONE]]
662-
// NO__ERRNO: declare fp128 @sinhf128(fp128 noundef) [[READNONE]]
659+
// NO__ERRNO: declare double @llvm.sinh.f64(double) [[READNONE_INTRINSIC]]
660+
// NO__ERRNO: declare float @llvm.sinh.f32(float) [[READNONE_INTRINSIC]]
661+
// NO__ERRNO: declare x86_fp80 @llvm.sinh.f80(x86_fp80) [[READNONE_INTRINSIC]]
662+
// NO__ERRNO: declare fp128 @llvm.sinh.f128(fp128) [[READNONE_INTRINSIC]]
663663
// HAS_ERRNO: declare double @sinh(double noundef) [[NOT_READNONE]]
664664
// HAS_ERRNO: declare float @sinhf(float noundef) [[NOT_READNONE]]
665665
// HAS_ERRNO: declare x86_fp80 @sinhl(x86_fp80 noundef) [[NOT_READNONE]]
@@ -689,10 +689,10 @@ __builtin_tan(f); __builtin_tanf(f); __builtin_tanl(f); __builtin_t
689689

690690
__builtin_tanh(f); __builtin_tanhf(f); __builtin_tanhl(f); __builtin_tanhf128(f);
691691

692-
// NO__ERRNO: declare double @tanh(double noundef) [[READNONE]]
693-
// NO__ERRNO: declare float @tanhf(float noundef) [[READNONE]]
694-
// NO__ERRNO: declare x86_fp80 @tanhl(x86_fp80 noundef) [[READNONE]]
695-
// NO__ERRNO: declare fp128 @tanhf128(fp128 noundef) [[READNONE]]
692+
// NO__ERRNO: declare double @llvm.tanh.f64(double) [[READNONE_INTRINSIC]]
693+
// NO__ERRNO: declare float @llvm.tanh.f32(float) [[READNONE_INTRINSIC]]
694+
// NO__ERRNO: declare x86_fp80 @llvm.tanh.f80(x86_fp80) [[READNONE_INTRINSIC]]
695+
// NO__ERRNO: declare fp128 @llvm.tanh.f128(fp128) [[READNONE_INTRINSIC]]
696696
// HAS_ERRNO: declare double @tanh(double noundef) [[NOT_READNONE]]
697697
// HAS_ERRNO: declare float @tanhf(float noundef) [[NOT_READNONE]]
698698
// HAS_ERRNO: declare x86_fp80 @tanhl(x86_fp80 noundef) [[NOT_READNONE]]

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

+41
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c, _
3636
// CHECK: call float @llvm.experimental.constrained.ldexp.f32.i32(float %{{.*}}, i32 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
3737
// CHECK: call x86_fp80 @llvm.experimental.constrained.ldexp.f80.i32(x86_fp80 %{{.*}}, i32 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
3838

39+
__builtin_acos(f); __builtin_acosf(f); __builtin_acosl(f); __builtin_acosf128(f);
40+
41+
// CHECK: call double @llvm.experimental.constrained.acos.f64(double %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
42+
// CHECK: call float @llvm.experimental.constrained.acos.f32(float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
43+
// CHECK: call x86_fp80 @llvm.experimental.constrained.acos.f80(x86_fp80 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
44+
// CHECK: call fp128 @llvm.experimental.constrained.acos.f128(fp128 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
45+
46+
__builtin_asin(f); __builtin_asinf(f); __builtin_asinl(f); __builtin_asinf128(f);
47+
48+
// CHECK: call double @llvm.experimental.constrained.asin.f64(double %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
49+
// CHECK: call float @llvm.experimental.constrained.asin.f32(float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
50+
// CHECK: call x86_fp80 @llvm.experimental.constrained.asin.f80(x86_fp80 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
51+
// CHECK: call fp128 @llvm.experimental.constrained.asin.f128(fp128 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
52+
53+
__builtin_atan(f); __builtin_atanf(f); __builtin_atanl(f); __builtin_atanf128(f);
54+
55+
// CHECK: call double @llvm.experimental.constrained.atan.f64(double %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
56+
// CHECK: call float @llvm.experimental.constrained.atan.f32(float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
57+
// CHECK: call x86_fp80 @llvm.experimental.constrained.atan.f80(x86_fp80 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
58+
// CHECK: call fp128 @llvm.experimental.constrained.atan.f128(fp128 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
59+
3960
__builtin_ceil(f); __builtin_ceilf(f); __builtin_ceill(f); __builtin_ceilf128(f);
4061

4162
// CHECK: call double @llvm.experimental.constrained.ceil.f64(double %{{.*}}, metadata !"fpexcept.strict")
@@ -50,6 +71,13 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c, _
5071
// CHECK: call x86_fp80 @llvm.experimental.constrained.cos.f80(x86_fp80 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
5172
// CHECK: call fp128 @llvm.experimental.constrained.cos.f128(fp128 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
5273

74+
__builtin_cosh(f); __builtin_coshf(f); __builtin_coshl(f); __builtin_coshf128(f);
75+
76+
// CHECK: call double @llvm.experimental.constrained.cosh.f64(double %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
77+
// CHECK: call float @llvm.experimental.constrained.cosh.f32(float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
78+
// CHECK: call x86_fp80 @llvm.experimental.constrained.cosh.f80(x86_fp80 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
79+
// CHECK: call fp128 @llvm.experimental.constrained.cosh.f128(fp128 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
80+
5381
__builtin_exp(f); __builtin_expf(f); __builtin_expl(f); __builtin_expf128(f);
5482

5583
// CHECK: call double @llvm.experimental.constrained.exp.f64(double %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
@@ -177,6 +205,13 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c, _
177205
// CHECK: call x86_fp80 @llvm.experimental.constrained.sin.f80(x86_fp80 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
178206
// CHECK: call fp128 @llvm.experimental.constrained.sin.f128(fp128 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
179207

208+
__builtin_sinh(f); __builtin_sinhf(f); __builtin_sinhl(f); __builtin_sinhf128(f);
209+
210+
// CHECK: call double @llvm.experimental.constrained.sinh.f64(double %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
211+
// CHECK: call float @llvm.experimental.constrained.sinh.f32(float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
212+
// CHECK: call x86_fp80 @llvm.experimental.constrained.sinh.f80(x86_fp80 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
213+
// CHECK: call fp128 @llvm.experimental.constrained.sinh.f128(fp128 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
214+
180215
__builtin_sqrt(f); __builtin_sqrtf(f); __builtin_sqrtl(f); __builtin_sqrtf128(f);
181216

182217
// CHECK: call double @llvm.experimental.constrained.sqrt.f64(double %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
@@ -191,6 +226,12 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c, _
191226
// CHECK: call x86_fp80 @llvm.experimental.constrained.tan.f80(x86_fp80 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
192227
// CHECK: call fp128 @llvm.experimental.constrained.tan.f128(fp128 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
193228

229+
__builtin_tanh(f); __builtin_tanhf(f); __builtin_tanhl(f); __builtin_tanhf128(f);
230+
231+
// CHECK: call double @llvm.experimental.constrained.tanh.f64(double %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
232+
// CHECK: call float @llvm.experimental.constrained.tanh.f32(float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
233+
// CHECK: call x86_fp80 @llvm.experimental.constrained.tanh.f80(x86_fp80 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
234+
// CHECK: call fp128 @llvm.experimental.constrained.tanh.f128(fp128 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
194235

195236
__builtin_trunc(f); __builtin_truncf(f); __builtin_truncl(f); __builtin_truncf128(f);
196237

clang/test/CodeGen/libcalls.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,17 @@ void test_builtins(double d, float f, long double ld) {
8585
double atan_ = atan(d);
8686
long double atanl_ = atanl(ld);
8787
float atanf_ = atanf(f);
88-
// CHECK-NO: declare double @atan(double noundef) [[NUW_RN:#[0-9]+]]
89-
// CHECK-NO: declare x86_fp80 @atanl(x86_fp80 noundef) [[NUW_RN]]
90-
// CHECK-NO: declare float @atanf(float noundef) [[NUW_RN]]
88+
// CHECK-NO: declare double @llvm.atan.f64(double) [[NUW_RNI:#[0-9]+]]
89+
// CHECK-NO: declare x86_fp80 @llvm.atan.f80(x86_fp80) [[NUW_RNI]]
90+
// CHECK-NO: declare float @llvm.atan.f32(float) [[NUW_RNI]]
9191
// CHECK-YES: declare double @atan(double noundef) [[NUW:#[0-9]+]]
9292
// CHECK-YES: declare x86_fp80 @atanl(x86_fp80 noundef) [[NUW]]
9393
// CHECK-YES: declare float @atanf(float noundef) [[NUW]]
9494

9595
double atan2_ = atan2(d, 2);
9696
long double atan2l_ = atan2l(ld, ld);
9797
float atan2f_ = atan2f(f, f);
98-
// CHECK-NO: declare double @atan2(double noundef, double noundef) [[NUW_RN]]
98+
// CHECK-NO: declare double @atan2(double noundef, double noundef) [[NUW_RN:#[0-9]+]]
9999
// CHECK-NO: declare x86_fp80 @atan2l(x86_fp80 noundef, x86_fp80 noundef) [[NUW_RN]]
100100
// CHECK-NO: declare float @atan2f(float noundef, float noundef) [[NUW_RN]]
101101
// CHECK-YES: declare double @atan2(double noundef, double noundef) [[NUW]]

0 commit comments

Comments
 (0)