[clang] [HLSL] Adds matrix support for isnan(). (PR #195586)

via cfe-commits cfe-commits at lists.llvm.org
Sun May 3 22:43:14 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang

Author: Dan Brown (danbrown-amd)

<details>
<summary>Changes</summary>

Addresses #<!-- -->184483.

---
Full diff: https://github.com/llvm/llvm-project/pull/195586.diff


7 Files Affected:

- (modified) clang/include/clang/Basic/HLSLIntrinsics.td (-1) 
- (modified) clang/lib/CodeGen/CGHLSLBuiltins.cpp (+7-3) 
- (modified) clang/lib/Headers/hlsl/hlsl_compat_overloads.h (+15) 
- (modified) clang/lib/Sema/SemaChecking.cpp (+2-1) 
- (modified) clang/lib/Sema/SemaHLSL.cpp (+11-4) 
- (modified) clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl (+60) 
- (modified) clang/test/CodeGenHLSL/builtins/isnan.hlsl (+167) 


``````````diff
diff --git a/clang/include/clang/Basic/HLSLIntrinsics.td b/clang/include/clang/Basic/HLSLIntrinsics.td
index 144b27cab7398..0b01a588c0968 100644
--- a/clang/include/clang/Basic/HLSLIntrinsics.td
+++ b/clang/include/clang/Basic/HLSLIntrinsics.td
@@ -1101,7 +1101,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/CGHLSLBuiltins.cpp b/clang/lib/CodeGen/CGHLSLBuiltins.cpp
index b82a237ecefca..7f6c1cde5b826 100644
--- a/clang/lib/CodeGen/CGHLSLBuiltins.cpp
+++ b/clang/lib/CodeGen/CGHLSLBuiltins.cpp
@@ -1131,9 +1131,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 ee243abef6a41..3f7acb6859ccc 100644
--- a/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
+++ b/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
@@ -360,6 +360,21 @@ constexpr bool isnan(double V) { return isnan((float)V); }
 constexpr bool2 isnan(double2 V) { return isnan((float2)V); }
 constexpr bool3 isnan(double3 V) { return isnan((float3)V); }
 constexpr bool4 isnan(double4 V) { return isnan((float4)V); }
+constexpr bool1x2 isnan(double1x2 V) { return isnan((float1x2)V); }
+constexpr bool1x3 isnan(double1x3 V) { return isnan((float1x3)V); }
+constexpr bool1x4 isnan(double1x4 V) { return isnan((float1x4)V); }
+constexpr bool2x1 isnan(double2x1 V) { return isnan((float2x1)V); }
+constexpr bool2x2 isnan(double2x2 V) { return isnan((float2x2)V); }
+constexpr bool2x3 isnan(double2x3 V) { return isnan((float2x3)V); }
+constexpr bool2x4 isnan(double2x4 V) { return isnan((float2x4)V); }
+constexpr bool3x1 isnan(double3x1 V) { return isnan((float3x1)V); }
+constexpr bool3x2 isnan(double3x2 V) { return isnan((float3x2)V); }
+constexpr bool3x3 isnan(double3x3 V) { return isnan((float3x3)V); }
+constexpr bool3x4 isnan(double3x4 V) { return isnan((float3x4)V); }
+constexpr bool4x1 isnan(double4x1 V) { return isnan((float4x1)V); }
+constexpr bool4x2 isnan(double4x2 V) { return isnan((float4x2)V); }
+constexpr bool4x3 isnan(double4x3 V) { return isnan((float4x3)V); }
+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 eb957df6f1e97..a68686f11c260 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2199,7 +2199,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 aba1c5072a5fc..0c039be8d3b44 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -3221,6 +3221,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)
@@ -3235,6 +3237,8 @@ static bool CheckFloatOrHalfRepresentation(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->isHalfType() && !BaseType->isFloat32Type())
     return S->Diag(Loc, diag::err_builtin_invalid_arg_type)
