llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-x86 Author: Farzon Lotfi (farzonl) <details> <summary>Changes</summary> This change is part of this proposal: https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294 This is part 3 of 4 PRs. It sets the ground work for using the intrinsics in HLSL. Add HLSL frontend apis for `acos`, `asin`, `atan`, `cosh`, `sinh`, and `tanh` https://github.com/llvm/llvm-project/issues/70079 https://github.com/llvm/llvm-project/issues/70080 https://github.com/llvm/llvm-project/issues/70081 https://github.com/llvm/llvm-project/issues/70083 https://github.com/llvm/llvm-project/issues/70084 https://github.com/llvm/llvm-project/issues/95966 --- Patch is 57.87 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/95999.diff 19 Files Affected: - (modified) clang/docs/LanguageExtensions.rst (+6) - (modified) clang/include/clang/Basic/Builtins.td (+36) - (modified) clang/lib/CodeGen/CGBuiltin.cpp (+18-1) - (modified) clang/lib/Headers/hlsl/hlsl_intrinsics.h (+173) - (modified) clang/lib/Sema/SemaChecking.cpp (+12) - (modified) clang/test/CodeGen/builtins-elementwise-math.c (+96) - (modified) clang/test/CodeGen/strictfp-elementwise-bulitins.cpp (+60) - (added) clang/test/CodeGenHLSL/builtins/acos.hlsl (+59) - (added) clang/test/CodeGenHLSL/builtins/asin.hlsl (+59) - (added) clang/test/CodeGenHLSL/builtins/atan.hlsl (+59) - (added) clang/test/CodeGenHLSL/builtins/cosh.hlsl (+59) - (added) clang/test/CodeGenHLSL/builtins/sinh.hlsl (+59) - (added) clang/test/CodeGenHLSL/builtins/tanh.hlsl (+59) - (modified) clang/test/Sema/aarch64-sve-vector-trig-ops.c (+35) - (modified) clang/test/Sema/builtins-elementwise-math.c (+126) - (modified) clang/test/Sema/riscv-rvv-vector-trig-ops.c (+36) - (modified) clang/test/SemaCXX/builtins-elementwise-math.cpp (+42) - (modified) clang/test/SemaHLSL/BuiltIns/half-float-only-errors.hlsl (+6) - (modified) llvm/include/llvm/IR/Intrinsics.td (+6) ``````````diff diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 92e6025c95a8c..ec9567782aec0 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -657,6 +657,12 @@ Unless specified otherwise operation(±0) = ±0 and operation(±infinity) = ±in T __builtin_elementwise_sin(T x) return the sine of x interpreted as an angle in radians floating point types T __builtin_elementwise_cos(T x) return the cosine of x interpreted as an angle in radians floating point types T __builtin_elementwise_tan(T x) return the tangent of x interpreted as an angle in radians floating point types + T __builtin_elementwise_asin(T x) return the arcsine of x interpreted as an angle in radians floating point types + T __builtin_elementwise_acos(T x) return the arccosine of x interpreted as an angle in radians floating point types + T __builtin_elementwise_atan(T x) return the arctangent of x interpreted as an angle in radians floating point types + T __builtin_elementwise_sinh(T x) return the hyperbolic sine of angle x in radians floating point types + T __builtin_elementwise_cosh(T x) return the hyperbolic cosine of angle x in radians floating point types + T __builtin_elementwise_tanh(T x) return the hyperbolic tangent of angle x in radians floating point types T __builtin_elementwise_floor(T x) return the largest integral value less than or equal to x floating point types T __builtin_elementwise_log(T x) return the natural logarithm of x floating point types T __builtin_elementwise_log2(T x) return the base 2 logarithm of x floating point types diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index 7bef5fd7ad40f..c9cd76b9b02ac 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -1218,6 +1218,24 @@ def ElementwiseAbs : Builtin { let Prototype = "void(...)"; } +def ElementwiseACos : Builtin { + let Spellings = ["__builtin_elementwise_acos"]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; + let Prototype = "void(...)"; +} + +def ElementwiseASin : Builtin { + let Spellings = ["__builtin_elementwise_asin"]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; + let Prototype = "void(...)"; +} + +def ElementwiseATan : Builtin { + let Spellings = ["__builtin_elementwise_atan"]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; + let Prototype = "void(...)"; +} + def ElementwiseBitreverse : Builtin { let Spellings = ["__builtin_elementwise_bitreverse"]; let Attributes = [NoThrow, Const, CustomTypeChecking]; @@ -1248,6 +1266,12 @@ def ElementwiseCos : Builtin { let Prototype = "void(...)"; } +def ElementwiseCosh : Builtin { + let Spellings = ["__builtin_elementwise_cosh"]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; + let Prototype = "void(...)"; +} + def ElementwiseExp : Builtin { let Spellings = ["__builtin_elementwise_exp"]; let Attributes = [NoThrow, Const, CustomTypeChecking]; @@ -1320,6 +1344,12 @@ def ElementwiseSin : Builtin { let Prototype = "void(...)"; } +def ElementwiseSinh : Builtin { + let Spellings = ["__builtin_elementwise_sinh"]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; + let Prototype = "void(...)"; +} + def ElementwiseSqrt : Builtin { let Spellings = ["__builtin_elementwise_sqrt"]; let Attributes = [NoThrow, Const, CustomTypeChecking]; @@ -1332,6 +1362,12 @@ def ElementwiseTan : Builtin { let Prototype = "void(...)"; } +def ElementwiseTanh : Builtin { + let Spellings = ["__builtin_elementwise_tanh"]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; + let Prototype = "void(...)"; +} + def ElementwiseTrunc : Builtin { let Spellings = ["__builtin_elementwise_trunc"]; let Attributes = [NoThrow, Const, CustomTypeChecking]; diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 08a89bd123d03..7d18c8d3db66b 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -3706,7 +3706,15 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, return RValue::get(Result); } - + case Builtin::BI__builtin_elementwise_acos: + return RValue::get( + emitUnaryBuiltin(*this, E, llvm::Intrinsic::acos, "elt.acos")); + case Builtin::BI__builtin_elementwise_asin: + return RValue::get( + emitUnaryBuiltin(*this, E, llvm::Intrinsic::asin, "elt.asin")); + case Builtin::BI__builtin_elementwise_atan: + return RValue::get( + emitUnaryBuiltin(*this, E, llvm::Intrinsic::atan, "elt.atan")); case Builtin::BI__builtin_elementwise_ceil: return RValue::get( emitUnaryBuiltin(*this, E, llvm::Intrinsic::ceil, "elt.ceil")); @@ -3734,6 +3742,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_elementwise_cos: return RValue::get( emitUnaryBuiltin(*this, E, llvm::Intrinsic::cos, "elt.cos")); + case Builtin::BI__builtin_elementwise_cosh: + return RValue::get( + emitUnaryBuiltin(*this, E, llvm::Intrinsic::cosh, "elt.cosh")); case Builtin::BI__builtin_elementwise_floor: return RValue::get( emitUnaryBuiltin(*this, E, llvm::Intrinsic::floor, "elt.floor")); @@ -3752,9 +3763,15 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_elementwise_sin: return RValue::get( emitUnaryBuiltin(*this, E, llvm::Intrinsic::sin, "elt.sin")); + case Builtin::BI__builtin_elementwise_sinh: + return RValue::get( + emitUnaryBuiltin(*this, E, llvm::Intrinsic::sinh, "elt.sinh")); case Builtin::BI__builtin_elementwise_tan: return RValue::get( emitUnaryBuiltin(*this, E, llvm::Intrinsic::tan, "elt.tan")); + case Builtin::BI__builtin_elementwise_tanh: + return RValue::get( + emitUnaryBuiltin(*this, E, llvm::Intrinsic::tanh, "elt.tanh")); case Builtin::BI__builtin_elementwise_trunc: return RValue::get( emitUnaryBuiltin(*this, E, llvm::Intrinsic::trunc, "elt.trunc")); diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h index bc72e8a00e0d5..09f26a4588c14 100644 --- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -107,6 +107,34 @@ double3 abs(double3); _HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs) double4 abs(double4); +//===----------------------------------------------------------------------===// +// acos builtins +//===----------------------------------------------------------------------===// + +/// \fn T acos(T Val) +/// \brief Returns the arccosine of the input value, \a Val. +/// \param Val The input value. + +#ifdef __HLSL_ENABLE_16_BIT +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos) +half acos(half); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos) +half2 acos(half2); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos) +half3 acos(half3); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos) +half4 acos(half4); +#endif + +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos) +float acos(float); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos) +float2 acos(float2); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos) +float3 acos(float3); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos) +float4 acos(float4); + //===----------------------------------------------------------------------===// // all builtins //===----------------------------------------------------------------------===// @@ -331,6 +359,62 @@ bool any(double3); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_any) bool any(double4); +//===----------------------------------------------------------------------===// +// asin builtins +//===----------------------------------------------------------------------===// + +/// \fn T asin(T Val) +/// \brief Returns the arcsine of the input value, \a Val. +/// \param Val The input value. + +#ifdef __HLSL_ENABLE_16_BIT +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin) +half asin(half); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin) +half2 asin(half2); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin) +half3 asin(half3); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin) +half4 asin(half4); +#endif + +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin) +float asin(float); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin) +float2 asin(float2); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin) +float3 asin(float3); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin) +float4 asin(float4); + +//===----------------------------------------------------------------------===// +// atan builtins +//===----------------------------------------------------------------------===// + +/// \fn T atan(T Val) +/// \brief Returns the arctangent of the input value, \a Val. +/// \param Val The input value. + +#ifdef __HLSL_ENABLE_16_BIT +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan) +half atan(half); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan) +half2 atan(half2); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan) +half3 atan(half3); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan) +half4 atan(half4); +#endif + +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan) +float atan(float); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan) +float2 atan(float2); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan) +float3 atan(float3); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan) +float4 atan(float4); + //===----------------------------------------------------------------------===// // ceil builtins //===----------------------------------------------------------------------===// @@ -502,6 +586,34 @@ float3 cos(float3); _HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos) float4 cos(float4); +//===----------------------------------------------------------------------===// +// cosh builtins +//===----------------------------------------------------------------------===// + +/// \fn T cosh(T Val) +/// \brief Returns the hyperbolic cosine of the input value, \a Val. +/// \param Val The input value. + +#ifdef __HLSL_ENABLE_16_BIT +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh) +half cosh(half); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh) +half2 cosh(half2); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh) +half3 cosh(half3); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh) +half4 cosh(half4); +#endif + +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh) +float cosh(float); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh) +float2 cosh(float2); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh) +float3 cosh(float3); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh) +float4 cosh(float4); + //===----------------------------------------------------------------------===// // dot product builtins //===----------------------------------------------------------------------===// @@ -1418,6 +1530,34 @@ float3 sin(float3); _HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin) float4 sin(float4); +//===----------------------------------------------------------------------===// +// sinh builtins +//===----------------------------------------------------------------------===// + +/// \fn T sinh(T Val) +/// \brief Returns the hyperbolic sine of the input value, \a Val. +/// \param Val The input value. + +#ifdef __HLSL_ENABLE_16_BIT +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh) +half sinh(half); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh) +half2 sinh(half2); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh) +half3 sinh(half3); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh) +half4 sinh(half4); +#endif + +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh) +float sinh(float); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh) +float2 sinh(float2); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh) +float3 sinh(float3); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh) +float4 sinh(float4); + //===----------------------------------------------------------------------===// // sqrt builtins //===----------------------------------------------------------------------===// @@ -1451,6 +1591,11 @@ float4 sqrt(float4); //===----------------------------------------------------------------------===// // tan builtins //===----------------------------------------------------------------------===// + +/// \fn T tan(T Val) +/// \brief Returns the tangent of the input value, \a Val. +/// \param Val The input value. + #ifdef __HLSL_ENABLE_16_BIT _HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan) half tan(half); @@ -1471,6 +1616,34 @@ float3 tan(float3); _HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan) float4 tan(float4); +//===----------------------------------------------------------------------===// +// tanh builtins +//===----------------------------------------------------------------------===// + +/// \fn T tanh(T Val) +/// \brief Returns the hyperbolic tangent of the input value, \a Val. +/// \param Val The input value. + +#ifdef __HLSL_ENABLE_16_BIT +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh) +half tanh(half); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh) +half2 tanh(half2); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh) +half3 tanh(half3); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh) +half4 tanh(half4); +#endif + +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh) +float tanh(float); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh) +float2 tanh(float2); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh) +float3 tanh(float3); +_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh) +float4 tanh(float4); + //===----------------------------------------------------------------------===// // trunc builtins //===----------------------------------------------------------------------===// diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 07cd0727eb3f4..832545c7ab5ab 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -3047,8 +3047,12 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, // These builtins restrict the element type to floating point // types only. + case Builtin::BI__builtin_elementwise_acos: + case Builtin::BI__builtin_elementwise_asin: + case Builtin::BI__builtin_elementwise_atan: case Builtin::BI__builtin_elementwise_ceil: case Builtin::BI__builtin_elementwise_cos: + case Builtin::BI__builtin_elementwise_cosh: case Builtin::BI__builtin_elementwise_exp: case Builtin::BI__builtin_elementwise_exp2: case Builtin::BI__builtin_elementwise_floor: @@ -3060,8 +3064,10 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, case Builtin::BI__builtin_elementwise_rint: case Builtin::BI__builtin_elementwise_nearbyint: case Builtin::BI__builtin_elementwise_sin: + case Builtin::BI__builtin_elementwise_sinh: case Builtin::BI__builtin_elementwise_sqrt: case Builtin::BI__builtin_elementwise_tan: + case Builtin::BI__builtin_elementwise_tanh: case Builtin::BI__builtin_elementwise_trunc: case Builtin::BI__builtin_elementwise_canonicalize: { if (PrepareBuiltinElementwiseMathOneArgCall(TheCall)) @@ -3522,8 +3528,12 @@ bool Sema::CheckHLSLBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { return true; break; } + case Builtin::BI__builtin_elementwise_acos: + case Builtin::BI__builtin_elementwise_asin: + case Builtin::BI__builtin_elementwise_atan: case Builtin::BI__builtin_elementwise_ceil: case Builtin::BI__builtin_elementwise_cos: + case Builtin::BI__builtin_elementwise_cosh: case Builtin::BI__builtin_elementwise_exp: case Builtin::BI__builtin_elementwise_exp2: case Builtin::BI__builtin_elementwise_floor: @@ -3533,8 +3543,10 @@ bool Sema::CheckHLSLBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { case Builtin::BI__builtin_elementwise_pow: case Builtin::BI__builtin_elementwise_roundeven: case Builtin::BI__builtin_elementwise_sin: + case Builtin::BI__builtin_elementwise_sinh: case Builtin::BI__builtin_elementwise_sqrt: case Builtin::BI__builtin_elementwise_tan: + case Builtin::BI__builtin_elementwise_tanh: case Builtin::BI__builtin_elementwise_trunc: { if (CheckFloatOrHalfRepresentations(this, TheCall)) return true; diff --git a/clang/test/CodeGen/builtins-elementwise-math.c b/clang/test/CodeGen/builtins-elementwise-math.c index 1b5466abd347d..b52a11cca1990 100644 --- a/clang/test/CodeGen/builtins-elementwise-math.c +++ b/clang/test/CodeGen/builtins-elementwise-math.c @@ -375,6 +375,54 @@ void test_builtin_elementwise_ceil(float f1, float f2, double d1, double d2, vf2 = __builtin_elementwise_ceil(vf1); } +void test_builtin_elementwise_acos(float f1, float f2, double d1, double d2, + float4 vf1, float4 vf2) { + // CHECK-LABEL: define void @test_builtin_elementwise_acos( + // CHECK: [[F1:%.+]] = load float, ptr %f1.addr, align 4 + // CHECK-NEXT: call float @llvm.acos.f32(float [[F1]]) + f2 = __builtin_elementwise_acos(f1); + + // CHECK: [[D1:%.+]] = load double, ptr %d1.addr, align 8 + // CHECK-NEXT: call double @llvm.acos.f64(double [[D1]]) + d2 = __builtin_elementwise_acos(d1); + + // CHECK: [[VF1:%.+]] = load <4 x float>, ptr %vf1.addr, align 16 + // CHECK-NEXT: call <4 x float> @llvm.acos.v4f32(<4 x float> [[VF1]]) + vf2 = __builtin_elementwise_acos(vf1); +} + +void test_builtin_elementwise_asin(float f1, float f2, double d1, double d2, + float4 vf1, float4 vf2) { + // CHECK-LABEL: define void @test_builtin_elementwise_asin( + // CHECK: [[F1:%.+]] = load float, ptr %f1.addr, align 4 + // CHECK-NEXT: call float @llvm.asin.f32(float [[F1]]) + f2 = __builtin_elementwise_asin(f1); + + // CHECK: [[D1:%.+]] = load double, ptr %d1.addr, align 8 + // CHECK-NEXT: call double @llvm.asin.f64(double [[D1]]) + d2 = __builtin_elementwise_asin(d1); + + // CHECK: [[VF1:%.+]] = load <4 x float>, ptr %vf1.addr, align 16 + // CHECK-NEXT: call <4 x float> @llvm.asin.v4f32(<4 x float> [[VF1]]) + vf2 = __builtin_elementwise_asin(vf1); +} + +void test_builtin_elementwise_atan(float f1, float f2, double d1, double d2, + float4 vf1, float4 vf2) { + // CHECK-LABEL: define void @test_builtin_elementwise_atan( + // CHECK: [[F1:%.+]] = load float, ptr %f1.addr, align 4 + // CHECK-NEXT: call float @llvm.atan.f32(float [[F1]]) + f2 = __builtin_elementwise_atan(f1); + + // CHECK: [[D1:%.+]] = load double, ptr %d1.addr, align 8 + // CHECK-NEXT: call double @llvm.atan.f64(double [[D1]]) + d2 = __builtin_elementwise_atan(d1); + + // CHECK: [[VF1:%.+]] = load <4 x float>, ptr %vf1.addr, align 16 + // CHECK-NEXT: call <4 x float> @llvm.atan.v4f32(<4 x float> [[VF1]]) + vf2 = __builtin_elementwise_atan(vf1); +} + void test_builtin_elementwise_cos(float f1, float f2, double d1, double d2, float4 vf1, float4 vf2) { // CHECK-LABEL: define void @test_builtin_elementwise_cos( @@ -391,6 +439,22 @@ void test_builtin_elementwise_cos(float f1, float f2, double d1, double d2, vf2 = __builtin_elementwise_cos(vf1); } +void test_builtin_elementwise_cosh(float f1, float f2, double d1, double d2, + float4 vf1, float4 vf2) { + // CHECK-LABEL: define void @test_builtin_elementwise_cosh( + // CHECK: [[F1:%.+]] = load float, ptr %f1.addr, align 4 + // CHECK-NEXT: call float @llvm.cosh.f32(float [[F1]]) + f2 = __builtin_elementwise_cosh(f1); + + // CHECK: [[D1:%.+]] = load double, ptr %d1.addr, align 8 + // CHECK-NEXT: call double @llvm.cosh.f64(double [[D1]]) + d2 = __builtin_elementwise_cosh(d1); + + // CHECK: [[VF1:%.+]] = load <4 x float>, ptr %vf1.addr, align 16 + // CHECK-NEXT: call <4 x float> @llvm.cosh.v4f32(<4 x float> [[VF1]]) + vf2 = __builtin_elementwise_cosh(vf1); +} + void test_builtin_elementwise_exp(float f1, float f2, double d1, double d2, float4 vf1, float4 vf2) { // CHECK-LABEL: define void @test_builtin_elementwise_exp( @@ -588,6 +652,22 @@ void test_builtin_elementwise_sin(float f1, float f2, double d1, double d2, ... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/95999 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits