https://github.com/danbrown-amd updated https://github.com/llvm/llvm-project/pull/195586
>From 6c1f7ecf6a4a18ca3553d904a53f3fb4ec696f9c Mon Sep 17 00:00:00 2001 From: Dan Brown <[email protected]> Date: Sun, 3 May 2026 23:01:34 -0600 Subject: [PATCH] [HLSL] Adds matrix support for isnan() and isinf(). Addresses #184483 and #184505. Assisted-by: Claude Sonnet 4 --- clang/include/clang/Basic/Builtins.td | 4 +- clang/include/clang/Basic/HLSLIntrinsics.td | 2 - clang/lib/CodeGen/CGExpr.cpp | 3 + clang/lib/CodeGen/CGHLSLBuiltins.cpp | 20 +- .../lib/Headers/hlsl/hlsl_compat_overloads.h | 64 ++++++ clang/lib/Sema/SemaChecking.cpp | 3 +- clang/lib/Sema/SemaHLSL.cpp | 9 +- .../builtins/isinf-overloads_mat.hlsl | 88 +++++++++ .../test/CodeGenHLSL/builtins/isinf_mat.hlsl | 183 ++++++++++++++++++ .../CodeGenHLSL/builtins/isnan-overloads.hlsl | 31 ++- .../builtins/isnan-overloads_mat.hlsl | 88 +++++++++ clang/test/CodeGenHLSL/builtins/isnan.hlsl | 161 +++++++++++++++ .../test/CodeGenHLSL/builtins/isnan_mat.hlsl | 183 ++++++++++++++++++ .../test/SemaHLSL/BuiltIns/isinf-errors.hlsl | 11 -- .../SemaHLSL/BuiltIns/isinf-errors_mat.hlsl | 6 + .../test/SemaHLSL/BuiltIns/isnan-errors.hlsl | 11 -- .../SemaHLSL/BuiltIns/isnan-errors_mat.hlsl | 6 + 17 files changed, 829 insertions(+), 44 deletions(-) create mode 100644 clang/test/CodeGenHLSL/builtins/isinf-overloads_mat.hlsl create mode 100644 clang/test/CodeGenHLSL/builtins/isinf_mat.hlsl create mode 100644 clang/test/CodeGenHLSL/builtins/isnan-overloads_mat.hlsl create mode 100644 clang/test/CodeGenHLSL/builtins/isnan_mat.hlsl create mode 100644 clang/test/SemaHLSL/BuiltIns/isinf-errors_mat.hlsl create mode 100644 clang/test/SemaHLSL/BuiltIns/isnan-errors_mat.hlsl diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index 84799929cee87..4491edf067721 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -5588,13 +5588,13 @@ def HLSLFrac : LangBuiltin<"HLSL_LANG"> { def HLSLIsinf : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_elementwise_isinf"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } def HLSLIsnan : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_elementwise_isnan"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td index 6084a6f92180e..96c65ea807293 100644 --- a/clang/include/clang/Basic/HLSLIntrinsics.td +++ b/clang/include/clang/Basic/HLSLIntrinsics.td @@ -1085,7 +1085,6 @@ to True if the x parameter is +INF or -INF. Otherwise, False. }]; let ReturnType = VaryingShape<BoolTy>; let VaryingTypes = [HalfTy, FloatTy]; - let VaryingMatDims = []; } // Determines if the specified value x is Not a Number. @@ -1100,7 +1099,6 @@ to True if the x parameter is NaN or QNaN. Otherwise, False. }]; let ReturnType = VaryingShape<BoolTy>; let VaryingTypes = [HalfTy, FloatTy]; - let VaryingMatDims = []; } // Returns the result of multiplying the specified value by two raised diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 77fd47ed42f03..f1268d4eb7499 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -2295,6 +2295,9 @@ llvm::Value *CodeGenFunction::EmitFromMemory(llvm::Value *Value, QualType Ty) { } llvm::Type *ResTy = ConvertType(Ty); + if (Ty->isConstantMatrixBoolType()) + return Builder.CreateTrunc(Value, ResTy, "loadedv"); + bool HasBoolRep = Ty->hasBooleanRepresentation() || Ty->isExtVectorBoolType(); if (HasBoolRep && CGM.getCodeGenOpts().isConvertingBoolWithCmp0()) { return Builder.CreateICmpNE( diff --git a/clang/lib/CodeGen/CGHLSLBuiltins.cpp b/clang/lib/CodeGen/CGHLSLBuiltins.cpp index a4cd28f97b6d6..e18df06ec6d0c 100644 --- a/clang/lib/CodeGen/CGHLSLBuiltins.cpp +++ b/clang/lib/CodeGen/CGHLSLBuiltins.cpp @@ -1122,9 +1122,13 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID, llvm::Type *Xty = Op0->getType(); llvm::Type *retType = llvm::Type::getInt1Ty(this->getLLVMContext()); if (Xty->isVectorTy()) { - auto *XVecTy = E->getArg(0)->getType()->castAs<VectorType>(); - retType = llvm::VectorType::get( - retType, ElementCount::getFixed(XVecTy->getNumElements())); + unsigned NumElts; + if (auto *MatTy = E->getArg(0)->getType()->getAs<ConstantMatrixType>()) + NumElts = MatTy->getNumRows() * MatTy->getNumColumns(); + else + NumElts = + E->getArg(0)->getType()->castAs<VectorType>()->getNumElements(); + retType = llvm::VectorType::get(retType, ElementCount::getFixed(NumElts)); } if (!E->getArg(0)->getType()->hasFloatingRepresentation()) llvm_unreachable("isinf operand must have a float representation"); @@ -1137,9 +1141,13 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID, llvm::Type *Xty = Op0->getType(); llvm::Type *retType = llvm::Type::getInt1Ty(this->getLLVMContext()); if (Xty->isVectorTy()) { - auto *XVecTy = E->getArg(0)->getType()->castAs<VectorType>(); - retType = llvm::VectorType::get( - retType, ElementCount::getFixed(XVecTy->getNumElements())); + unsigned NumElts; + if (auto *MatTy = E->getArg(0)->getType()->getAs<ConstantMatrixType>()) + NumElts = MatTy->getNumRows() * MatTy->getNumColumns(); + else + NumElts = + E->getArg(0)->getType()->castAs<VectorType>()->getNumElements(); + retType = llvm::VectorType::get(retType, ElementCount::getFixed(NumElts)); } if (!E->getArg(0)->getType()->hasFloatingRepresentation()) llvm_unreachable("isnan operand must have a float representation"); diff --git a/clang/lib/Headers/hlsl/hlsl_compat_overloads.h b/clang/lib/Headers/hlsl/hlsl_compat_overloads.h index d97039128ea85..4d00b34b32ca0 100644 --- a/clang/lib/Headers/hlsl/hlsl_compat_overloads.h +++ b/clang/lib/Headers/hlsl/hlsl_compat_overloads.h @@ -390,15 +390,79 @@ _DXC_DEPRECATED_64BIT_FN(fn) constexpr bool3 isinf(double3 V) { return isinf((float3)V); } _DXC_DEPRECATED_64BIT_FN(fn) constexpr bool4 isinf(double4 V) { return isinf((float4)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool1x2 isinf(double1x2 V) { return isinf((float1x2)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool1x3 isinf(double1x3 V) { return isinf((float1x3)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool1x4 isinf(double1x4 V) { return isinf((float1x4)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool2x1 isinf(double2x1 V) { return isinf((float2x1)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool2x2 isinf(double2x2 V) { return isinf((float2x2)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool2x3 isinf(double2x3 V) { return isinf((float2x3)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool2x4 isinf(double2x4 V) { return isinf((float2x4)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool3x1 isinf(double3x1 V) { return isinf((float3x1)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool3x2 isinf(double3x2 V) { return isinf((float3x2)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool3x3 isinf(double3x3 V) { return isinf((float3x3)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool3x4 isinf(double3x4 V) { return isinf((float3x4)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool4x1 isinf(double4x1 V) { return isinf((float4x1)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool4x2 isinf(double4x2 V) { return isinf((float4x2)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool4x3 isinf(double4x3 V) { return isinf((float4x3)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool4x4 isinf(double4x4 V) { return isinf((float4x4)V); } //===----------------------------------------------------------------------===// // isnan builtins overloads //===----------------------------------------------------------------------===// +_DXC_DEPRECATED_64BIT_FN(fn) constexpr bool isnan(double V) { return isnan((float)V); } +_DXC_DEPRECATED_64BIT_FN(fn) constexpr bool2 isnan(double2 V) { return isnan((float2)V); } +_DXC_DEPRECATED_64BIT_FN(fn) constexpr bool3 isnan(double3 V) { return isnan((float3)V); } +_DXC_DEPRECATED_64BIT_FN(fn) constexpr bool4 isnan(double4 V) { return isnan((float4)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool1x2 isnan(double1x2 V) { return isnan((float1x2)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool1x3 isnan(double1x3 V) { return isnan((float1x3)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool1x4 isnan(double1x4 V) { return isnan((float1x4)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool2x1 isnan(double2x1 V) { return isnan((float2x1)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool2x2 isnan(double2x2 V) { return isnan((float2x2)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool2x3 isnan(double2x3 V) { return isnan((float2x3)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool2x4 isnan(double2x4 V) { return isnan((float2x4)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool3x1 isnan(double3x1 V) { return isnan((float3x1)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool3x2 isnan(double3x2 V) { return isnan((float3x2)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool3x3 isnan(double3x3 V) { return isnan((float3x3)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool3x4 isnan(double3x4 V) { return isnan((float3x4)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool4x1 isnan(double4x1 V) { return isnan((float4x1)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool4x2 isnan(double4x2 V) { return isnan((float4x2)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool4x3 isnan(double4x3 V) { return isnan((float4x3)V); } +_DXC_DEPRECATED_64BIT_FN(fn) +constexpr bool4x4 isnan(double4x4 V) { return isnan((float4x4)V); } //===----------------------------------------------------------------------===// // lerp builtins overloads diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 2309196ee1696..935f041cb3763 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2200,7 +2200,8 @@ checkMathBuiltinElementType(Sema &S, SourceLocation Loc, QualType ArgTy, switch (ArgTyRestr) { case Sema::EltwiseBuiltinArgTyRestriction::None: - if (!ArgTy->getAs<VectorType>() && !isValidMathElementType(ArgTy)) { + if (!ArgTy->getAs<VectorType>() && !ArgTy->getAs<MatrixType>() && + !isValidMathElementType(ArgTy)) { return S.Diag(Loc, diag::err_builtin_invalid_arg_type) << ArgOrdinal << /* vector */ 2 << /* integer */ 1 << /* fp */ 1 << ArgTy; diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp index 8c747cdb02606..139baf845111f 100644 --- a/clang/lib/Sema/SemaHLSL.cpp +++ b/clang/lib/Sema/SemaHLSL.cpp @@ -3282,6 +3282,8 @@ static bool CheckFloatRepresentation(Sema *S, SourceLocation Loc, clang::QualType BaseType = PassedType->isVectorType() ? PassedType->castAs<clang::VectorType>()->getElementType() + : PassedType->getAs<clang::ConstantMatrixType>() + ? PassedType->castAs<clang::ConstantMatrixType>()->getElementType() : PassedType; if (!BaseType->isFloat32Type()) return S->Diag(Loc, diag::err_builtin_invalid_arg_type) @@ -3402,10 +3404,13 @@ static bool CheckExpectedBitWidth(Sema *S, CallExpr *TheCall, static void SetElementTypeAsReturnType(Sema *S, CallExpr *TheCall, QualType ReturnType) { - auto *VecTyA = TheCall->getArg(0)->getType()->getAs<VectorType>(); - if (VecTyA) + if (auto *VecTyA = TheCall->getArg(0)->getType()->getAs<VectorType>()) ReturnType = S->Context.getExtVectorType(ReturnType, VecTyA->getNumElements()); + else if (auto *MatTyA = + TheCall->getArg(0)->getType()->getAs<ConstantMatrixType>()) + ReturnType = S->Context.getConstantMatrixType( + ReturnType, MatTyA->getNumRows(), MatTyA->getNumColumns()); TheCall->setType(ReturnType); } diff --git a/clang/test/CodeGenHLSL/builtins/isinf-overloads_mat.hlsl b/clang/test/CodeGenHLSL/builtins/isinf-overloads_mat.hlsl new file mode 100644 index 0000000000000..2a00eab249ed1 --- /dev/null +++ b/clang/test/CodeGenHLSL/builtins/isinf-overloads_mat.hlsl @@ -0,0 +1,88 @@ +// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -Wdeprecated-declarations -o - | FileCheck %s \ +// RUN: -DFNATTRS="hidden noundef" -DTARGET=dx +// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \ +// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \ +// RUN: -Wdeprecated-declarations -o - | FileCheck %s \ +// RUN: -DFNATTRS="hidden spir_func noundef" -DTARGET=spv +// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s \ +// RUN: -verify -verify-ignore-unexpected=note +// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple spirv-unknown-vulkan-compute %s \ +// RUN: -verify -verify-ignore-unexpected=note + +// CHECK: define [[FNATTRS]] <2 x i1> @ +// CHECK: %hlsl.isinf = call <2 x i1> @llvm.[[TARGET]].isinf.v2f32 +// CHECK: ret <2 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool1x2 test_isinf_double1x2(double1x2 p0) { return isinf(p0); } +// CHECK: define [[FNATTRS]] <3 x i1> @ +// CHECK: %hlsl.isinf = call <3 x i1> @llvm.[[TARGET]].isinf.v3f32 +// CHECK: ret <3 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool1x3 test_isinf_double1x3(double1x3 p0) { return isinf(p0); } +// CHECK: define [[FNATTRS]] <4 x i1> @ +// CHECK: %hlsl.isinf = call <4 x i1> @llvm.[[TARGET]].isinf.v4f32 +// CHECK: ret <4 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool1x4 test_isinf_double1x4(double1x4 p0) { return isinf(p0); } +// CHECK: define [[FNATTRS]] <2 x i1> @ +// CHECK: %hlsl.isinf = call <2 x i1> @llvm.[[TARGET]].isinf.v2f32 +// CHECK: ret <2 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool2x1 test_isinf_double2x1(double2x1 p0) { return isinf(p0); } +// CHECK: define [[FNATTRS]] <4 x i1> @ +// CHECK: %hlsl.isinf = call <4 x i1> @llvm.[[TARGET]].isinf.v4f32 +// CHECK: ret <4 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool2x2 test_isinf_double2x2(double2x2 p0) { return isinf(p0); } +// CHECK: define [[FNATTRS]] <6 x i1> @ +// CHECK: %hlsl.isinf = call <6 x i1> @llvm.[[TARGET]].isinf.v6f32 +// CHECK: ret <6 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool2x3 test_isinf_double2x3(double2x3 p0) { return isinf(p0); } +// CHECK: define [[FNATTRS]] <8 x i1> @ +// CHECK: %hlsl.isinf = call <8 x i1> @llvm.[[TARGET]].isinf.v8f32 +// CHECK: ret <8 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool2x4 test_isinf_double2x4(double2x4 p0) { return isinf(p0); } +// CHECK: define [[FNATTRS]] <3 x i1> @ +// CHECK: %hlsl.isinf = call <3 x i1> @llvm.[[TARGET]].isinf.v3f32 +// CHECK: ret <3 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool3x1 test_isinf_double3x1(double3x1 p0) { return isinf(p0); } +// CHECK: define [[FNATTRS]] <6 x i1> @ +// CHECK: %hlsl.isinf = call <6 x i1> @llvm.[[TARGET]].isinf.v6f32 +// CHECK: ret <6 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool3x2 test_isinf_double3x2(double3x2 p0) { return isinf(p0); } +// CHECK: define [[FNATTRS]] <9 x i1> @ +// CHECK: %hlsl.isinf = call <9 x i1> @llvm.[[TARGET]].isinf.v9f32 +// CHECK: ret <9 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool3x3 test_isinf_double3x3(double3x3 p0) { return isinf(p0); } +// CHECK: define [[FNATTRS]] <12 x i1> @ +// CHECK: %hlsl.isinf = call <12 x i1> @llvm.[[TARGET]].isinf.v12f32 +// CHECK: ret <12 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool3x4 test_isinf_double3x4(double3x4 p0) { return isinf(p0); } +// CHECK: define [[FNATTRS]] <4 x i1> @ +// CHECK: %hlsl.isinf = call <4 x i1> @llvm.[[TARGET]].isinf.v4f32 +// CHECK: ret <4 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool4x1 test_isinf_double4x1(double4x1 p0) { return isinf(p0); } +// CHECK: define [[FNATTRS]] <8 x i1> @ +// CHECK: %hlsl.isinf = call <8 x i1> @llvm.[[TARGET]].isinf.v8f32 +// CHECK: ret <8 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool4x2 test_isinf_double4x2(double4x2 p0) { return isinf(p0); } +// CHECK: define [[FNATTRS]] <12 x i1> @ +// CHECK: %hlsl.isinf = call <12 x i1> @llvm.[[TARGET]].isinf.v12f32 +// CHECK: ret <12 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool4x3 test_isinf_double4x3(double4x3 p0) { return isinf(p0); } +// CHECK: define [[FNATTRS]] <16 x i1> @ +// CHECK: %hlsl.isinf = call <16 x i1> @llvm.[[TARGET]].isinf.v16f32 +// CHECK: ret <16 x i1> %hlsl.isinf +// expected-warning@+1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool4x4 test_isinf_double4x4(double4x4 p0) { return isinf(p0); } diff --git a/clang/test/CodeGenHLSL/builtins/isinf_mat.hlsl b/clang/test/CodeGenHLSL/builtins/isinf_mat.hlsl new file mode 100644 index 0000000000000..2d9eea3a8ec04 --- /dev/null +++ b/clang/test/CodeGenHLSL/builtins/isinf_mat.hlsl @@ -0,0 +1,183 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type -fnative-int16-type \ +// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ +// RUN: --check-prefixes=CHECK,DXCHECK,NATIVE_HALF +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %s --check-prefixes=CHECK,DXCHECK,NO_HALF + +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: spirv-unknown-vulkan-compute %s -fnative-half-type -fnative-int16-type \ +// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ +// RUN: --check-prefixes=CHECK,SPVCHECK,NATIVE_HALF +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %s --check-prefixes=CHECK,SPVCHECK,NO_HALF + +// DXCHECK: define hidden [[FN_TYPE:]]noundef <2 x i1> @ +// SPVCHECK: define hidden [[FN_TYPE:spir_func ]]noundef <2 x i1> @ +// DXCHECK: %hlsl.isinf = call <2 x i1> @llvm.[[ICF:dx]].isinf.v2f32( +// SPVCHECK: %hlsl.isinf = call <2 x i1> @llvm.[[ICF:spv]].isinf.v2f32( +// CHECK: ret <2 x i1> %hlsl.isinf +bool1x2 test_isinf_float1x2(float1x2 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <3 x i1> @ +// CHECK: %hlsl.isinf = call <3 x i1> @llvm.[[ICF]].isinf.v3f32 +// CHECK: ret <3 x i1> %hlsl.isinf +bool1x3 test_isinf_float1x3(float1x3 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// CHECK: %hlsl.isinf = call <4 x i1> @llvm.[[ICF]].isinf.v4f32 +// CHECK: ret <4 x i1> %hlsl.isinf +bool1x4 test_isinf_float1x4(float1x4 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <2 x i1> @ +// CHECK: %hlsl.isinf = call <2 x i1> @llvm.[[ICF]].isinf.v2f32 +// CHECK: ret <2 x i1> %hlsl.isinf +bool2x1 test_isinf_float2x1(float2x1 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// CHECK: %hlsl.isinf = call <4 x i1> @llvm.[[ICF]].isinf.v4f32 +// CHECK: ret <4 x i1> %hlsl.isinf +bool2x2 test_isinf_float2x2(float2x2 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <6 x i1> @ +// CHECK: %hlsl.isinf = call <6 x i1> @llvm.[[ICF]].isinf.v6f32 +// CHECK: ret <6 x i1> %hlsl.isinf +bool2x3 test_isinf_float2x3(float2x3 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <8 x i1> @ +// CHECK: %hlsl.isinf = call <8 x i1> @llvm.[[ICF]].isinf.v8f32 +// CHECK: ret <8 x i1> %hlsl.isinf +bool2x4 test_isinf_float2x4(float2x4 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <3 x i1> @ +// CHECK: %hlsl.isinf = call <3 x i1> @llvm.[[ICF]].isinf.v3f32 +// CHECK: ret <3 x i1> %hlsl.isinf +bool3x1 test_isinf_float3x1(float3x1 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <6 x i1> @ +// CHECK: %hlsl.isinf = call <6 x i1> @llvm.[[ICF]].isinf.v6f32 +// CHECK: ret <6 x i1> %hlsl.isinf +bool3x2 test_isinf_float3x2(float3x2 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <9 x i1> @ +// CHECK: %hlsl.isinf = call <9 x i1> @llvm.[[ICF]].isinf.v9f32 +// CHECK: ret <9 x i1> %hlsl.isinf +bool3x3 test_isinf_float3x3(float3x3 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <12 x i1> @ +// CHECK: %hlsl.isinf = call <12 x i1> @llvm.[[ICF]].isinf.v12f32 +// CHECK: ret <12 x i1> %hlsl.isinf +bool3x4 test_isinf_float3x4(float3x4 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// CHECK: %hlsl.isinf = call <4 x i1> @llvm.[[ICF]].isinf.v4f32 +// CHECK: ret <4 x i1> %hlsl.isinf +bool4x1 test_isinf_float4x1(float4x1 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <8 x i1> @ +// CHECK: %hlsl.isinf = call <8 x i1> @llvm.[[ICF]].isinf.v8f32 +// CHECK: ret <8 x i1> %hlsl.isinf +bool4x2 test_isinf_float4x2(float4x2 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <12 x i1> @ +// CHECK: %hlsl.isinf = call <12 x i1> @llvm.[[ICF]].isinf.v12f32 +// CHECK: ret <12 x i1> %hlsl.isinf +bool4x3 test_isinf_float4x3(float4x3 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <16 x i1> @ +// CHECK: %hlsl.isinf = call <16 x i1> @llvm.[[ICF]].isinf.v16f32 +// CHECK: ret <16 x i1> %hlsl.isinf +bool4x4 test_isinf_float4x4(float4x4 p0) { return isinf(p0); } + + +// CHECK: define hidden [[FN_TYPE]]noundef <2 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <2 x i1> @llvm.[[ICF]].isinf.v2f16 +// NO_HALF: %hlsl.isinf = call <2 x i1> @llvm.[[ICF]].isinf.v2f32 +// CHECK: ret <2 x i1> %hlsl.isinf +bool1x2 test_isinf_half1x2(half1x2 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <3 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <3 x i1> @llvm.[[ICF]].isinf.v3f16 +// NO_HALF: %hlsl.isinf = call <3 x i1> @llvm.[[ICF]].isinf.v3f32 +// CHECK: ret <3 x i1> %hlsl.isinf +bool1x3 test_isinf_half1x3(half1x3 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <4 x i1> @llvm.[[ICF]].isinf.v4f16 +// NO_HALF: %hlsl.isinf = call <4 x i1> @llvm.[[ICF]].isinf.v4f32 +// CHECK: ret <4 x i1> %hlsl.isinf +bool1x4 test_isinf_half1x4(half1x4 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <2 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <2 x i1> @llvm.[[ICF]].isinf.v2f16 +// NO_HALF: %hlsl.isinf = call <2 x i1> @llvm.[[ICF]].isinf.v2f32 +// CHECK: ret <2 x i1> %hlsl.isinf +bool2x1 test_isinf_half2x1(half2x1 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <4 x i1> @llvm.[[ICF]].isinf.v4f16 +// NO_HALF: %hlsl.isinf = call <4 x i1> @llvm.[[ICF]].isinf.v4f32 +// CHECK: ret <4 x i1> %hlsl.isinf +bool2x2 test_isinf_half2x2(half2x2 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <6 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <6 x i1> @llvm.[[ICF]].isinf.v6f16 +// NO_HALF: %hlsl.isinf = call <6 x i1> @llvm.[[ICF]].isinf.v6f32 +// CHECK: ret <6 x i1> %hlsl.isinf +bool2x3 test_isinf_half2x3(half2x3 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <8 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <8 x i1> @llvm.[[ICF]].isinf.v8f16 +// NO_HALF: %hlsl.isinf = call <8 x i1> @llvm.[[ICF]].isinf.v8f32 +// CHECK: ret <8 x i1> %hlsl.isinf +bool2x4 test_isinf_half2x4(half2x4 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <3 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <3 x i1> @llvm.[[ICF]].isinf.v3f16 +// NO_HALF: %hlsl.isinf = call <3 x i1> @llvm.[[ICF]].isinf.v3f32 +// CHECK: ret <3 x i1> %hlsl.isinf +bool3x1 test_isinf_half3x1(half3x1 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <6 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <6 x i1> @llvm.[[ICF]].isinf.v6f16 +// NO_HALF: %hlsl.isinf = call <6 x i1> @llvm.[[ICF]].isinf.v6f32 +// CHECK: ret <6 x i1> %hlsl.isinf +bool3x2 test_isinf_half3x2(half3x2 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <9 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <9 x i1> @llvm.[[ICF]].isinf.v9f16 +// NO_HALF: %hlsl.isinf = call <9 x i1> @llvm.[[ICF]].isinf.v9f32 +// CHECK: ret <9 x i1> %hlsl.isinf +bool3x3 test_isinf_half3x3(half3x3 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <12 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <12 x i1> @llvm.[[ICF]].isinf.v12f16 +// NO_HALF: %hlsl.isinf = call <12 x i1> @llvm.[[ICF]].isinf.v12f32 +// CHECK: ret <12 x i1> %hlsl.isinf +bool3x4 test_isinf_half3x4(half3x4 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <4 x i1> @llvm.[[ICF]].isinf.v4f16 +// NO_HALF: %hlsl.isinf = call <4 x i1> @llvm.[[ICF]].isinf.v4f32 +// CHECK: ret <4 x i1> %hlsl.isinf +bool4x1 test_isinf_half4x1(half4x1 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <8 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <8 x i1> @llvm.[[ICF]].isinf.v8f16 +// NO_HALF: %hlsl.isinf = call <8 x i1> @llvm.[[ICF]].isinf.v8f32 +// CHECK: ret <8 x i1> %hlsl.isinf +bool4x2 test_isinf_half4x2(half4x2 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <12 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <12 x i1> @llvm.[[ICF]].isinf.v12f16 +// NO_HALF: %hlsl.isinf = call <12 x i1> @llvm.[[ICF]].isinf.v12f32 +// CHECK: ret <12 x i1> %hlsl.isinf +bool4x3 test_isinf_half4x3(half4x3 p0) { return isinf(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <16 x i1> @ +// NATIVE_HALF: %hlsl.isinf = call <16 x i1> @llvm.[[ICF]].isinf.v16f16 +// NO_HALF: %hlsl.isinf = call <16 x i1> @llvm.[[ICF]].isinf.v16f32 +// CHECK: ret <16 x i1> %hlsl.isinf +bool4x4 test_isinf_half4x4(half4x4 p0) { return isinf(p0); } diff --git a/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl b/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl index a0c3eee5da636..8e2a1326e7b1b 100644 --- a/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl +++ b/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl @@ -1,20 +1,33 @@ // RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \ // RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ -// RUN: -o - | FileCheck %s +// RUN: -Wdeprecated-declarations -o - | FileCheck %s \ +// RUN: -DFNATTRS="hidden noundef" -DTARGET=dx +// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \ +// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \ +// RUN: -Wdeprecated-declarations -o - | FileCheck %s \ +// RUN: -DFNATTRS="hidden spir_func noundef" -DTARGET=spv +// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s \ +// RUN: -verify -verify-ignore-unexpected=note +// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple spirv-unknown-vulkan-compute %s \ +// RUN: -verify -verify-ignore-unexpected=note -// CHECK: define hidden noundef i1 @ -// CHECK: %hlsl.isnan = call i1 @llvm.dx.isnan.f32( +// CHECK: define [[FNATTRS]] i1 @ +// CHECK: %hlsl.isnan = call i1 @llvm.[[TARGET]].isnan.f32( // CHECK: ret i1 %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} bool test_isnan_double(double p0) { return isnan(p0); } -// CHECK: define hidden noundef <2 x i1> @ -// CHECK: %hlsl.isnan = call <2 x i1> @llvm.dx.isnan.v2f32 +// CHECK: define [[FNATTRS]] <2 x i1> @ +// CHECK: %hlsl.isnan = call <2 x i1> @llvm.[[TARGET]].isnan.v2f32 // CHECK: ret <2 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} bool2 test_isnan_double2(double2 p0) { return isnan(p0); } -// CHECK: define hidden noundef <3 x i1> @ -// CHECK: %hlsl.isnan = call <3 x i1> @llvm.dx.isnan.v3f32 +// CHECK: define [[FNATTRS]] <3 x i1> @ +// CHECK: %hlsl.isnan = call <3 x i1> @llvm.[[TARGET]].isnan.v3f32 // CHECK: ret <3 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} bool3 test_isnan_double3(double3 p0) { return isnan(p0); } -// CHECK: define hidden noundef <4 x i1> @ -// CHECK: %hlsl.isnan = call <4 x i1> @llvm.dx.isnan.v4f32 +// CHECK: define [[FNATTRS]] <4 x i1> @ +// CHECK: %hlsl.isnan = call <4 x i1> @llvm.[[TARGET]].isnan.v4f32 // CHECK: ret <4 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} bool4 test_isnan_double4(double4 p0) { return isnan(p0); } diff --git a/clang/test/CodeGenHLSL/builtins/isnan-overloads_mat.hlsl b/clang/test/CodeGenHLSL/builtins/isnan-overloads_mat.hlsl new file mode 100644 index 0000000000000..234897e456663 --- /dev/null +++ b/clang/test/CodeGenHLSL/builtins/isnan-overloads_mat.hlsl @@ -0,0 +1,88 @@ +// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -Wdeprecated-declarations -o - | FileCheck %s \ +// RUN: -DFNATTRS="hidden noundef" -DTARGET=dx +// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \ +// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \ +// RUN: -Wdeprecated-declarations -o - | FileCheck %s \ +// RUN: -DFNATTRS="hidden spir_func noundef" -DTARGET=spv +// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s \ +// RUN: -verify -verify-ignore-unexpected=note +// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple spirv-unknown-vulkan-compute %s \ +// RUN: -verify -verify-ignore-unexpected=note + +// CHECK: define [[FNATTRS]] <2 x i1> @ +// CHECK: %hlsl.isnan = call <2 x i1> @llvm.[[TARGET]].isnan.v2f32 +// CHECK: ret <2 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool1x2 test_isnan_double1x2(double1x2 p0) { return isnan(p0); } +// CHECK: define [[FNATTRS]] <3 x i1> @ +// CHECK: %hlsl.isnan = call <3 x i1> @llvm.[[TARGET]].isnan.v3f32 +// CHECK: ret <3 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool1x3 test_isnan_double1x3(double1x3 p0) { return isnan(p0); } +// CHECK: define [[FNATTRS]] <4 x i1> @ +// CHECK: %hlsl.isnan = call <4 x i1> @llvm.[[TARGET]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool1x4 test_isnan_double1x4(double1x4 p0) { return isnan(p0); } +// CHECK: define [[FNATTRS]] <2 x i1> @ +// CHECK: %hlsl.isnan = call <2 x i1> @llvm.[[TARGET]].isnan.v2f32 +// CHECK: ret <2 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool2x1 test_isnan_double2x1(double2x1 p0) { return isnan(p0); } +// CHECK: define [[FNATTRS]] <4 x i1> @ +// CHECK: %hlsl.isnan = call <4 x i1> @llvm.[[TARGET]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool2x2 test_isnan_double2x2(double2x2 p0) { return isnan(p0); } +// CHECK: define [[FNATTRS]] <6 x i1> @ +// CHECK: %hlsl.isnan = call <6 x i1> @llvm.[[TARGET]].isnan.v6f32 +// CHECK: ret <6 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool2x3 test_isnan_double2x3(double2x3 p0) { return isnan(p0); } +// CHECK: define [[FNATTRS]] <8 x i1> @ +// CHECK: %hlsl.isnan = call <8 x i1> @llvm.[[TARGET]].isnan.v8f32 +// CHECK: ret <8 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool2x4 test_isnan_double2x4(double2x4 p0) { return isnan(p0); } +// CHECK: define [[FNATTRS]] <3 x i1> @ +// CHECK: %hlsl.isnan = call <3 x i1> @llvm.[[TARGET]].isnan.v3f32 +// CHECK: ret <3 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool3x1 test_isnan_double3x1(double3x1 p0) { return isnan(p0); } +// CHECK: define [[FNATTRS]] <6 x i1> @ +// CHECK: %hlsl.isnan = call <6 x i1> @llvm.[[TARGET]].isnan.v6f32 +// CHECK: ret <6 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool3x2 test_isnan_double3x2(double3x2 p0) { return isnan(p0); } +// CHECK: define [[FNATTRS]] <9 x i1> @ +// CHECK: %hlsl.isnan = call <9 x i1> @llvm.[[TARGET]].isnan.v9f32 +// CHECK: ret <9 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool3x3 test_isnan_double3x3(double3x3 p0) { return isnan(p0); } +// CHECK: define [[FNATTRS]] <12 x i1> @ +// CHECK: %hlsl.isnan = call <12 x i1> @llvm.[[TARGET]].isnan.v12f32 +// CHECK: ret <12 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool3x4 test_isnan_double3x4(double3x4 p0) { return isnan(p0); } +// CHECK: define [[FNATTRS]] <4 x i1> @ +// CHECK: %hlsl.isnan = call <4 x i1> @llvm.[[TARGET]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool4x1 test_isnan_double4x1(double4x1 p0) { return isnan(p0); } +// CHECK: define [[FNATTRS]] <8 x i1> @ +// CHECK: %hlsl.isnan = call <8 x i1> @llvm.[[TARGET]].isnan.v8f32 +// CHECK: ret <8 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool4x2 test_isnan_double4x2(double4x2 p0) { return isnan(p0); } +// CHECK: define [[FNATTRS]] <12 x i1> @ +// CHECK: %hlsl.isnan = call <12 x i1> @llvm.[[TARGET]].isnan.v12f32 +// CHECK: ret <12 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool4x3 test_isnan_double4x3(double4x3 p0) { return isnan(p0); } +// CHECK: define [[FNATTRS]] <16 x i1> @ +// CHECK: %hlsl.isnan = call <16 x i1> @llvm.[[TARGET]].isnan.v16f32 +// CHECK: ret <16 x i1> %hlsl.isnan +// expected-warning@+1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}} +bool4x4 test_isnan_double4x4(double4x4 p0) { return isnan(p0); } diff --git a/clang/test/CodeGenHLSL/builtins/isnan.hlsl b/clang/test/CodeGenHLSL/builtins/isnan.hlsl index cca3863557229..f52c508309f25 100644 --- a/clang/test/CodeGenHLSL/builtins/isnan.hlsl +++ b/clang/test/CodeGenHLSL/builtins/isnan.hlsl @@ -60,3 +60,164 @@ bool3 test_isnan_float3(float3 p0) { return isnan(p0); } // CHECK: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f32 // CHECK: ret <4 x i1> %hlsl.isnan bool4 test_isnan_float4(float4 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <3 x i1> @ +// CHECK: %hlsl.isnan = call <3 x i1> @llvm.[[ICF]].isnan.v3f32 +// CHECK: ret <3 x i1> %hlsl.isnan +bool1x3 test_isnan_float1x3(float1x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// CHECK: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +bool1x4 test_isnan_float1x4(float1x4 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <2 x i1> @ +// CHECK: %hlsl.isnan = call <2 x i1> @llvm.[[ICF]].isnan.v2f32 +// CHECK: ret <2 x i1> %hlsl.isnan +bool2x1 test_isnan_float2x1(float2x1 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// CHECK: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +bool2x2 test_isnan_float2x2(float2x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <6 x i1> @ +// CHECK: %hlsl.isnan = call <6 x i1> @llvm.[[ICF]].isnan.v6f32 +// CHECK: ret <6 x i1> %hlsl.isnan +bool2x3 test_isnan_float2x3(float2x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <8 x i1> @ +// CHECK: %hlsl.isnan = call <8 x i1> @llvm.[[ICF]].isnan.v8f32 +// CHECK: ret <8 x i1> %hlsl.isnan +bool2x4 test_isnan_float2x4(float2x4 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <3 x i1> @ +// CHECK: %hlsl.isnan = call <3 x i1> @llvm.[[ICF]].isnan.v3f32 +// CHECK: ret <3 x i1> %hlsl.isnan +bool3x1 test_isnan_float3x1(float3x1 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <6 x i1> @ +// CHECK: %hlsl.isnan = call <6 x i1> @llvm.[[ICF]].isnan.v6f32 +// CHECK: ret <6 x i1> %hlsl.isnan +bool3x2 test_isnan_float3x2(float3x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <9 x i1> @ +// CHECK: %hlsl.isnan = call <9 x i1> @llvm.[[ICF]].isnan.v9f32 +// CHECK: ret <9 x i1> %hlsl.isnan +bool3x3 test_isnan_float3x3(float3x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <12 x i1> @ +// CHECK: %hlsl.isnan = call <12 x i1> @llvm.[[ICF]].isnan.v12f32 +// CHECK: ret <12 x i1> %hlsl.isnan +bool3x4 test_isnan_float3x4(float3x4 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// CHECK: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +bool4x1 test_isnan_float4x1(float4x1 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <8 x i1> @ +// CHECK: %hlsl.isnan = call <8 x i1> @llvm.[[ICF]].isnan.v8f32 +// CHECK: ret <8 x i1> %hlsl.isnan +bool4x2 test_isnan_float4x2(float4x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <12 x i1> @ +// CHECK: %hlsl.isnan = call <12 x i1> @llvm.[[ICF]].isnan.v12f32 +// CHECK: ret <12 x i1> %hlsl.isnan +bool4x3 test_isnan_float4x3(float4x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <16 x i1> @ +// CHECK: %hlsl.isnan = call <16 x i1> @llvm.[[ICF]].isnan.v16f32 +// CHECK: ret <16 x i1> %hlsl.isnan +bool4x4 test_isnan_float4x4(float4x4 p0) { return isnan(p0); } + + +// CHECK: define hidden [[FN_TYPE]]noundef <2 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <2 x i1> @llvm.[[ICF]].isnan.v2f16 +// NO_HALF: %hlsl.isnan = call <2 x i1> @llvm.[[ICF]].isnan.v2f32 +// CHECK: ret <2 x i1> %hlsl.isnan +bool1x2 test_isnan_half1x2(half1x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <3 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <3 x i1> @llvm.[[ICF]].isnan.v3f16 +// NO_HALF: %hlsl.isnan = call <3 x i1> @llvm.[[ICF]].isnan.v3f32 +// CHECK: ret <3 x i1> %hlsl.isnan +bool1x3 test_isnan_half1x3(half1x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f16 +// NO_HALF: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +bool1x4 test_isnan_half1x4(half1x4 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <2 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <2 x i1> @llvm.[[ICF]].isnan.v2f16 +// NO_HALF: %hlsl.isnan = call <2 x i1> @llvm.[[ICF]].isnan.v2f32 +// CHECK: ret <2 x i1> %hlsl.isnan +bool2x1 test_isnan_half2x1(half2x1 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f16 +// NO_HALF: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +bool2x2 test_isnan_half2x2(half2x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <6 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <6 x i1> @llvm.[[ICF]].isnan.v6f16 +// NO_HALF: %hlsl.isnan = call <6 x i1> @llvm.[[ICF]].isnan.v6f32 +// CHECK: ret <6 x i1> %hlsl.isnan +bool2x3 test_isnan_half2x3(half2x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <8 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <8 x i1> @llvm.[[ICF]].isnan.v8f16 +// NO_HALF: %hlsl.isnan = call <8 x i1> @llvm.[[ICF]].isnan.v8f32 +// CHECK: ret <8 x i1> %hlsl.isnan +bool2x4 test_isnan_half2x4(half2x4 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <3 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <3 x i1> @llvm.[[ICF]].isnan.v3f16 +// NO_HALF: %hlsl.isnan = call <3 x i1> @llvm.[[ICF]].isnan.v3f32 +// CHECK: ret <3 x i1> %hlsl.isnan +bool3x1 test_isnan_half3x1(half3x1 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <6 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <6 x i1> @llvm.[[ICF]].isnan.v6f16 +// NO_HALF: %hlsl.isnan = call <6 x i1> @llvm.[[ICF]].isnan.v6f32 +// CHECK: ret <6 x i1> %hlsl.isnan +bool3x2 test_isnan_half3x2(half3x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <9 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <9 x i1> @llvm.[[ICF]].isnan.v9f16 +// NO_HALF: %hlsl.isnan = call <9 x i1> @llvm.[[ICF]].isnan.v9f32 +// CHECK: ret <9 x i1> %hlsl.isnan +bool3x3 test_isnan_half3x3(half3x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <12 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <12 x i1> @llvm.[[ICF]].isnan.v12f16 +// NO_HALF: %hlsl.isnan = call <12 x i1> @llvm.[[ICF]].isnan.v12f32 +// CHECK: ret <12 x i1> %hlsl.isnan +bool3x4 test_isnan_half3x4(half3x4 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f16 +// NO_HALF: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +bool4x1 test_isnan_half4x1(half4x1 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <8 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <8 x i1> @llvm.[[ICF]].isnan.v8f16 +// NO_HALF: %hlsl.isnan = call <8 x i1> @llvm.[[ICF]].isnan.v8f32 +// CHECK: ret <8 x i1> %hlsl.isnan +bool4x2 test_isnan_half4x2(half4x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <12 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <12 x i1> @llvm.[[ICF]].isnan.v12f16 +// NO_HALF: %hlsl.isnan = call <12 x i1> @llvm.[[ICF]].isnan.v12f32 +// CHECK: ret <12 x i1> %hlsl.isnan +bool4x3 test_isnan_half4x3(half4x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <16 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <16 x i1> @llvm.[[ICF]].isnan.v16f16 +// NO_HALF: %hlsl.isnan = call <16 x i1> @llvm.[[ICF]].isnan.v16f32 +// CHECK: ret <16 x i1> %hlsl.isnan +bool4x4 test_isnan_half4x4(half4x4 p0) { return isnan(p0); } diff --git a/clang/test/CodeGenHLSL/builtins/isnan_mat.hlsl b/clang/test/CodeGenHLSL/builtins/isnan_mat.hlsl new file mode 100644 index 0000000000000..d354e0aed55e5 --- /dev/null +++ b/clang/test/CodeGenHLSL/builtins/isnan_mat.hlsl @@ -0,0 +1,183 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type -fnative-int16-type \ +// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ +// RUN: --check-prefixes=CHECK,DXCHECK,NATIVE_HALF +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %s --check-prefixes=CHECK,DXCHECK,NO_HALF + +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: spirv-unknown-vulkan-compute %s -fnative-half-type -fnative-int16-type \ +// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ +// RUN: --check-prefixes=CHECK,SPVCHECK,NATIVE_HALF +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %s --check-prefixes=CHECK,SPVCHECK,NO_HALF + +// DXCHECK: define hidden [[FN_TYPE:]]noundef <2 x i1> @ +// SPVCHECK: define hidden [[FN_TYPE:spir_func ]]noundef <2 x i1> @ +// DXCHECK: %hlsl.isnan = call <2 x i1> @llvm.[[ICF:dx]].isnan.v2f32( +// SPVCHECK: %hlsl.isnan = call <2 x i1> @llvm.[[ICF:spv]].isnan.v2f32( +// CHECK: ret <2 x i1> %hlsl.isnan +bool1x2 test_isnan_float1x2(float1x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <3 x i1> @ +// CHECK: %hlsl.isnan = call <3 x i1> @llvm.[[ICF]].isnan.v3f32 +// CHECK: ret <3 x i1> %hlsl.isnan +bool1x3 test_isnan_float1x3(float1x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// CHECK: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +bool1x4 test_isnan_float1x4(float1x4 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <2 x i1> @ +// CHECK: %hlsl.isnan = call <2 x i1> @llvm.[[ICF]].isnan.v2f32 +// CHECK: ret <2 x i1> %hlsl.isnan +bool2x1 test_isnan_float2x1(float2x1 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// CHECK: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +bool2x2 test_isnan_float2x2(float2x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <6 x i1> @ +// CHECK: %hlsl.isnan = call <6 x i1> @llvm.[[ICF]].isnan.v6f32 +// CHECK: ret <6 x i1> %hlsl.isnan +bool2x3 test_isnan_float2x3(float2x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <8 x i1> @ +// CHECK: %hlsl.isnan = call <8 x i1> @llvm.[[ICF]].isnan.v8f32 +// CHECK: ret <8 x i1> %hlsl.isnan +bool2x4 test_isnan_float2x4(float2x4 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <3 x i1> @ +// CHECK: %hlsl.isnan = call <3 x i1> @llvm.[[ICF]].isnan.v3f32 +// CHECK: ret <3 x i1> %hlsl.isnan +bool3x1 test_isnan_float3x1(float3x1 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <6 x i1> @ +// CHECK: %hlsl.isnan = call <6 x i1> @llvm.[[ICF]].isnan.v6f32 +// CHECK: ret <6 x i1> %hlsl.isnan +bool3x2 test_isnan_float3x2(float3x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <9 x i1> @ +// CHECK: %hlsl.isnan = call <9 x i1> @llvm.[[ICF]].isnan.v9f32 +// CHECK: ret <9 x i1> %hlsl.isnan +bool3x3 test_isnan_float3x3(float3x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <12 x i1> @ +// CHECK: %hlsl.isnan = call <12 x i1> @llvm.[[ICF]].isnan.v12f32 +// CHECK: ret <12 x i1> %hlsl.isnan +bool3x4 test_isnan_float3x4(float3x4 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// CHECK: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +bool4x1 test_isnan_float4x1(float4x1 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <8 x i1> @ +// CHECK: %hlsl.isnan = call <8 x i1> @llvm.[[ICF]].isnan.v8f32 +// CHECK: ret <8 x i1> %hlsl.isnan +bool4x2 test_isnan_float4x2(float4x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <12 x i1> @ +// CHECK: %hlsl.isnan = call <12 x i1> @llvm.[[ICF]].isnan.v12f32 +// CHECK: ret <12 x i1> %hlsl.isnan +bool4x3 test_isnan_float4x3(float4x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <16 x i1> @ +// CHECK: %hlsl.isnan = call <16 x i1> @llvm.[[ICF]].isnan.v16f32 +// CHECK: ret <16 x i1> %hlsl.isnan +bool4x4 test_isnan_float4x4(float4x4 p0) { return isnan(p0); } + + +// CHECK: define hidden [[FN_TYPE]]noundef <2 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <2 x i1> @llvm.[[ICF]].isnan.v2f16 +// NO_HALF: %hlsl.isnan = call <2 x i1> @llvm.[[ICF]].isnan.v2f32 +// CHECK: ret <2 x i1> %hlsl.isnan +bool1x2 test_isnan_half1x2(half1x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <3 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <3 x i1> @llvm.[[ICF]].isnan.v3f16 +// NO_HALF: %hlsl.isnan = call <3 x i1> @llvm.[[ICF]].isnan.v3f32 +// CHECK: ret <3 x i1> %hlsl.isnan +bool1x3 test_isnan_half1x3(half1x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f16 +// NO_HALF: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +bool1x4 test_isnan_half1x4(half1x4 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <2 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <2 x i1> @llvm.[[ICF]].isnan.v2f16 +// NO_HALF: %hlsl.isnan = call <2 x i1> @llvm.[[ICF]].isnan.v2f32 +// CHECK: ret <2 x i1> %hlsl.isnan +bool2x1 test_isnan_half2x1(half2x1 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f16 +// NO_HALF: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +bool2x2 test_isnan_half2x2(half2x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <6 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <6 x i1> @llvm.[[ICF]].isnan.v6f16 +// NO_HALF: %hlsl.isnan = call <6 x i1> @llvm.[[ICF]].isnan.v6f32 +// CHECK: ret <6 x i1> %hlsl.isnan +bool2x3 test_isnan_half2x3(half2x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <8 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <8 x i1> @llvm.[[ICF]].isnan.v8f16 +// NO_HALF: %hlsl.isnan = call <8 x i1> @llvm.[[ICF]].isnan.v8f32 +// CHECK: ret <8 x i1> %hlsl.isnan +bool2x4 test_isnan_half2x4(half2x4 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <3 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <3 x i1> @llvm.[[ICF]].isnan.v3f16 +// NO_HALF: %hlsl.isnan = call <3 x i1> @llvm.[[ICF]].isnan.v3f32 +// CHECK: ret <3 x i1> %hlsl.isnan +bool3x1 test_isnan_half3x1(half3x1 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <6 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <6 x i1> @llvm.[[ICF]].isnan.v6f16 +// NO_HALF: %hlsl.isnan = call <6 x i1> @llvm.[[ICF]].isnan.v6f32 +// CHECK: ret <6 x i1> %hlsl.isnan +bool3x2 test_isnan_half3x2(half3x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <9 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <9 x i1> @llvm.[[ICF]].isnan.v9f16 +// NO_HALF: %hlsl.isnan = call <9 x i1> @llvm.[[ICF]].isnan.v9f32 +// CHECK: ret <9 x i1> %hlsl.isnan +bool3x3 test_isnan_half3x3(half3x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <12 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <12 x i1> @llvm.[[ICF]].isnan.v12f16 +// NO_HALF: %hlsl.isnan = call <12 x i1> @llvm.[[ICF]].isnan.v12f32 +// CHECK: ret <12 x i1> %hlsl.isnan +bool3x4 test_isnan_half3x4(half3x4 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <4 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f16 +// NO_HALF: %hlsl.isnan = call <4 x i1> @llvm.[[ICF]].isnan.v4f32 +// CHECK: ret <4 x i1> %hlsl.isnan +bool4x1 test_isnan_half4x1(half4x1 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <8 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <8 x i1> @llvm.[[ICF]].isnan.v8f16 +// NO_HALF: %hlsl.isnan = call <8 x i1> @llvm.[[ICF]].isnan.v8f32 +// CHECK: ret <8 x i1> %hlsl.isnan +bool4x2 test_isnan_half4x2(half4x2 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <12 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <12 x i1> @llvm.[[ICF]].isnan.v12f16 +// NO_HALF: %hlsl.isnan = call <12 x i1> @llvm.[[ICF]].isnan.v12f32 +// CHECK: ret <12 x i1> %hlsl.isnan +bool4x3 test_isnan_half4x3(half4x3 p0) { return isnan(p0); } + +// CHECK: define hidden [[FN_TYPE]]noundef <16 x i1> @ +// NATIVE_HALF: %hlsl.isnan = call <16 x i1> @llvm.[[ICF]].isnan.v16f16 +// NO_HALF: %hlsl.isnan = call <16 x i1> @llvm.[[ICF]].isnan.v16f32 +// CHECK: ret <16 x i1> %hlsl.isnan +bool4x4 test_isnan_half4x4(half4x4 p0) { return isnan(p0); } diff --git a/clang/test/SemaHLSL/BuiltIns/isinf-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/isinf-errors.hlsl index a32bc9628a295..7ffc750f2d941 100644 --- a/clang/test/SemaHLSL/BuiltIns/isinf-errors.hlsl +++ b/clang/test/SemaHLSL/BuiltIns/isinf-errors.hlsl @@ -25,14 +25,3 @@ bool2 builtin_isinf_int2_to_float2_promotion(int2 p1) { return __builtin_hlsl_elementwise_isinf(p1); // expected-error@-1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'int2' (aka 'vector<int, 2>'))}} } - -// builtins are variadic functions and so are subject to DefaultVariadicArgumentPromotion -half builtin_isinf_half_scalar (half p0) { - return __builtin_hlsl_elementwise_isinf (p0); - // expected-error@-1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'double')}} -} - -float builtin_isinf_float_scalar ( float p0) { - return __builtin_hlsl_elementwise_isinf (p0); - // expected-error@-1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'double')}} -} diff --git a/clang/test/SemaHLSL/BuiltIns/isinf-errors_mat.hlsl b/clang/test/SemaHLSL/BuiltIns/isinf-errors_mat.hlsl new file mode 100644 index 0000000000000..70d2a68ca16dd --- /dev/null +++ b/clang/test/SemaHLSL/BuiltIns/isinf-errors_mat.hlsl @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -fnative-int16-type -emit-llvm-only -disable-llvm-passes -verify + +bool2x2 test_builtin_isinf_double_matrix(double2x2 p0) { + return __builtin_hlsl_elementwise_isinf(p0); + // expected-error@-1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'double2x2' (aka 'matrix<double, 2, 2>'))}} +} diff --git a/clang/test/SemaHLSL/BuiltIns/isnan-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/isnan-errors.hlsl index 625c415f91de2..1af44ec2dd38f 100644 --- a/clang/test/SemaHLSL/BuiltIns/isnan-errors.hlsl +++ b/clang/test/SemaHLSL/BuiltIns/isnan-errors.hlsl @@ -25,14 +25,3 @@ bool2 builtin_isnan_int2_to_float2_promotion(int2 p1) { return __builtin_hlsl_elementwise_isnan(p1); // expected-error@-1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'int2' (aka 'vector<int, 2>'))}} } - -// builtins are variadic functions and so are subject to DefaultVariadicArgumentPromotion -half builtin_isnan_half_scalar (half p0) { - return __builtin_hlsl_elementwise_isnan (p0); - // expected-error@-1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'double')}} -} - -float builtin_isnan_float_scalar ( float p0) { - return __builtin_hlsl_elementwise_isnan (p0); - // expected-error@-1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'double')}} -} diff --git a/clang/test/SemaHLSL/BuiltIns/isnan-errors_mat.hlsl b/clang/test/SemaHLSL/BuiltIns/isnan-errors_mat.hlsl new file mode 100644 index 0000000000000..b8728c78bab22 --- /dev/null +++ b/clang/test/SemaHLSL/BuiltIns/isnan-errors_mat.hlsl @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -fnative-int16-type -emit-llvm-only -disable-llvm-passes -verify + +bool2x2 test_builtin_isnan_double_matrix(double2x2 p0) { + return __builtin_hlsl_elementwise_isnan(p0); + // expected-error@-1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'double2x2' (aka 'matrix<double, 2, 2>'))}} +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