@@ -3249,8 +3253,8 @@ static bool CheckAnyDoubleRepresentation(Sema *S, SourceLocation Loc,
   clang::QualType BaseType =
       PassedType->isVectorType()
           ? PassedType->castAs<clang::VectorType>()->getElementType()
-      : PassedType->isMatrixType()
-          ? PassedType->castAs<clang::MatrixType>()->getElementType()
+      : PassedType->getAs<clang::ConstantMatrixType>()
+          ? PassedType->castAs<clang::ConstantMatrixType>()->getElementType()
           : PassedType;
   if (!BaseType->isDoubleType()) {
     // FIXME: adopt standard `err_builtin_invalid_arg_type` instead of using
@@ -3339,10 +3343,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/isnan-overloads.hlsl b/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl
index a0c3eee5da636..6ff22dd2f713f 100644
--- a/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl
@@ -18,3 +18,63 @@ bool3 test_isnan_double3(double3 p0) { return isnan(p0); }
 // CHECK: %hlsl.isnan = call <4 x i1> @llvm.dx.isnan.v4f32
 // CHECK: ret <4 x i1> %hlsl.isnan
 bool4 test_isnan_double4(double4 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <2 x i1> @
+// CHECK: %hlsl.isnan = call <2 x i1> @llvm.dx.isnan.v2f32
+// CHECK: ret <2 x i1> %hlsl.isnan
+bool1x2 test_isnan_double1x2(double1x2 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <3 x i1> @
+// CHECK: %hlsl.isnan = call <3 x i1> @llvm.dx.isnan.v3f32
+// CHECK: ret <3 x i1> %hlsl.isnan
+bool1x3 test_isnan_double1x3(double1x3 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <4 x i1> @
+// CHECK: %hlsl.isnan = call <4 x i1> @llvm.dx.isnan.v4f32
+// CHECK: ret <4 x i1> %hlsl.isnan
+bool1x4 test_isnan_double1x4(double1x4 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <2 x i1> @
+// CHECK: %hlsl.isnan = call <2 x i1> @llvm.dx.isnan.v2f32
+// CHECK: ret <2 x i1> %hlsl.isnan
+bool2x1 test_isnan_double2x1(double2x1 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <4 x i1> @
+// CHECK: %hlsl.isnan = call <4 x i1> @llvm.dx.isnan.v4f32
+// CHECK: ret <4 x i1> %hlsl.isnan
+bool2x2 test_isnan_double2x2(double2x2 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <6 x i1> @
+// CHECK: %hlsl.isnan = call <6 x i1> @llvm.dx.isnan.v6f32
+// CHECK: ret <6 x i1> %hlsl.isnan
+bool2x3 test_isnan_double2x3(double2x3 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <8 x i1> @
+// CHECK: %hlsl.isnan = call <8 x i1> @llvm.dx.isnan.v8f32
+// CHECK: ret <8 x i1> %hlsl.isnan
+bool2x4 test_isnan_double2x4(double2x4 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <3 x i1> @
+// CHECK: %hlsl.isnan = call <3 x i1> @llvm.dx.isnan.v3f32
+// CHECK: ret <3 x i1> %hlsl.isnan
+bool3x1 test_isnan_double3x1(double3x1 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <6 x i1> @
+// CHECK: %hlsl.isnan = call <6 x i1> @llvm.dx.isnan.v6f32
+// CHECK: ret <6 x i1> %hlsl.isnan
+bool3x2 test_isnan_double3x2(double3x2 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <9 x i1> @
+// CHECK: %hlsl.isnan = call <9 x i1> @llvm.dx.isnan.v9f32
+// CHECK: ret <9 x i1> %hlsl.isnan
+bool3x3 test_isnan_double3x3(double3x3 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <12 x i1> @
+// CHECK: %hlsl.isnan = call <12 x i1> @llvm.dx.isnan.v12f32
+// CHECK: ret <12 x i1> %hlsl.isnan
+bool3x4 test_isnan_double3x4(double3x4 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <4 x i1> @
+// CHECK: %hlsl.isnan = call <4 x i1> @llvm.dx.isnan.v4f32
+// CHECK: ret <4 x i1> %hlsl.isnan
+bool4x1 test_isnan_double4x1(double4x1 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <8 x i1> @
+// CHECK: %hlsl.isnan = call <8 x i1> @llvm.dx.isnan.v8f32
+// CHECK: ret <8 x i1> %hlsl.isnan
+bool4x2 test_isnan_double4x2(double4x2 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <12 x i1> @
+// CHECK: %hlsl.isnan = call <12 x i1> @llvm.dx.isnan.v12f32
+// CHECK: ret <12 x i1> %hlsl.isnan
+bool4x3 test_isnan_double4x3(double4x3 p0) { return isnan(p0); }
+// CHECK: define {{.*}}hidden noundef <16 x i1> @
+// CHECK: %hlsl.isnan = call <16 x i1> @llvm.dx.isnan.v16f32
+// CHECK: ret <16 x i1> %hlsl.isnan
+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..a128d352a1a31 100644
--- a/clang/test/CodeGenHLSL/builtins/isnan.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isnan.hlsl
@@ -60,3 +60,170 @@ 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 <2 x i1> @
+// CHECK: %hlsl.isnan = call <2 x i1> @llvm.[[ICF]].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); }

``````````

</details>


https://github.com/llvm/llvm-project/pull/195586


More information about the cfe-commits mailing list