[clang] [HLSL] Add matrix support for isnan() and isinf() (PR #195586)

Dan Brown via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 6 20:13:16 PDT 2026


https://github.com/danbrown-amd updated https://github.com/llvm/llvm-project/pull/195586

>From ab5bd08afa5b87a984687fed1b1ba8ed47b11b53 Mon Sep 17 00:00:00 2001
From: Dan Brown <danbrown at amd.com>
Date: Sun, 3 May 2026 23:01:34 -0600
Subject: [PATCH 01/17] [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 ea8dbb96fab56..e9034e59f92b3 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -5697,13 +5697,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 56b031dbfa045..17d85dbd16d9b 100644
--- a/clang/include/clang/Basic/HLSLIntrinsics.td
+++ b/clang/include/clang/Basic/HLSLIntrinsics.td
@@ -1082,7 +1082,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.
@@ -1097,7 +1096,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 9201e40bc13a1..53e633eb97e54 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2316,6 +2316,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 45cb6de5b17c6..86ed0da28d07b 100644
--- a/clang/lib/CodeGen/CGHLSLBuiltins.cpp
+++ b/clang/lib/CodeGen/CGHLSLBuiltins.cpp
@@ -1169,9 +1169,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");
@@ -1184,9 +1188,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 3a75050129aa5..d8e1e453a5b13 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 0db040ed90e3f..f2f38c84dc5f8 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2352,7 +2352,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 3fda2dbc0ffc6..84a13690f291a 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -3384,6 +3384,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)
@@ -3518,10 +3520,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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 at +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 88907cef0bd07..546f45373e60d 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 at -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 at -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 at -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 at -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 at -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 at -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 at -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 at -1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'double2x2' (aka 'matrix<double, 2, 2>'))}}
+}

>From e6396e2a4df94ba164f28db60087bcfd2c652058 Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Thu, 28 May 2026 16:18:06 -0600
Subject: [PATCH 02/17] [HLSL] Fixes crash on bool matrix single subscript.

VisitMatrixSingleSubscriptExpr used ConvertTypeForMem to determine the element type for the result vector, but Visit(E->getBase()) returns a value in register representation. For bool matrices this causes a type mismatch: the flat matrix value has element type i1 while the result vector is built with element type i32, causing an assertion failure in InsertElementInst ("Invalid insertelement instruction operands!").  Fix by using ConvertType instead of ConvertTypeForMem, so the element type of the result vector matches the register type of the extracted elements. The existing EmitFromMemory call on the result handles any further conversion.

Assisted-by: Claude Sonnet 4
---
 clang/lib/CodeGen/CGExprScalar.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 67014904ffb37..e9f461c05aa2b 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2223,7 +2223,7 @@ Value *ScalarExprEmitter::VisitMatrixSingleSubscriptExpr(
     MB.CreateIndexAssumption(RowIdx, NumRows);
 
   Value *FlatMatrix = Visit(E->getBase());
-  llvm::Type *ElemTy = CGF.ConvertTypeForMem(MatrixTy->getElementType());
+  llvm::Type *ElemTy = CGF.ConvertType(MatrixTy->getElementType());
   auto *ResultTy = llvm::FixedVectorType::get(ElemTy, NumColumns);
   Value *RowVec = llvm::PoisonValue::get(ResultTy);
 

>From dda5894758b215434243d4befb4a14d1a1e9d650 Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Sun, 31 May 2026 21:41:36 -0600
Subject: [PATCH 03/17] Updates tests in accordance with previous commit.

---
 .../MatrixSingleSubscriptGetter.hlsl          | 51 +++++++---------
 .../MatrixToAndFromVectorConstructors.hlsl    | 25 ++++----
 .../BasicFeatures/VectorElementwiseCast.hlsl  | 24 ++++----
 clang/test/CodeGenHLSL/BoolMatrix.hlsl        | 44 ++++----------
 clang/test/CodeGenHLSL/builtins/and_mat.hlsl  | 60 +++++++++----------
 clang/test/CodeGenHLSL/builtins/or.hlsl       | 60 +++++++++----------
 .../test/CodeGenHLSL/builtins/transpose.hlsl  |  5 +-
 7 files changed, 124 insertions(+), 145 deletions(-)

diff --git a/clang/test/CodeGenHLSL/BasicFeatures/MatrixSingleSubscriptGetter.hlsl b/clang/test/CodeGenHLSL/BasicFeatures/MatrixSingleSubscriptGetter.hlsl
index 07cad8214e284..baac77b2e0fad 100644
--- a/clang/test/CodeGenHLSL/BasicFeatures/MatrixSingleSubscriptGetter.hlsl
+++ b/clang/test/CodeGenHLSL/BasicFeatures/MatrixSingleSubscriptGetter.hlsl
@@ -4,7 +4,6 @@
 // CHECK-LABEL: define hidden noundef nofpclass(nan inf) <4 x float> @_Z24getFloatVecMatrixDynamicu11matrix_typeILm4ELm4EfEi(
 // CHECK-SAME: <16 x float> noundef nofpclass(nan inf) [[M:%.*]], i32 noundef [[INDEX:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [4 x <4 x float>], align 4
 // CHECK-NEXT:    [[INDEX_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    store <16 x float> [[M]], ptr [[M_ADDR]], align 4
@@ -32,7 +31,6 @@ float4 getFloatVecMatrixDynamic(float4x4 M, int index) {
 // CHECK-LABEL: define hidden noundef nofpclass(nan inf) float @_Z27getFloatScalarMatrixDynamicu11matrix_typeILm2ELm1EfEi(
 // CHECK-SAME: <2 x float> noundef nofpclass(nan inf) [[M:%.*]], i32 noundef [[INDEX:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [1 x <2 x float>], align 4
 // CHECK-NEXT:    [[INDEX_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    store <2 x float> [[M]], ptr [[M_ADDR]], align 4
@@ -52,7 +50,6 @@ float getFloatScalarMatrixDynamic(float2x1 M, int index) {
 // CHECK-LABEL: define hidden noundef nofpclass(nan inf) float @_Z28getFloatScalarMatrixConstantu11matrix_typeILm2ELm1EfE(
 // CHECK-SAME: <2 x float> noundef nofpclass(nan inf) [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [1 x <2 x float>], align 4
 // CHECK-NEXT:    store <2 x float> [[M]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load <2 x float>, ptr [[M_ADDR]], align 4
@@ -68,7 +65,6 @@ float getFloatScalarMatrixConstant(float2x1 M) {
 // CHECK-LABEL: define hidden noundef nofpclass(nan inf) float @_Z29getFloatScalarMatrixConstant2u11matrix_typeILm2ELm1EfE(
 // CHECK-SAME: <2 x float> noundef nofpclass(nan inf) [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [1 x <2 x float>], align 4
 // CHECK-NEXT:    store <2 x float> [[M]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load <2 x float>, ptr [[M_ADDR]], align 4
@@ -84,7 +80,6 @@ float getFloatScalarMatrixConstant2(float2x1 M) {
 // CHECK-LABEL: define hidden noundef <4 x i32> @_Z19getIntMatrixDynamicu11matrix_typeILm4ELm4EiEi(
 // CHECK-SAME: <16 x i32> noundef [[M:%.*]], i32 noundef [[INDEX:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [4 x <4 x i32>], align 4
 // CHECK-NEXT:    [[INDEX_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    store <16 x i32> [[M]], ptr [[M_ADDR]], align 4
@@ -112,7 +107,6 @@ int4 getIntMatrixDynamic(int4x4 M, int index) {
 // CHECK-LABEL: define hidden noundef nofpclass(nan inf) <4 x float> @_Z22AddFloatMatrixConstantu11matrix_typeILm4ELm4EfE(
 // CHECK-SAME: <16 x float> noundef nofpclass(nan inf) [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [4 x <4 x float>], align 4
 // CHECK-NEXT:    store <16 x float> [[M]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load <16 x float>, ptr [[M_ADDR]], align 4
@@ -163,7 +157,6 @@ float4 AddFloatMatrixConstant(float4x4 M) {
 // CHECK-LABEL: define hidden noundef <4 x i32> @_Z20AddIntMatrixConstantu11matrix_typeILm4ELm4EiE(
 // CHECK-SAME: <16 x i32> noundef [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [4 x <4 x i32>], align 4
 // CHECK-NEXT:    store <16 x i32> [[M]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load <16 x i32>, ptr [[M_ADDR]], align 4
@@ -214,7 +207,6 @@ int4 AddIntMatrixConstant(int4x4 M) {
 // CHECK-LABEL: define hidden noundef <3 x i1> @_Z23getBoolVecMatrixDynamicu11matrix_typeILm2ELm3EbEi(
 // CHECK-SAME: <6 x i1> noundef [[M:%.*]], i32 noundef [[INDEX:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [3 x <2 x i32>], align 4
 // CHECK-NEXT:    [[INDEX_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <6 x i1> [[M]] to <6 x i32>
@@ -222,16 +214,17 @@ int4 AddIntMatrixConstant(int4x4 M) {
 // CHECK-NEXT:    store i32 [[INDEX]], ptr [[INDEX_ADDR]], align 4
 // CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr [[INDEX_ADDR]], align 4
 // CHECK-NEXT:    [[TMP2:%.*]] = load <6 x i32>, ptr [[M_ADDR]], align 4
+// CHECK-NEXT:    [[TRUNC:%.*]] = trunc <6 x i32> [[TMP2]] to <6 x i1>
 // CHECK-NEXT:    [[TMP3:%.*]] = add i32 0, [[TMP1]]
-// CHECK-NEXT:    [[MATRIX_ELEM:%.*]] = extractelement <6 x i32> [[TMP2]], i32 [[TMP3]]
-// CHECK-NEXT:    [[MATRIX_ROW_INS:%.*]] = insertelement <3 x i32> poison, i32 [[MATRIX_ELEM]], i32 0
+// CHECK-NEXT:    [[MATRIX_ELEM:%.*]] = extractelement <6 x i1> [[TRUNC]], i32 [[TMP3]]
+// CHECK-NEXT:    [[MATRIX_ROW_INS:%.*]] = insertelement <3 x i1> poison, i1 [[MATRIX_ELEM]], i32 0
 // CHECK-NEXT:    [[TMP4:%.*]] = add i32 2, [[TMP1]]
-// CHECK-NEXT:    [[MATRIX_ELEM1:%.*]] = extractelement <6 x i32> [[TMP2]], i32 [[TMP4]]
-// CHECK-NEXT:    [[MATRIX_ROW_INS2:%.*]] = insertelement <3 x i32> [[MATRIX_ROW_INS]], i32 [[MATRIX_ELEM1]], i32 1
+// CHECK-NEXT:    [[MATRIX_ELEM1:%.*]] = extractelement <6 x i1> [[TRUNC]], i32 [[TMP4]]
+// CHECK-NEXT:    [[MATRIX_ROW_INS2:%.*]] = insertelement <3 x i1> [[MATRIX_ROW_INS]], i1 [[MATRIX_ELEM1]], i32 1
 // CHECK-NEXT:    [[TMP5:%.*]] = add i32 4, [[TMP1]]
-// CHECK-NEXT:    [[MATRIX_ELEM3:%.*]] = extractelement <6 x i32> [[TMP2]], i32 [[TMP5]]
-// CHECK-NEXT:    [[MATRIX_ROW_INS4:%.*]] = insertelement <3 x i32> [[MATRIX_ROW_INS2]], i32 [[MATRIX_ELEM3]], i32 2
-// CHECK-NEXT:    [[LOADEDV:%.*]] = icmp ne <3 x i32> [[MATRIX_ROW_INS4]], zeroinitializer
+// CHECK-NEXT:    [[MATRIX_ELEM3:%.*]] = extractelement <6 x i1> [[TRUNC]], i32 [[TMP5]]
+// CHECK-NEXT:    [[MATRIX_ROW_INS4:%.*]] = insertelement <3 x i1> [[MATRIX_ROW_INS2]], i1 [[MATRIX_ELEM3]], i32 2
+// CHECK-NEXT:    [[LOADEDV:%.*]] = icmp ne <3 x i1> [[MATRIX_ROW_INS4]], zeroinitializer
 // CHECK-NEXT:    ret <3 x i1> [[LOADEDV]]
 //
 bool3 getBoolVecMatrixDynamic(bool2x3 M, int index) {
@@ -241,20 +234,20 @@ bool3 getBoolVecMatrixDynamic(bool2x3 M, int index) {
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z24getBoolVecMatrixConstantu11matrix_typeILm4ELm4EbE(
 // CHECK-SAME: <16 x i1> noundef [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [4 x <4 x i32>], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <16 x i1> [[M]] to <16 x i32>
 // CHECK-NEXT:    store <16 x i32> [[TMP0]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP1:%.*]] = load <16 x i32>, ptr [[M_ADDR]], align 4
-// CHECK-NEXT:    [[MATRIX_ELEM:%.*]] = extractelement <16 x i32> [[TMP1]], i32 0
-// CHECK-NEXT:    [[MATRIX_ROW_INS:%.*]] = insertelement <4 x i32> poison, i32 [[MATRIX_ELEM]], i32 0
-// CHECK-NEXT:    [[MATRIX_ELEM1:%.*]] = extractelement <16 x i32> [[TMP1]], i32 4
-// CHECK-NEXT:    [[MATRIX_ROW_INS2:%.*]] = insertelement <4 x i32> [[MATRIX_ROW_INS]], i32 [[MATRIX_ELEM1]], i32 1
-// CHECK-NEXT:    [[MATRIX_ELEM3:%.*]] = extractelement <16 x i32> [[TMP1]], i32 8
-// CHECK-NEXT:    [[MATRIX_ROW_INS4:%.*]] = insertelement <4 x i32> [[MATRIX_ROW_INS2]], i32 [[MATRIX_ELEM3]], i32 2
-// CHECK-NEXT:    [[MATRIX_ELEM5:%.*]] = extractelement <16 x i32> [[TMP1]], i32 12
-// CHECK-NEXT:    [[MATRIX_ROW_INS6:%.*]] = insertelement <4 x i32> [[MATRIX_ROW_INS4]], i32 [[MATRIX_ELEM5]], i32 3
-// CHECK-NEXT:    [[LOADEDV:%.*]] = icmp ne <4 x i32> [[MATRIX_ROW_INS6]], zeroinitializer
+// CHECK-NEXT:    [[TRUNC:%.*]] = trunc <16 x i32> [[TMP1]] to <16 x i1>
+// CHECK-NEXT:    [[MATRIX_ELEM:%.*]] = extractelement <16 x i1> [[TRUNC]], i32 0
+// CHECK-NEXT:    [[MATRIX_ROW_INS:%.*]] = insertelement <4 x i1> poison, i1 [[MATRIX_ELEM]], i32 0
+// CHECK-NEXT:    [[MATRIX_ELEM1:%.*]] = extractelement <16 x i1> [[TRUNC]], i32 4
+// CHECK-NEXT:    [[MATRIX_ROW_INS2:%.*]] = insertelement <4 x i1> [[MATRIX_ROW_INS]], i1 [[MATRIX_ELEM1]], i32 1
+// CHECK-NEXT:    [[MATRIX_ELEM3:%.*]] = extractelement <16 x i1> [[TRUNC]], i32 8
+// CHECK-NEXT:    [[MATRIX_ROW_INS4:%.*]] = insertelement <4 x i1> [[MATRIX_ROW_INS2]], i1 [[MATRIX_ELEM3]], i32 2
+// CHECK-NEXT:    [[MATRIX_ELEM5:%.*]] = extractelement <16 x i1> [[TRUNC]], i32 12
+// CHECK-NEXT:    [[MATRIX_ROW_INS6:%.*]] = insertelement <4 x i1> [[MATRIX_ROW_INS4]], i1 [[MATRIX_ELEM5]], i32 3
+// CHECK-NEXT:    [[LOADEDV:%.*]] = icmp ne <4 x i1> [[MATRIX_ROW_INS6]], zeroinitializer
 // CHECK-NEXT:    ret <4 x i1> [[LOADEDV]]
 //
 bool4 getBoolVecMatrixConstant(bool4x4 M) {
@@ -264,14 +257,14 @@ bool4 getBoolVecMatrixConstant(bool4x4 M) {
 // CHECK-LABEL: define hidden noundef i1 @_Z27getBoolScalarMatrixConstantu11matrix_typeILm3ELm1EbE(
 // CHECK-SAME: <3 x i1> noundef [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [1 x <3 x i32>], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <3 x i1> [[M]] to <3 x i32>
 // CHECK-NEXT:    store <3 x i32> [[TMP0]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP1:%.*]] = load <3 x i32>, ptr [[M_ADDR]], align 4
-// CHECK-NEXT:    [[MATRIX_ELEM:%.*]] = extractelement <3 x i32> [[TMP1]], i32 1
-// CHECK-NEXT:    [[MATRIX_ROW_INS:%.*]] = insertelement <1 x i32> poison, i32 [[MATRIX_ELEM]], i32 0
-// CHECK-NEXT:    [[LOADEDV:%.*]] = icmp ne <1 x i32> [[MATRIX_ROW_INS]], zeroinitializer
+// CHECK-NEXT:    [[TRUNC:%.*]] = trunc <3 x i32> [[TMP1]] to <3 x i1>
+// CHECK-NEXT:    [[MATRIX_ELEM:%.*]] = extractelement <3 x i1> [[TRUNC]], i32 1
+// CHECK-NEXT:    [[MATRIX_ROW_INS:%.*]] = insertelement <1 x i1> poison, i1 [[MATRIX_ELEM]], i32 0
+// CHECK-NEXT:    [[LOADEDV:%.*]] = icmp ne <1 x i1> [[MATRIX_ROW_INS]], zeroinitializer
 // CHECK-NEXT:    [[CAST_VTRUNC:%.*]] = extractelement <1 x i1> [[LOADEDV]], i32 0
 // CHECK-NEXT:    ret i1 [[CAST_VTRUNC]]
 //
diff --git a/clang/test/CodeGenHLSL/BasicFeatures/MatrixToAndFromVectorConstructors.hlsl b/clang/test/CodeGenHLSL/BasicFeatures/MatrixToAndFromVectorConstructors.hlsl
index 358f976126f55..76d9a78ea9df8 100644
--- a/clang/test/CodeGenHLSL/BasicFeatures/MatrixToAndFromVectorConstructors.hlsl
+++ b/clang/test/CodeGenHLSL/BasicFeatures/MatrixToAndFromVectorConstructors.hlsl
@@ -4,7 +4,6 @@
 // CHECK-LABEL: define hidden noundef nofpclass(nan inf) <4 x float> @_Z2fnu11matrix_typeILm2ELm2EfE(
 // CHECK-SAME: <4 x float> noundef nofpclass(nan inf) [[M:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [2 x <2 x float>], align 4
 // CHECK-NEXT:    [[V:%.*]] = alloca <4 x float>, align 4
 // CHECK-NEXT:    store <4 x float> [[M]], ptr [[M_ADDR]], align 4
@@ -34,7 +33,6 @@ float4 fn(float2x2 m) {
 // CHECK-LABEL: define hidden noundef <4 x i32> @_Z2fnDv4_i(
 // CHECK-SAME: <4 x i32> noundef [[V:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[V_ADDR:%.*]] = alloca <4 x i32>, align 4
 // CHECK-NEXT:    [[M:%.*]] = alloca [2 x <2 x i32>], align 4
 // CHECK-NEXT:    store <4 x i32> [[V]], ptr [[V_ADDR]], align 4
@@ -64,7 +62,6 @@ int2x2 fn(int4 v) {
 // CHECK-LABEL: define hidden noundef <2 x i32> @_Z3fn1Dv2_i(
 // CHECK-SAME: <2 x i32> noundef [[V:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[V_ADDR:%.*]] = alloca <2 x i32>, align 4
 // CHECK-NEXT:    store <2 x i32> [[V]], ptr [[V_ADDR]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load <2 x i32>, ptr [[V_ADDR]], align 4
@@ -82,7 +79,6 @@ int1x2 fn1(int2 v) {
 // CHECK-LABEL: define hidden noundef <3 x i1> @_Z3fn2Dv3_b(
 // CHECK-SAME: <3 x i1> noundef [[B:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[B_ADDR:%.*]] = alloca <3 x i32>, align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <3 x i1> [[B]] to <3 x i32>
 // CHECK-NEXT:    store <3 x i32> [[TMP0]], ptr [[B_ADDR]], align 4
@@ -107,21 +103,26 @@ bool3x1 fn2(bool3 b) {
 // CHECK-LABEL: define hidden noundef <3 x i32> @_Z3fn3u11matrix_typeILm1ELm3EbE(
 // CHECK-SAME: <3 x i1> noundef [[B:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // COL-CHECK-NEXT:    [[B_ADDR:%.*]] = alloca [3 x <1 x i32>], align 4
 // ROW-CHECK-NEXT:    [[B_ADDR:%.*]] = alloca [1 x <3 x i32>], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <3 x i1> [[B]] to <3 x i32>
 // CHECK-NEXT:    store <3 x i32> [[TMP0]], ptr [[B_ADDR]], align 4
 // CHECK-NEXT:    [[TMP1:%.*]] = load <3 x i32>, ptr [[B_ADDR]], align 4
-// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <3 x i32> [[TMP1]], i32 0
-// CHECK-NEXT:    [[VECINIT:%.*]] = insertelement <3 x i32> poison, i32 [[MATRIXEXT]], i32 0
+// CHECK-NEXT:    [[TRUNC1:%.*]] = trunc <3 x i32> [[TMP1]] to <3 x i1>
+// CHECK-NEXT:    [[MATRIXEXT1:%.*]] = extractelement <3 x i1> [[TRUNC1]], i32 0
+// CHECK-NEXT:    [[CONV1:%.*]] = zext i1 [[MATRIXEXT1]] to i32
+// CHECK-NEXT:    [[VECINIT1:%.*]] = insertelement <3 x i32> poison, i32 [[CONV1]], i32 0
 // CHECK-NEXT:    [[TMP2:%.*]] = load <3 x i32>, ptr [[B_ADDR]], align 4
-// CHECK-NEXT:    [[MATRIXEXT1:%.*]] = extractelement <3 x i32> [[TMP2]], i32 1
-// CHECK-NEXT:    [[VECINIT2:%.*]] = insertelement <3 x i32> [[VECINIT]], i32 [[MATRIXEXT1]], i32 1
+// CHECK-NEXT:    [[TRUNC2:%.*]] = trunc <3 x i32> [[TMP2]] to <3 x i1>
+// CHECK-NEXT:    [[MATRIXEXT2:%.*]] = extractelement <3 x i1> [[TRUNC2]], i32 1
+// CHECK-NEXT:    [[CONV2:%.*]] = zext i1 [[MATRIXEXT2]] to i32
+// CHECK-NEXT:    [[VECINIT2:%.*]] = insertelement <3 x i32> [[VECINIT1]], i32 [[CONV2]], i32 1
 // CHECK-NEXT:    [[TMP3:%.*]] = load <3 x i32>, ptr [[B_ADDR]], align 4
-// CHECK-NEXT:    [[MATRIXEXT3:%.*]] = extractelement <3 x i32> [[TMP3]], i32 2
-// CHECK-NEXT:    [[VECINIT4:%.*]] = insertelement <3 x i32> [[VECINIT2]], i32 [[MATRIXEXT3]], i32 2
-// CHECK-NEXT:    ret <3 x i32> [[VECINIT4]]
+// CHECK-NEXT:    [[TRUNC3:%.*]] = trunc <3 x i32> [[TMP3]] to <3 x i1>
+// CHECK-NEXT:    [[MATRIXEXT3:%.*]] = extractelement <3 x i1> [[TRUNC3]], i32 2
+// CHECK-NEXT:    [[CONV3:%.*]] = zext i1 [[MATRIXEXT3]] to i32
+// CHECK-NEXT:    [[VECINIT3:%.*]] = insertelement <3 x i32> [[VECINIT2]], i32 [[CONV3]], i32 2
+// CHECK-NEXT:    ret <3 x i32> [[VECINIT3]]
 //
 int3 fn3(bool1x3 b) {
     return b;
diff --git a/clang/test/CodeGenHLSL/BasicFeatures/VectorElementwiseCast.hlsl b/clang/test/CodeGenHLSL/BasicFeatures/VectorElementwiseCast.hlsl
index 89f5ff8f16825..8902248baa063 100644
--- a/clang/test/CodeGenHLSL/BasicFeatures/VectorElementwiseCast.hlsl
+++ b/clang/test/CodeGenHLSL/BasicFeatures/VectorElementwiseCast.hlsl
@@ -197,19 +197,21 @@ export void call8(int3x1 M) {
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <2 x i1> %M to <2 x i32>
 // CHECK-NEXT:    store <2 x i32> [[TMP0]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP1:%.*]] = load <2 x i32>, ptr [[M_ADDR]], align 4
-// CHECK-NEXT:    store <2 x i32> [[TMP1]], ptr [[HLSL_EWCAST_SRC]], align 4
+// CHECK-NEXT:    [[LOADEDV0:%.*]] = trunc <2 x i32> [[TMP1]] to <2 x i1>
+// CHECK-NEXT:    [[TMP2:%.*]] = zext <2 x i1> [[LOADEDV0]] to <2 x i32>
+// CHECK-NEXT:    store <2 x i32> [[TMP2]], ptr [[HLSL_EWCAST_SRC]], align 4
 // CHECK-NEXT:    [[MATRIX_GEP:%.*]] = getelementptr inbounds <2 x i32>, ptr [[HLSL_EWCAST_SRC]], i32 0
-// CHECK-NEXT:    [[TMP2:%.*]] = load <2 x i1>, ptr [[FLATCAST_TMP]], align 4
-// CHECK-NEXT:    [[TMP3:%.*]] = load <2 x i32>, ptr [[MATRIX_GEP]], align 4
-// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <2 x i32> [[TMP3]], i32 0
-// CHECK-NEXT:    [[LOADEDV:%.*]] = icmp ne i32 [[MATRIXEXT]], 0
-// CHECK-NEXT:    [[TMP4:%.*]] = insertelement <2 x i1> [[TMP2]], i1 [[LOADEDV]], i64 0
-// CHECK-NEXT:    [[TMP5:%.*]] = load <2 x i32>, ptr [[MATRIX_GEP]], align 4
-// CHECK-NEXT:    [[MATRIXEXT1:%.*]] = extractelement <2 x i32> [[TMP5]], i32 1
+// CHECK-NEXT:    [[TMP3:%.*]] = load <2 x i1>, ptr [[FLATCAST_TMP]], align 4
+// CHECK-NEXT:    [[TMP4:%.*]] = load <2 x i32>, ptr [[MATRIX_GEP]], align 4
+// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <2 x i32> [[TMP4]], i32 0
+// CHECK-NEXT:    [[LOADEDV1:%.*]] = icmp ne i32 [[MATRIXEXT]], 0
+// CHECK-NEXT:    [[TMP5:%.*]] = insertelement <2 x i1> [[TMP3]], i1 [[LOADEDV1]], i64 0
+// CHECK-NEXT:    [[TMP6:%.*]] = load <2 x i32>, ptr [[MATRIX_GEP]], align 4
+// CHECK-NEXT:    [[MATRIXEXT1:%.*]] = extractelement <2 x i32> [[TMP6]], i32 1
 // CHECK-NEXT:    [[LOADEDV2:%.*]] = icmp ne i32 [[MATRIXEXT1]], 0
-// CHECK-NEXT:    [[TMP6:%.*]] = insertelement <2 x i1> [[TMP4]], i1 [[LOADEDV2]], i64 1
-// CHECK-NEXT:    [[TMP7:%.*]] = zext <2 x i1> [[TMP6]] to <2 x i32>
-// CHECK-NEXT:    store <2 x i32> [[TMP7]], ptr [[V]], align 4
+// CHECK-NEXT:    [[TMP7:%.*]] = insertelement <2 x i1> [[TMP5]], i1 [[LOADEDV2]], i64 1
+// CHECK-NEXT:    [[TMP8:%.*]] = zext <2 x i1> [[TMP7]] to <2 x i32>
+// CHECK-NEXT:    store <2 x i32> [[TMP8]], ptr [[V]], align 4
 // CHECK-NEXT:    ret void
 export void call9(bool1x2 M) {
     bool2 V = (bool2)M;
diff --git a/clang/test/CodeGenHLSL/BoolMatrix.hlsl b/clang/test/CodeGenHLSL/BoolMatrix.hlsl
index eeb2fa83d4656..d237c7a5eaaca 100644
--- a/clang/test/CodeGenHLSL/BoolMatrix.hlsl
+++ b/clang/test/CodeGenHLSL/BoolMatrix.hlsl
@@ -10,15 +10,12 @@ struct S {
 // CHECK-LABEL: define hidden noundef i1 @_Z3fn1v(
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
-// CHECK-NEXT:    [[RETVAL:%.*]] = alloca i1, align 4
 // CHECK-NEXT:    [[B:%.*]] = alloca [2 x <2 x i32>], align 4
 // CHECK-NEXT:    store <4 x i32> splat (i32 1), ptr [[B]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i32>, ptr [[B]], align 4
-// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <4 x i32> [[TMP0]], i32 0
-// CHECK-NEXT:    store i32 [[MATRIXEXT]], ptr [[RETVAL]], align 4
-// CHECK-NEXT:    [[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 4
-// CHECK-NEXT:    ret i1 [[TMP1]]
+// CHECK-NEXT:    [[LOADEDV:%.*]] = trunc <4 x i32> [[TMP0]] to <4 x i1>
+// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <4 x i1> [[LOADEDV]], i32 0
+// CHECK-NEXT:    ret i1 [[MATRIXEXT]]
 //
 bool fn1() {
   bool2x2 B = {true,true,true,true};
@@ -28,8 +25,6 @@ bool fn1() {
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z3fn2b(
 // CHECK-SAME: i1 noundef [[V:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
-// CHECK-NEXT:    [[RETVAL:%.*]] = alloca <4 x i1>, align 4
 // CHECK-NEXT:    [[V_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    [[A:%.*]] = alloca [2 x <2 x i32>], align 4
 // CHECK-NEXT:    [[STOREDV:%.*]] = zext i1 [[V]] to i32
@@ -45,9 +40,8 @@ bool fn1() {
 // CHECK-NEXT:    [[TMP2:%.*]] = zext <4 x i1> [[VECINIT4]] to <4 x i32>
 // CHECK-NEXT:    store <4 x i32> [[TMP2]], ptr [[A]], align 4
 // CHECK-NEXT:    [[TMP3:%.*]] = load <4 x i32>, ptr [[A]], align 4
-// CHECK-NEXT:    store <4 x i32> [[TMP3]], ptr [[RETVAL]], align 4
-// CHECK-NEXT:    [[TMP4:%.*]] = load <4 x i1>, ptr [[RETVAL]], align 4
-// CHECK-NEXT:    ret <4 x i1> [[TMP4]]
+// CHECK-NEXT:    [[TRUNC:%.*]] = trunc <4 x i32> [[TMP3]] to <4 x i1>
+// CHECK-NEXT:    ret <4 x i1> [[TRUNC]]
 //
 bool2x2 fn2(bool V) {
   bool2x2 A = {V, true, V, false};
@@ -57,16 +51,13 @@ bool2x2 fn2(bool V) {
 // CHECK-LABEL: define hidden noundef i1 @_Z3fn3v(
 // CHECK-SAME: ) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
-// CHECK-NEXT:    [[RETVAL:%.*]] = alloca i1, align 4
 // CHECK-NEXT:    [[S:%.*]] = alloca [[STRUCT_S:%.*]], align 1
 // CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i32(ptr align 1 [[S]], ptr align 1 @__const._Z3fn3v.s, i32 20, i1 false)
 // CHECK-NEXT:    [[BM:%.*]] = getelementptr inbounds nuw [[STRUCT_S]], ptr [[S]], i32 0, i32 0
 // CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i32>, ptr [[BM]], align 1
-// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <4 x i32> [[TMP0]], i32 0
-// CHECK-NEXT:    store i32 [[MATRIXEXT]], ptr [[RETVAL]], align 4
-// CHECK-NEXT:    [[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 4
-// CHECK-NEXT:    ret i1 [[TMP1]]
+// CHECK-NEXT:    [[TRUNC:%.*]] = trunc <4 x i32> [[TMP0]] to <4 x i1>
+// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <4 x i1> [[TRUNC]], i32 0
+// CHECK-NEXT:    ret i1 [[MATRIXEXT]]
 //
 bool fn3() {
   S s = {{true,true,false,false}, 1.0};
@@ -76,16 +67,13 @@ bool fn3() {
 // CHECK-LABEL: define hidden noundef i1 @_Z3fn4v(
 // CHECK-SAME: ) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
-// CHECK-NEXT:    [[RETVAL:%.*]] = alloca i1, align 4
 // CHECK-NEXT:    [[ARR:%.*]] = alloca [2 x [2 x <2 x i32>]], align 4
 // CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[ARR]], ptr align 4 @constinit, i32 32, i1 false)
 // CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds [2 x [2 x <2 x i32>]], ptr [[ARR]], i32 0, i32 0
 // CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i32>, ptr [[ARRAYIDX]], align 4
-// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <4 x i32> [[TMP0]], i32 1
-// CHECK-NEXT:    store i32 [[MATRIXEXT]], ptr [[RETVAL]], align 4
-// CHECK-NEXT:    [[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 4
-// CHECK-NEXT:    ret i1 [[TMP1]]
+// CHECK-NEXT:    [[TRUNC:%.*]] = trunc <4 x i32> [[TMP0]] to <4 x i1>
+// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <4 x i1> [[TRUNC]], i32 1
+// CHECK-NEXT:    ret i1 [[MATRIXEXT]]
 //
 bool fn4() {
   bool2x2 Arr[2] = {{true,true,true,true}, {false,false,false,false}};
@@ -95,7 +83,6 @@ bool fn4() {
 // CHECK-LABEL: define hidden void @_Z3fn5v(
 // CHECK-SAME: ) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M:%.*]] = alloca [2 x <2 x i32>], align 4
 // CHECK-NEXT:    store <4 x i32> splat (i32 1), ptr [[M]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = getelementptr <4 x i32>, ptr [[M]], i32 0, i32 3
@@ -110,7 +97,6 @@ void fn5() {
 // CHECK-LABEL: define hidden void @_Z3fn6v(
 // CHECK-SAME: ) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[V:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    [[S:%.*]] = alloca [[STRUCT_S:%.*]], align 1
 // CHECK-NEXT:    store i32 0, ptr [[V]], align 4
@@ -132,7 +118,6 @@ void fn6() {
 // CHECK-LABEL: define hidden void @_Z3fn7v(
 // CHECK-SAME: ) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[ARR:%.*]] = alloca [2 x [2 x <2 x i32>]], align 4
 // CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[ARR]], ptr align 4 @constinit.1, i32 32, i1 false)
 // CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds [2 x [2 x <2 x i32>]], ptr [[ARR]], i32 0, i32 0
@@ -148,15 +133,12 @@ void fn7() {
 // CHECK-LABEL: define hidden noundef <16 x i1> @_Z3fn8u11matrix_typeILm4ELm4EbE(
 // CHECK-SAME: <16 x i1> noundef [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
-// CHECK-NEXT:    [[RETVAL:%.*]] = alloca <16 x i1>, align 4
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [4 x <4 x i32>], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <16 x i1> [[M]] to <16 x i32>
 // CHECK-NEXT:    store <16 x i32> [[TMP0]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP1:%.*]] = load <16 x i32>, ptr [[M_ADDR]], align 4
-// CHECK-NEXT:    store <16 x i32> [[TMP1]], ptr [[RETVAL]], align 4
-// CHECK-NEXT:    [[TMP2:%.*]] = load <16 x i1>, ptr [[RETVAL]], align 4
-// CHECK-NEXT:    ret <16 x i1> [[TMP2]]
+// CHECK-NEXT:    [[TRUNC:%.*]] = trunc <16 x i32> [[TMP1]] to <16 x i1>
+// CHECK-NEXT:    ret <16 x i1> [[TRUNC]]
 //
 bool4x4 fn8(bool4x4 m) {
   return m;
diff --git a/clang/test/CodeGenHLSL/builtins/and_mat.hlsl b/clang/test/CodeGenHLSL/builtins/and_mat.hlsl
index c070dd90d9568..66c87c5de9453 100644
--- a/clang/test/CodeGenHLSL/builtins/and_mat.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/and_mat.hlsl
@@ -5,8 +5,8 @@
 // CHECK-LABEL: define hidden noundef <2 x i1> @_Z16test_and_bool1x2u11matrix_typeILm1ELm2EbES_(
 // CHECK-SAME: <2 x i1> noundef [[X:%.*]], <2 x i1> noundef [[Y:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <2 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <2 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <2 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <2 x i1> [[HLSL_AND]]
 bool1x2 test_and_bool1x2(bool1x2 x, bool1x2 y)
 {
     return and(x, y);
@@ -15,8 +15,8 @@ bool1x2 test_and_bool1x2(bool1x2 x, bool1x2 y)
 // CHECK-LABEL: define hidden noundef <3 x i1> @_Z16test_and_bool1x3u11matrix_typeILm1ELm3EbES_(
 // CHECK-SAME: <3 x i1> noundef [[X:%.*]], <3 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <3 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <3 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <3 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <3 x i1> [[HLSL_AND]]
 bool1x3 test_and_bool1x3(bool1x3 x, bool1x3 y)
 {
     return and(x, y);
@@ -25,8 +25,8 @@ bool1x3 test_and_bool1x3(bool1x3 x, bool1x3 y)
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z16test_and_bool1x4u11matrix_typeILm1ELm4EbES_(
 // CHECK-SAME: <4 x i1> noundef [[X:%.*]], <4 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <4 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <4 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <4 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <4 x i1> [[HLSL_AND]]
 bool1x4 test_and_bool1x4(bool1x4 x, bool1x4 y)
 {
     return and(x, y);
@@ -35,8 +35,8 @@ bool1x4 test_and_bool1x4(bool1x4 x, bool1x4 y)
 // CHECK-LABEL: define hidden noundef <2 x i1> @_Z16test_and_bool2x1u11matrix_typeILm2ELm1EbES_(
 // CHECK-SAME: <2 x i1> noundef [[X:%.*]], <2 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <2 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <2 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <2 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <2 x i1> [[HLSL_AND]]
 bool2x1 test_and_bool2x1(bool2x1 x, bool2x1 y)
 {
     return and(x, y);
@@ -46,8 +46,8 @@ bool2x1 test_and_bool2x1(bool2x1 x, bool2x1 y)
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z16test_and_bool2x2u11matrix_typeILm2ELm2EbES_(
 // CHECK-SAME: <4 x i1> noundef [[X:%.*]], <4 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <4 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <4 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <4 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <4 x i1> [[HLSL_AND]]
 bool2x2 test_and_bool2x2(bool2x2 x, bool2x2 y)
 {
     return and(x, y);
@@ -56,8 +56,8 @@ bool2x2 test_and_bool2x2(bool2x2 x, bool2x2 y)
 // CHECK-LABEL: define hidden noundef <6 x i1> @_Z16test_and_bool2x3u11matrix_typeILm2ELm3EbES_(
 // CHECK-SAME: <6 x i1> noundef [[X:%.*]], <6 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <6 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <6 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <6 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <6 x i1> [[HLSL_AND]]
 bool2x3 test_and_bool2x3(bool2x3 x, bool2x3 y)
 {
     return and(x, y);
@@ -66,8 +66,8 @@ bool2x3 test_and_bool2x3(bool2x3 x, bool2x3 y)
 // CHECK-LABEL: define hidden noundef <8 x i1> @_Z16test_and_bool2x4u11matrix_typeILm2ELm4EbES_(
 // CHECK-SAME: <8 x i1> noundef [[X:%.*]], <8 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <8 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <8 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <8 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <8 x i1> [[HLSL_AND]]
 bool2x4 test_and_bool2x4(bool2x4 x, bool2x4 y)
 {
     return and(x, y);
@@ -76,8 +76,8 @@ bool2x4 test_and_bool2x4(bool2x4 x, bool2x4 y)
 // CHECK-LABEL: define hidden noundef <3 x i1> @_Z16test_and_bool3x1u11matrix_typeILm3ELm1EbES_(
 // CHECK-SAME: <3 x i1> noundef [[X:%.*]], <3 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <3 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <3 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <3 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <3 x i1> [[HLSL_AND]]
 bool3x1 test_and_bool3x1(bool3x1 x, bool3x1 y)
 {
     return and(x, y);
@@ -86,8 +86,8 @@ bool3x1 test_and_bool3x1(bool3x1 x, bool3x1 y)
 // CHECK-LABEL: define hidden noundef <6 x i1> @_Z16test_and_bool3x2u11matrix_typeILm3ELm2EbES_(
 // CHECK-SAME: <6 x i1> noundef [[X:%.*]], <6 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <6 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <6 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <6 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <6 x i1> [[HLSL_AND]]
 bool3x2 test_and_bool3x2(bool3x2 x, bool3x2 y)
 {
     return and(x, y);
@@ -97,8 +97,8 @@ bool3x2 test_and_bool3x2(bool3x2 x, bool3x2 y)
 // CHECK-LABEL: define hidden noundef <9 x i1> @_Z16test_and_bool3x3u11matrix_typeILm3ELm3EbES_(
 // CHECK-SAME: <9 x i1> noundef [[X:%.*]], <9 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <9 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <9 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <9 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <9 x i1> [[HLSL_AND]]
 bool3x3 test_and_bool3x3(bool3x3 x, bool3x3 y)
 {
     return and(x, y);
@@ -107,8 +107,8 @@ bool3x3 test_and_bool3x3(bool3x3 x, bool3x3 y)
 // CHECK-LABEL: define hidden noundef <12 x i1> @_Z16test_and_bool3x4u11matrix_typeILm3ELm4EbES_(
 // CHECK-SAME: <12 x i1> noundef [[X:%.*]], <12 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <12 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <12 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <12 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <12 x i1> [[HLSL_AND]]
 bool3x4 test_and_bool3x4(bool3x4 x, bool3x4 y)
 {
     return and(x, y);
@@ -117,8 +117,8 @@ bool3x4 test_and_bool3x4(bool3x4 x, bool3x4 y)
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z16test_and_bool4x1u11matrix_typeILm4ELm1EbES_(
 // CHECK-SAME: <4 x i1> noundef [[X:%.*]], <4 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <4 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <4 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <4 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <4 x i1> [[HLSL_AND]]
 bool4x1 test_and_bool4x1(bool4x1 x, bool4x1 y)
 {
     return and(x, y);
@@ -127,8 +127,8 @@ bool4x1 test_and_bool4x1(bool4x1 x, bool4x1 y)
 // CHECK-LABEL: define hidden noundef <8 x i1> @_Z16test_and_bool4x2u11matrix_typeILm4ELm2EbES_(
 // CHECK-SAME: <8 x i1> noundef [[X:%.*]], <8 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <8 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <8 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <8 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <8 x i1> [[HLSL_AND]]
 bool4x2 test_and_bool4x2(bool4x2 x, bool4x2 y)
 {
     return and(x, y);
@@ -137,8 +137,8 @@ bool4x2 test_and_bool4x2(bool4x2 x, bool4x2 y)
 // CHECK-LABEL: define hidden noundef <12 x i1> @_Z16test_and_bool4x3u11matrix_typeILm4ELm3EbES_(
 // CHECK-SAME: <12 x i1> noundef [[X:%.*]], <12 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <12 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <12 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <12 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <12 x i1> [[HLSL_AND]]
 bool4x3 test_and_bool4x3(bool4x3 x, bool4x3 y)
 {
     return and(x, y);
@@ -147,8 +147,8 @@ bool4x3 test_and_bool4x3(bool4x3 x, bool4x3 y)
 // CHECK-LABEL: define hidden noundef <16 x i1> @_Z16test_and_bool4x4u11matrix_typeILm4ELm4EbES_(
 // CHECK-SAME: <16 x i1> noundef [[X:%.*]], <16 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <16 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <16 x i1> [[HLSL_AND_CAST:%.*]]
+// CHECK:         [[HLSL_AND:%.*]] = and <16 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <16 x i1> [[HLSL_AND]]
 bool4x4 test_and_bool4x4(bool4x4 x, bool4x4 y)
 {
     return and(x, y);
diff --git a/clang/test/CodeGenHLSL/builtins/or.hlsl b/clang/test/CodeGenHLSL/builtins/or.hlsl
index cf07d2fb7b42b..bd6f9c3f21d49 100644
--- a/clang/test/CodeGenHLSL/builtins/or.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/or.hlsl
@@ -81,8 +81,8 @@ bool4 test_or_float4(float4 x, float4 y)
 // CHECK-LABEL: define hidden noundef <2 x i1> @_Z15test_or_bool1x2u11matrix_typeILm1ELm2EbES_(
 // CHECK-SAME: <2 x i1> noundef [[X:%.*]], <2 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <2 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <2 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <2 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <2 x i1> [[HLSL_OR]]
 bool1x2 test_or_bool1x2(bool1x2 x, bool1x2 y)
 {
     return or(x, y);
@@ -91,8 +91,8 @@ bool1x2 test_or_bool1x2(bool1x2 x, bool1x2 y)
 // CHECK-LABEL: define hidden noundef <3 x i1> @_Z15test_or_bool1x3u11matrix_typeILm1ELm3EbES_(
 // CHECK-SAME: <3 x i1> noundef [[X:%.*]], <3 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <3 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <3 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <3 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <3 x i1> [[HLSL_OR]]
 bool1x3 test_or_bool1x3(bool1x3 x, bool1x3 y)
 {
     return or(x, y);
@@ -101,8 +101,8 @@ bool1x3 test_or_bool1x3(bool1x3 x, bool1x3 y)
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z15test_or_bool1x4u11matrix_typeILm1ELm4EbES_(
 // CHECK-SAME: <4 x i1> noundef [[X:%.*]], <4 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <4 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <4 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <4 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <4 x i1> [[HLSL_OR]]
 bool1x4 test_or_bool1x4(bool1x4 x, bool1x4 y)
 {
     return or(x, y);
@@ -111,8 +111,8 @@ bool1x4 test_or_bool1x4(bool1x4 x, bool1x4 y)
 // CHECK-LABEL: define hidden noundef <2 x i1> @_Z15test_or_bool2x1u11matrix_typeILm2ELm1EbES_(
 // CHECK-SAME: <2 x i1> noundef [[X:%.*]], <2 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <2 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <2 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <2 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <2 x i1> [[HLSL_OR]]
 bool2x1 test_or_bool2x1(bool2x1 x, bool2x1 y)
 {
     return or(x, y);
@@ -122,8 +122,8 @@ bool2x1 test_or_bool2x1(bool2x1 x, bool2x1 y)
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z15test_or_bool2x2u11matrix_typeILm2ELm2EbES_(
 // CHECK-SAME: <4 x i1> noundef [[X:%.*]], <4 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <4 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <4 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <4 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <4 x i1> [[HLSL_OR]]
 bool2x2 test_or_bool2x2(bool2x2 x, bool2x2 y)
 {
     return or(x, y);
@@ -132,8 +132,8 @@ bool2x2 test_or_bool2x2(bool2x2 x, bool2x2 y)
 // CHECK-LABEL: define hidden noundef <6 x i1> @_Z15test_or_bool2x3u11matrix_typeILm2ELm3EbES_(
 // CHECK-SAME: <6 x i1> noundef [[X:%.*]], <6 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <6 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <6 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <6 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <6 x i1> [[HLSL_OR]]
 bool2x3 test_or_bool2x3(bool2x3 x, bool2x3 y)
 {
     return or(x, y);
@@ -142,8 +142,8 @@ bool2x3 test_or_bool2x3(bool2x3 x, bool2x3 y)
 // CHECK-LABEL: define hidden noundef <8 x i1> @_Z15test_or_bool2x4u11matrix_typeILm2ELm4EbES_(
 // CHECK-SAME: <8 x i1> noundef [[X:%.*]], <8 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <8 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <8 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <8 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <8 x i1> [[HLSL_OR]]
 bool2x4 test_or_bool2x4(bool2x4 x, bool2x4 y)
 {
     return or(x, y);
@@ -152,8 +152,8 @@ bool2x4 test_or_bool2x4(bool2x4 x, bool2x4 y)
 // CHECK-LABEL: define hidden noundef <3 x i1> @_Z15test_or_bool3x1u11matrix_typeILm3ELm1EbES_(
 // CHECK-SAME: <3 x i1> noundef [[X:%.*]], <3 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <3 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <3 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <3 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <3 x i1> [[HLSL_OR]]
 bool3x1 test_or_bool3x1(bool3x1 x, bool3x1 y)
 {
     return or(x, y);
@@ -162,8 +162,8 @@ bool3x1 test_or_bool3x1(bool3x1 x, bool3x1 y)
 // CHECK-LABEL: define hidden noundef <6 x i1> @_Z15test_or_bool3x2u11matrix_typeILm3ELm2EbES_(
 // CHECK-SAME: <6 x i1> noundef [[X:%.*]], <6 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <6 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <6 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <6 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <6 x i1> [[HLSL_OR]]
 bool3x2 test_or_bool3x2(bool3x2 x, bool3x2 y)
 {
     return or(x, y);
@@ -173,8 +173,8 @@ bool3x2 test_or_bool3x2(bool3x2 x, bool3x2 y)
 // CHECK-LABEL: define hidden noundef <9 x i1> @_Z15test_or_bool3x3u11matrix_typeILm3ELm3EbES_(
 // CHECK-SAME: <9 x i1> noundef [[X:%.*]], <9 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <9 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <9 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <9 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <9 x i1> [[HLSL_OR]]
 bool3x3 test_or_bool3x3(bool3x3 x, bool3x3 y)
 {
     return or(x, y);
@@ -183,8 +183,8 @@ bool3x3 test_or_bool3x3(bool3x3 x, bool3x3 y)
 // CHECK-LABEL: define hidden noundef <12 x i1> @_Z15test_or_bool3x4u11matrix_typeILm3ELm4EbES_(
 // CHECK-SAME: <12 x i1> noundef [[X:%.*]], <12 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <12 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <12 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <12 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <12 x i1> [[HLSL_OR]]
 bool3x4 test_or_bool3x4(bool3x4 x, bool3x4 y)
 {
     return or(x, y);
@@ -193,8 +193,8 @@ bool3x4 test_or_bool3x4(bool3x4 x, bool3x4 y)
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z15test_or_bool4x1u11matrix_typeILm4ELm1EbES_(
 // CHECK-SAME: <4 x i1> noundef [[X:%.*]], <4 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <4 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <4 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <4 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <4 x i1> [[HLSL_OR]]
 bool4x1 test_or_bool4x1(bool4x1 x, bool4x1 y)
 {
     return or(x, y);
@@ -203,8 +203,8 @@ bool4x1 test_or_bool4x1(bool4x1 x, bool4x1 y)
 // CHECK-LABEL: define hidden noundef <8 x i1> @_Z15test_or_bool4x2u11matrix_typeILm4ELm2EbES_(
 // CHECK-SAME: <8 x i1> noundef [[X:%.*]], <8 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <8 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <8 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <8 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <8 x i1> [[HLSL_OR]]
 bool4x2 test_or_bool4x2(bool4x2 x, bool4x2 y)
 {
     return or(x, y);
@@ -213,8 +213,8 @@ bool4x2 test_or_bool4x2(bool4x2 x, bool4x2 y)
 // CHECK-LABEL: define hidden noundef <12 x i1> @_Z15test_or_bool4x3u11matrix_typeILm4ELm3EbES_(
 // CHECK-SAME: <12 x i1> noundef [[X:%.*]], <12 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <12 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <12 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <12 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <12 x i1> [[HLSL_OR]]
 bool4x3 test_or_bool4x3(bool4x3 x, bool4x3 y)
 {
     return or(x, y);
@@ -223,8 +223,8 @@ bool4x3 test_or_bool4x3(bool4x3 x, bool4x3 y)
 // CHECK-LABEL: define hidden noundef <16 x i1> @_Z15test_or_bool4x4u11matrix_typeILm4ELm4EbES_(
 // CHECK-SAME: <16 x i1> noundef [[X:%.*]], <16 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <16 x i32> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <16 x i1> [[HLSL_OR_CAST:%.*]]
+// CHECK:         [[HLSL_OR:%.*]] = or <16 x i1> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <16 x i1> [[HLSL_OR]]
 bool4x4 test_or_bool4x4(bool4x4 x, bool4x4 y)
 {
     return or(x, y);
diff --git a/clang/test/CodeGenHLSL/builtins/transpose.hlsl b/clang/test/CodeGenHLSL/builtins/transpose.hlsl
index d8430fcf5bf9d..0863fba6190c1 100644
--- a/clang/test/CodeGenHLSL/builtins/transpose.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/transpose.hlsl
@@ -9,8 +9,9 @@
 // CHECK:       [[A_EXT:%.*]] = zext <6 x i1> %{{.*}} to <6 x i32>
 // CHECK:       store <6 x i32> [[A_EXT]], ptr [[A_ADDR]], align 4
 // CHECK:       [[A:%.*]] = load <6 x i32>, ptr [[A_ADDR]], align 4
-// COLMAJOR:    [[TRANS:%.*]] = call <6 x i32> @llvm.matrix.transpose.v6i32(<6 x i32> [[A]], i32 2, i32 3)
-// ROWMAJOR:    [[TRANS:%.*]] = call <6 x i32> @llvm.matrix.transpose.v6i32(<6 x i32> [[A]], i32 3, i32 2)
+// CHECK:       [[TRUNC:%.*]] = trunc <6 x i32> [[A]] to <6 x i1>
+// COLMAJOR:    [[TRANS:%.*]] = call <6 x i1> @llvm.matrix.transpose.v6i1(<6 x i1> [[TRUNC]], i32 2, i32 3)
+// ROWMAJOR:    [[TRANS:%.*]] = call <6 x i1> @llvm.matrix.transpose.v6i1(<6 x i1> [[TRUNC]], i32 3, i32 2)
 bool3x2 test_transpose_bool2x3(bool2x3 a) {
   return transpose(a);
 }

>From 12a2c672b89d11a2705639e833134fcc3aaa24fc Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Wed, 3 Jun 2026 10:21:10 -0600
Subject: [PATCH 04/17] Restores convergence.entry checks.

---
 .../BasicFeatures/MatrixSingleSubscriptGetter.hlsl     | 10 ++++++++++
 .../MatrixToAndFromVectorConstructors.hlsl             |  5 +++++
 clang/test/CodeGenHLSL/BoolMatrix.hlsl                 |  8 ++++++++
 3 files changed, 23 insertions(+)

diff --git a/clang/test/CodeGenHLSL/BasicFeatures/MatrixSingleSubscriptGetter.hlsl b/clang/test/CodeGenHLSL/BasicFeatures/MatrixSingleSubscriptGetter.hlsl
index baac77b2e0fad..6adf7e80fe0eb 100644
--- a/clang/test/CodeGenHLSL/BasicFeatures/MatrixSingleSubscriptGetter.hlsl
+++ b/clang/test/CodeGenHLSL/BasicFeatures/MatrixSingleSubscriptGetter.hlsl
@@ -4,6 +4,7 @@
 // CHECK-LABEL: define hidden noundef nofpclass(nan inf) <4 x float> @_Z24getFloatVecMatrixDynamicu11matrix_typeILm4ELm4EfEi(
 // CHECK-SAME: <16 x float> noundef nofpclass(nan inf) [[M:%.*]], i32 noundef [[INDEX:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [4 x <4 x float>], align 4
 // CHECK-NEXT:    [[INDEX_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    store <16 x float> [[M]], ptr [[M_ADDR]], align 4
@@ -31,6 +32,7 @@ float4 getFloatVecMatrixDynamic(float4x4 M, int index) {
 // CHECK-LABEL: define hidden noundef nofpclass(nan inf) float @_Z27getFloatScalarMatrixDynamicu11matrix_typeILm2ELm1EfEi(
 // CHECK-SAME: <2 x float> noundef nofpclass(nan inf) [[M:%.*]], i32 noundef [[INDEX:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [1 x <2 x float>], align 4
 // CHECK-NEXT:    [[INDEX_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    store <2 x float> [[M]], ptr [[M_ADDR]], align 4
@@ -50,6 +52,7 @@ float getFloatScalarMatrixDynamic(float2x1 M, int index) {
 // CHECK-LABEL: define hidden noundef nofpclass(nan inf) float @_Z28getFloatScalarMatrixConstantu11matrix_typeILm2ELm1EfE(
 // CHECK-SAME: <2 x float> noundef nofpclass(nan inf) [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [1 x <2 x float>], align 4
 // CHECK-NEXT:    store <2 x float> [[M]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load <2 x float>, ptr [[M_ADDR]], align 4
@@ -65,6 +68,7 @@ float getFloatScalarMatrixConstant(float2x1 M) {
 // CHECK-LABEL: define hidden noundef nofpclass(nan inf) float @_Z29getFloatScalarMatrixConstant2u11matrix_typeILm2ELm1EfE(
 // CHECK-SAME: <2 x float> noundef nofpclass(nan inf) [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [1 x <2 x float>], align 4
 // CHECK-NEXT:    store <2 x float> [[M]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load <2 x float>, ptr [[M_ADDR]], align 4
@@ -80,6 +84,7 @@ float getFloatScalarMatrixConstant2(float2x1 M) {
 // CHECK-LABEL: define hidden noundef <4 x i32> @_Z19getIntMatrixDynamicu11matrix_typeILm4ELm4EiEi(
 // CHECK-SAME: <16 x i32> noundef [[M:%.*]], i32 noundef [[INDEX:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [4 x <4 x i32>], align 4
 // CHECK-NEXT:    [[INDEX_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    store <16 x i32> [[M]], ptr [[M_ADDR]], align 4
@@ -107,6 +112,7 @@ int4 getIntMatrixDynamic(int4x4 M, int index) {
 // CHECK-LABEL: define hidden noundef nofpclass(nan inf) <4 x float> @_Z22AddFloatMatrixConstantu11matrix_typeILm4ELm4EfE(
 // CHECK-SAME: <16 x float> noundef nofpclass(nan inf) [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [4 x <4 x float>], align 4
 // CHECK-NEXT:    store <16 x float> [[M]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load <16 x float>, ptr [[M_ADDR]], align 4
@@ -157,6 +163,7 @@ float4 AddFloatMatrixConstant(float4x4 M) {
 // CHECK-LABEL: define hidden noundef <4 x i32> @_Z20AddIntMatrixConstantu11matrix_typeILm4ELm4EiE(
 // CHECK-SAME: <16 x i32> noundef [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [4 x <4 x i32>], align 4
 // CHECK-NEXT:    store <16 x i32> [[M]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load <16 x i32>, ptr [[M_ADDR]], align 4
@@ -207,6 +214,7 @@ int4 AddIntMatrixConstant(int4x4 M) {
 // CHECK-LABEL: define hidden noundef <3 x i1> @_Z23getBoolVecMatrixDynamicu11matrix_typeILm2ELm3EbEi(
 // CHECK-SAME: <6 x i1> noundef [[M:%.*]], i32 noundef [[INDEX:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [3 x <2 x i32>], align 4
 // CHECK-NEXT:    [[INDEX_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <6 x i1> [[M]] to <6 x i32>
@@ -234,6 +242,7 @@ bool3 getBoolVecMatrixDynamic(bool2x3 M, int index) {
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z24getBoolVecMatrixConstantu11matrix_typeILm4ELm4EbE(
 // CHECK-SAME: <16 x i1> noundef [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [4 x <4 x i32>], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <16 x i1> [[M]] to <16 x i32>
 // CHECK-NEXT:    store <16 x i32> [[TMP0]], ptr [[M_ADDR]], align 4
@@ -257,6 +266,7 @@ bool4 getBoolVecMatrixConstant(bool4x4 M) {
 // CHECK-LABEL: define hidden noundef i1 @_Z27getBoolScalarMatrixConstantu11matrix_typeILm3ELm1EbE(
 // CHECK-SAME: <3 x i1> noundef [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [1 x <3 x i32>], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <3 x i1> [[M]] to <3 x i32>
 // CHECK-NEXT:    store <3 x i32> [[TMP0]], ptr [[M_ADDR]], align 4
diff --git a/clang/test/CodeGenHLSL/BasicFeatures/MatrixToAndFromVectorConstructors.hlsl b/clang/test/CodeGenHLSL/BasicFeatures/MatrixToAndFromVectorConstructors.hlsl
index 76d9a78ea9df8..c75116ec6c9cd 100644
--- a/clang/test/CodeGenHLSL/BasicFeatures/MatrixToAndFromVectorConstructors.hlsl
+++ b/clang/test/CodeGenHLSL/BasicFeatures/MatrixToAndFromVectorConstructors.hlsl
@@ -4,6 +4,7 @@
 // CHECK-LABEL: define hidden noundef nofpclass(nan inf) <4 x float> @_Z2fnu11matrix_typeILm2ELm2EfE(
 // CHECK-SAME: <4 x float> noundef nofpclass(nan inf) [[M:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [2 x <2 x float>], align 4
 // CHECK-NEXT:    [[V:%.*]] = alloca <4 x float>, align 4
 // CHECK-NEXT:    store <4 x float> [[M]], ptr [[M_ADDR]], align 4
@@ -33,6 +34,7 @@ float4 fn(float2x2 m) {
 // CHECK-LABEL: define hidden noundef <4 x i32> @_Z2fnDv4_i(
 // CHECK-SAME: <4 x i32> noundef [[V:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[V_ADDR:%.*]] = alloca <4 x i32>, align 4
 // CHECK-NEXT:    [[M:%.*]] = alloca [2 x <2 x i32>], align 4
 // CHECK-NEXT:    store <4 x i32> [[V]], ptr [[V_ADDR]], align 4
@@ -62,6 +64,7 @@ int2x2 fn(int4 v) {
 // CHECK-LABEL: define hidden noundef <2 x i32> @_Z3fn1Dv2_i(
 // CHECK-SAME: <2 x i32> noundef [[V:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[V_ADDR:%.*]] = alloca <2 x i32>, align 4
 // CHECK-NEXT:    store <2 x i32> [[V]], ptr [[V_ADDR]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load <2 x i32>, ptr [[V_ADDR]], align 4
@@ -79,6 +82,7 @@ int1x2 fn1(int2 v) {
 // CHECK-LABEL: define hidden noundef <3 x i1> @_Z3fn2Dv3_b(
 // CHECK-SAME: <3 x i1> noundef [[B:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[B_ADDR:%.*]] = alloca <3 x i32>, align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <3 x i1> [[B]] to <3 x i32>
 // CHECK-NEXT:    store <3 x i32> [[TMP0]], ptr [[B_ADDR]], align 4
@@ -103,6 +107,7 @@ bool3x1 fn2(bool3 b) {
 // CHECK-LABEL: define hidden noundef <3 x i32> @_Z3fn3u11matrix_typeILm1ELm3EbE(
 // CHECK-SAME: <3 x i1> noundef [[B:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // COL-CHECK-NEXT:    [[B_ADDR:%.*]] = alloca [3 x <1 x i32>], align 4
 // ROW-CHECK-NEXT:    [[B_ADDR:%.*]] = alloca [1 x <3 x i32>], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <3 x i1> [[B]] to <3 x i32>
diff --git a/clang/test/CodeGenHLSL/BoolMatrix.hlsl b/clang/test/CodeGenHLSL/BoolMatrix.hlsl
index d237c7a5eaaca..2b21d45495156 100644
--- a/clang/test/CodeGenHLSL/BoolMatrix.hlsl
+++ b/clang/test/CodeGenHLSL/BoolMatrix.hlsl
@@ -10,6 +10,7 @@ struct S {
 // CHECK-LABEL: define hidden noundef i1 @_Z3fn1v(
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[B:%.*]] = alloca [2 x <2 x i32>], align 4
 // CHECK-NEXT:    store <4 x i32> splat (i32 1), ptr [[B]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i32>, ptr [[B]], align 4
@@ -25,6 +26,7 @@ bool fn1() {
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z3fn2b(
 // CHECK-SAME: i1 noundef [[V:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[V_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    [[A:%.*]] = alloca [2 x <2 x i32>], align 4
 // CHECK-NEXT:    [[STOREDV:%.*]] = zext i1 [[V]] to i32
@@ -51,6 +53,7 @@ bool2x2 fn2(bool V) {
 // CHECK-LABEL: define hidden noundef i1 @_Z3fn3v(
 // CHECK-SAME: ) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[S:%.*]] = alloca [[STRUCT_S:%.*]], align 1
 // CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i32(ptr align 1 [[S]], ptr align 1 @__const._Z3fn3v.s, i32 20, i1 false)
 // CHECK-NEXT:    [[BM:%.*]] = getelementptr inbounds nuw [[STRUCT_S]], ptr [[S]], i32 0, i32 0
@@ -67,6 +70,7 @@ bool fn3() {
 // CHECK-LABEL: define hidden noundef i1 @_Z3fn4v(
 // CHECK-SAME: ) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[ARR:%.*]] = alloca [2 x [2 x <2 x i32>]], align 4
 // CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[ARR]], ptr align 4 @constinit, i32 32, i1 false)
 // CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds [2 x [2 x <2 x i32>]], ptr [[ARR]], i32 0, i32 0
@@ -83,6 +87,7 @@ bool fn4() {
 // CHECK-LABEL: define hidden void @_Z3fn5v(
 // CHECK-SAME: ) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M:%.*]] = alloca [2 x <2 x i32>], align 4
 // CHECK-NEXT:    store <4 x i32> splat (i32 1), ptr [[M]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = getelementptr <4 x i32>, ptr [[M]], i32 0, i32 3
@@ -97,6 +102,7 @@ void fn5() {
 // CHECK-LABEL: define hidden void @_Z3fn6v(
 // CHECK-SAME: ) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[V:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    [[S:%.*]] = alloca [[STRUCT_S:%.*]], align 1
 // CHECK-NEXT:    store i32 0, ptr [[V]], align 4
@@ -118,6 +124,7 @@ void fn6() {
 // CHECK-LABEL: define hidden void @_Z3fn7v(
 // CHECK-SAME: ) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[ARR:%.*]] = alloca [2 x [2 x <2 x i32>]], align 4
 // CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[ARR]], ptr align 4 @constinit.1, i32 32, i1 false)
 // CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds [2 x [2 x <2 x i32>]], ptr [[ARR]], i32 0, i32 0
@@ -133,6 +140,7 @@ void fn7() {
 // CHECK-LABEL: define hidden noundef <16 x i1> @_Z3fn8u11matrix_typeILm4ELm4EbE(
 // CHECK-SAME: <16 x i1> noundef [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [4 x <4 x i32>], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <16 x i1> [[M]] to <16 x i32>
 // CHECK-NEXT:    store <16 x i32> [[TMP0]], ptr [[M_ADDR]], align 4

>From 97c765b46f8f358076ff7a35ec23ce97a85287ec Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Mon, 27 Jul 2026 16:22:14 -0600
Subject: [PATCH 05/17] Revert existing tests

---
 .../MatrixSingleSubscriptGetter.hlsl          | 41 ++++++-------
 .../MatrixToAndFromVectorConstructors.hlsl    | 20 +++----
 .../BasicFeatures/VectorElementwiseCast.hlsl  | 24 ++++----
 clang/test/CodeGenHLSL/BoolMatrix.hlsl        | 36 +++++++----
 clang/test/CodeGenHLSL/builtins/and_mat.hlsl  | 60 +++++++++----------
 clang/test/CodeGenHLSL/builtins/or.hlsl       | 60 +++++++++----------
 .../test/CodeGenHLSL/builtins/transpose.hlsl  |  5 +-
 7 files changed, 122 insertions(+), 124 deletions(-)

diff --git a/clang/test/CodeGenHLSL/BasicFeatures/MatrixSingleSubscriptGetter.hlsl b/clang/test/CodeGenHLSL/BasicFeatures/MatrixSingleSubscriptGetter.hlsl
index 6adf7e80fe0eb..07cad8214e284 100644
--- a/clang/test/CodeGenHLSL/BasicFeatures/MatrixSingleSubscriptGetter.hlsl
+++ b/clang/test/CodeGenHLSL/BasicFeatures/MatrixSingleSubscriptGetter.hlsl
@@ -222,17 +222,16 @@ int4 AddIntMatrixConstant(int4x4 M) {
 // CHECK-NEXT:    store i32 [[INDEX]], ptr [[INDEX_ADDR]], align 4
 // CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr [[INDEX_ADDR]], align 4
 // CHECK-NEXT:    [[TMP2:%.*]] = load <6 x i32>, ptr [[M_ADDR]], align 4
-// CHECK-NEXT:    [[TRUNC:%.*]] = trunc <6 x i32> [[TMP2]] to <6 x i1>
 // CHECK-NEXT:    [[TMP3:%.*]] = add i32 0, [[TMP1]]
-// CHECK-NEXT:    [[MATRIX_ELEM:%.*]] = extractelement <6 x i1> [[TRUNC]], i32 [[TMP3]]
-// CHECK-NEXT:    [[MATRIX_ROW_INS:%.*]] = insertelement <3 x i1> poison, i1 [[MATRIX_ELEM]], i32 0
+// CHECK-NEXT:    [[MATRIX_ELEM:%.*]] = extractelement <6 x i32> [[TMP2]], i32 [[TMP3]]
+// CHECK-NEXT:    [[MATRIX_ROW_INS:%.*]] = insertelement <3 x i32> poison, i32 [[MATRIX_ELEM]], i32 0
 // CHECK-NEXT:    [[TMP4:%.*]] = add i32 2, [[TMP1]]
-// CHECK-NEXT:    [[MATRIX_ELEM1:%.*]] = extractelement <6 x i1> [[TRUNC]], i32 [[TMP4]]
-// CHECK-NEXT:    [[MATRIX_ROW_INS2:%.*]] = insertelement <3 x i1> [[MATRIX_ROW_INS]], i1 [[MATRIX_ELEM1]], i32 1
+// CHECK-NEXT:    [[MATRIX_ELEM1:%.*]] = extractelement <6 x i32> [[TMP2]], i32 [[TMP4]]
+// CHECK-NEXT:    [[MATRIX_ROW_INS2:%.*]] = insertelement <3 x i32> [[MATRIX_ROW_INS]], i32 [[MATRIX_ELEM1]], i32 1
 // CHECK-NEXT:    [[TMP5:%.*]] = add i32 4, [[TMP1]]
-// CHECK-NEXT:    [[MATRIX_ELEM3:%.*]] = extractelement <6 x i1> [[TRUNC]], i32 [[TMP5]]
-// CHECK-NEXT:    [[MATRIX_ROW_INS4:%.*]] = insertelement <3 x i1> [[MATRIX_ROW_INS2]], i1 [[MATRIX_ELEM3]], i32 2
-// CHECK-NEXT:    [[LOADEDV:%.*]] = icmp ne <3 x i1> [[MATRIX_ROW_INS4]], zeroinitializer
+// CHECK-NEXT:    [[MATRIX_ELEM3:%.*]] = extractelement <6 x i32> [[TMP2]], i32 [[TMP5]]
+// CHECK-NEXT:    [[MATRIX_ROW_INS4:%.*]] = insertelement <3 x i32> [[MATRIX_ROW_INS2]], i32 [[MATRIX_ELEM3]], i32 2
+// CHECK-NEXT:    [[LOADEDV:%.*]] = icmp ne <3 x i32> [[MATRIX_ROW_INS4]], zeroinitializer
 // CHECK-NEXT:    ret <3 x i1> [[LOADEDV]]
 //
 bool3 getBoolVecMatrixDynamic(bool2x3 M, int index) {
@@ -247,16 +246,15 @@ bool3 getBoolVecMatrixDynamic(bool2x3 M, int index) {
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <16 x i1> [[M]] to <16 x i32>
 // CHECK-NEXT:    store <16 x i32> [[TMP0]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP1:%.*]] = load <16 x i32>, ptr [[M_ADDR]], align 4
-// CHECK-NEXT:    [[TRUNC:%.*]] = trunc <16 x i32> [[TMP1]] to <16 x i1>
-// CHECK-NEXT:    [[MATRIX_ELEM:%.*]] = extractelement <16 x i1> [[TRUNC]], i32 0
-// CHECK-NEXT:    [[MATRIX_ROW_INS:%.*]] = insertelement <4 x i1> poison, i1 [[MATRIX_ELEM]], i32 0
-// CHECK-NEXT:    [[MATRIX_ELEM1:%.*]] = extractelement <16 x i1> [[TRUNC]], i32 4
-// CHECK-NEXT:    [[MATRIX_ROW_INS2:%.*]] = insertelement <4 x i1> [[MATRIX_ROW_INS]], i1 [[MATRIX_ELEM1]], i32 1
-// CHECK-NEXT:    [[MATRIX_ELEM3:%.*]] = extractelement <16 x i1> [[TRUNC]], i32 8
-// CHECK-NEXT:    [[MATRIX_ROW_INS4:%.*]] = insertelement <4 x i1> [[MATRIX_ROW_INS2]], i1 [[MATRIX_ELEM3]], i32 2
-// CHECK-NEXT:    [[MATRIX_ELEM5:%.*]] = extractelement <16 x i1> [[TRUNC]], i32 12
-// CHECK-NEXT:    [[MATRIX_ROW_INS6:%.*]] = insertelement <4 x i1> [[MATRIX_ROW_INS4]], i1 [[MATRIX_ELEM5]], i32 3
-// CHECK-NEXT:    [[LOADEDV:%.*]] = icmp ne <4 x i1> [[MATRIX_ROW_INS6]], zeroinitializer
+// CHECK-NEXT:    [[MATRIX_ELEM:%.*]] = extractelement <16 x i32> [[TMP1]], i32 0
+// CHECK-NEXT:    [[MATRIX_ROW_INS:%.*]] = insertelement <4 x i32> poison, i32 [[MATRIX_ELEM]], i32 0
+// CHECK-NEXT:    [[MATRIX_ELEM1:%.*]] = extractelement <16 x i32> [[TMP1]], i32 4
+// CHECK-NEXT:    [[MATRIX_ROW_INS2:%.*]] = insertelement <4 x i32> [[MATRIX_ROW_INS]], i32 [[MATRIX_ELEM1]], i32 1
+// CHECK-NEXT:    [[MATRIX_ELEM3:%.*]] = extractelement <16 x i32> [[TMP1]], i32 8
+// CHECK-NEXT:    [[MATRIX_ROW_INS4:%.*]] = insertelement <4 x i32> [[MATRIX_ROW_INS2]], i32 [[MATRIX_ELEM3]], i32 2
+// CHECK-NEXT:    [[MATRIX_ELEM5:%.*]] = extractelement <16 x i32> [[TMP1]], i32 12
+// CHECK-NEXT:    [[MATRIX_ROW_INS6:%.*]] = insertelement <4 x i32> [[MATRIX_ROW_INS4]], i32 [[MATRIX_ELEM5]], i32 3
+// CHECK-NEXT:    [[LOADEDV:%.*]] = icmp ne <4 x i32> [[MATRIX_ROW_INS6]], zeroinitializer
 // CHECK-NEXT:    ret <4 x i1> [[LOADEDV]]
 //
 bool4 getBoolVecMatrixConstant(bool4x4 M) {
@@ -271,10 +269,9 @@ bool4 getBoolVecMatrixConstant(bool4x4 M) {
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <3 x i1> [[M]] to <3 x i32>
 // CHECK-NEXT:    store <3 x i32> [[TMP0]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP1:%.*]] = load <3 x i32>, ptr [[M_ADDR]], align 4
-// CHECK-NEXT:    [[TRUNC:%.*]] = trunc <3 x i32> [[TMP1]] to <3 x i1>
-// CHECK-NEXT:    [[MATRIX_ELEM:%.*]] = extractelement <3 x i1> [[TRUNC]], i32 1
-// CHECK-NEXT:    [[MATRIX_ROW_INS:%.*]] = insertelement <1 x i1> poison, i1 [[MATRIX_ELEM]], i32 0
-// CHECK-NEXT:    [[LOADEDV:%.*]] = icmp ne <1 x i1> [[MATRIX_ROW_INS]], zeroinitializer
+// CHECK-NEXT:    [[MATRIX_ELEM:%.*]] = extractelement <3 x i32> [[TMP1]], i32 1
+// CHECK-NEXT:    [[MATRIX_ROW_INS:%.*]] = insertelement <1 x i32> poison, i32 [[MATRIX_ELEM]], i32 0
+// CHECK-NEXT:    [[LOADEDV:%.*]] = icmp ne <1 x i32> [[MATRIX_ROW_INS]], zeroinitializer
 // CHECK-NEXT:    [[CAST_VTRUNC:%.*]] = extractelement <1 x i1> [[LOADEDV]], i32 0
 // CHECK-NEXT:    ret i1 [[CAST_VTRUNC]]
 //
diff --git a/clang/test/CodeGenHLSL/BasicFeatures/MatrixToAndFromVectorConstructors.hlsl b/clang/test/CodeGenHLSL/BasicFeatures/MatrixToAndFromVectorConstructors.hlsl
index c75116ec6c9cd..358f976126f55 100644
--- a/clang/test/CodeGenHLSL/BasicFeatures/MatrixToAndFromVectorConstructors.hlsl
+++ b/clang/test/CodeGenHLSL/BasicFeatures/MatrixToAndFromVectorConstructors.hlsl
@@ -113,21 +113,15 @@ bool3x1 fn2(bool3 b) {
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <3 x i1> [[B]] to <3 x i32>
 // CHECK-NEXT:    store <3 x i32> [[TMP0]], ptr [[B_ADDR]], align 4
 // CHECK-NEXT:    [[TMP1:%.*]] = load <3 x i32>, ptr [[B_ADDR]], align 4
-// CHECK-NEXT:    [[TRUNC1:%.*]] = trunc <3 x i32> [[TMP1]] to <3 x i1>
-// CHECK-NEXT:    [[MATRIXEXT1:%.*]] = extractelement <3 x i1> [[TRUNC1]], i32 0
-// CHECK-NEXT:    [[CONV1:%.*]] = zext i1 [[MATRIXEXT1]] to i32
-// CHECK-NEXT:    [[VECINIT1:%.*]] = insertelement <3 x i32> poison, i32 [[CONV1]], i32 0
+// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <3 x i32> [[TMP1]], i32 0
+// CHECK-NEXT:    [[VECINIT:%.*]] = insertelement <3 x i32> poison, i32 [[MATRIXEXT]], i32 0
 // CHECK-NEXT:    [[TMP2:%.*]] = load <3 x i32>, ptr [[B_ADDR]], align 4
-// CHECK-NEXT:    [[TRUNC2:%.*]] = trunc <3 x i32> [[TMP2]] to <3 x i1>
-// CHECK-NEXT:    [[MATRIXEXT2:%.*]] = extractelement <3 x i1> [[TRUNC2]], i32 1
-// CHECK-NEXT:    [[CONV2:%.*]] = zext i1 [[MATRIXEXT2]] to i32
-// CHECK-NEXT:    [[VECINIT2:%.*]] = insertelement <3 x i32> [[VECINIT1]], i32 [[CONV2]], i32 1
+// CHECK-NEXT:    [[MATRIXEXT1:%.*]] = extractelement <3 x i32> [[TMP2]], i32 1
+// CHECK-NEXT:    [[VECINIT2:%.*]] = insertelement <3 x i32> [[VECINIT]], i32 [[MATRIXEXT1]], i32 1
 // CHECK-NEXT:    [[TMP3:%.*]] = load <3 x i32>, ptr [[B_ADDR]], align 4
-// CHECK-NEXT:    [[TRUNC3:%.*]] = trunc <3 x i32> [[TMP3]] to <3 x i1>
-// CHECK-NEXT:    [[MATRIXEXT3:%.*]] = extractelement <3 x i1> [[TRUNC3]], i32 2
-// CHECK-NEXT:    [[CONV3:%.*]] = zext i1 [[MATRIXEXT3]] to i32
-// CHECK-NEXT:    [[VECINIT3:%.*]] = insertelement <3 x i32> [[VECINIT2]], i32 [[CONV3]], i32 2
-// CHECK-NEXT:    ret <3 x i32> [[VECINIT3]]
+// CHECK-NEXT:    [[MATRIXEXT3:%.*]] = extractelement <3 x i32> [[TMP3]], i32 2
+// CHECK-NEXT:    [[VECINIT4:%.*]] = insertelement <3 x i32> [[VECINIT2]], i32 [[MATRIXEXT3]], i32 2
+// CHECK-NEXT:    ret <3 x i32> [[VECINIT4]]
 //
 int3 fn3(bool1x3 b) {
     return b;
diff --git a/clang/test/CodeGenHLSL/BasicFeatures/VectorElementwiseCast.hlsl b/clang/test/CodeGenHLSL/BasicFeatures/VectorElementwiseCast.hlsl
index 8902248baa063..89f5ff8f16825 100644
--- a/clang/test/CodeGenHLSL/BasicFeatures/VectorElementwiseCast.hlsl
+++ b/clang/test/CodeGenHLSL/BasicFeatures/VectorElementwiseCast.hlsl
@@ -197,21 +197,19 @@ export void call8(int3x1 M) {
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <2 x i1> %M to <2 x i32>
 // CHECK-NEXT:    store <2 x i32> [[TMP0]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP1:%.*]] = load <2 x i32>, ptr [[M_ADDR]], align 4
-// CHECK-NEXT:    [[LOADEDV0:%.*]] = trunc <2 x i32> [[TMP1]] to <2 x i1>
-// CHECK-NEXT:    [[TMP2:%.*]] = zext <2 x i1> [[LOADEDV0]] to <2 x i32>
-// CHECK-NEXT:    store <2 x i32> [[TMP2]], ptr [[HLSL_EWCAST_SRC]], align 4
+// CHECK-NEXT:    store <2 x i32> [[TMP1]], ptr [[HLSL_EWCAST_SRC]], align 4
 // CHECK-NEXT:    [[MATRIX_GEP:%.*]] = getelementptr inbounds <2 x i32>, ptr [[HLSL_EWCAST_SRC]], i32 0
-// CHECK-NEXT:    [[TMP3:%.*]] = load <2 x i1>, ptr [[FLATCAST_TMP]], align 4
-// CHECK-NEXT:    [[TMP4:%.*]] = load <2 x i32>, ptr [[MATRIX_GEP]], align 4
-// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <2 x i32> [[TMP4]], i32 0
-// CHECK-NEXT:    [[LOADEDV1:%.*]] = icmp ne i32 [[MATRIXEXT]], 0
-// CHECK-NEXT:    [[TMP5:%.*]] = insertelement <2 x i1> [[TMP3]], i1 [[LOADEDV1]], i64 0
-// CHECK-NEXT:    [[TMP6:%.*]] = load <2 x i32>, ptr [[MATRIX_GEP]], align 4
-// CHECK-NEXT:    [[MATRIXEXT1:%.*]] = extractelement <2 x i32> [[TMP6]], i32 1
+// CHECK-NEXT:    [[TMP2:%.*]] = load <2 x i1>, ptr [[FLATCAST_TMP]], align 4
+// CHECK-NEXT:    [[TMP3:%.*]] = load <2 x i32>, ptr [[MATRIX_GEP]], align 4
+// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <2 x i32> [[TMP3]], i32 0
+// CHECK-NEXT:    [[LOADEDV:%.*]] = icmp ne i32 [[MATRIXEXT]], 0
+// CHECK-NEXT:    [[TMP4:%.*]] = insertelement <2 x i1> [[TMP2]], i1 [[LOADEDV]], i64 0
+// CHECK-NEXT:    [[TMP5:%.*]] = load <2 x i32>, ptr [[MATRIX_GEP]], align 4
+// CHECK-NEXT:    [[MATRIXEXT1:%.*]] = extractelement <2 x i32> [[TMP5]], i32 1
 // CHECK-NEXT:    [[LOADEDV2:%.*]] = icmp ne i32 [[MATRIXEXT1]], 0
-// CHECK-NEXT:    [[TMP7:%.*]] = insertelement <2 x i1> [[TMP5]], i1 [[LOADEDV2]], i64 1
-// CHECK-NEXT:    [[TMP8:%.*]] = zext <2 x i1> [[TMP7]] to <2 x i32>
-// CHECK-NEXT:    store <2 x i32> [[TMP8]], ptr [[V]], align 4
+// CHECK-NEXT:    [[TMP6:%.*]] = insertelement <2 x i1> [[TMP4]], i1 [[LOADEDV2]], i64 1
+// CHECK-NEXT:    [[TMP7:%.*]] = zext <2 x i1> [[TMP6]] to <2 x i32>
+// CHECK-NEXT:    store <2 x i32> [[TMP7]], ptr [[V]], align 4
 // CHECK-NEXT:    ret void
 export void call9(bool1x2 M) {
     bool2 V = (bool2)M;
diff --git a/clang/test/CodeGenHLSL/BoolMatrix.hlsl b/clang/test/CodeGenHLSL/BoolMatrix.hlsl
index 2b21d45495156..eeb2fa83d4656 100644
--- a/clang/test/CodeGenHLSL/BoolMatrix.hlsl
+++ b/clang/test/CodeGenHLSL/BoolMatrix.hlsl
@@ -11,12 +11,14 @@ struct S {
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
+// CHECK-NEXT:    [[RETVAL:%.*]] = alloca i1, align 4
 // CHECK-NEXT:    [[B:%.*]] = alloca [2 x <2 x i32>], align 4
 // CHECK-NEXT:    store <4 x i32> splat (i32 1), ptr [[B]], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i32>, ptr [[B]], align 4
-// CHECK-NEXT:    [[LOADEDV:%.*]] = trunc <4 x i32> [[TMP0]] to <4 x i1>
-// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <4 x i1> [[LOADEDV]], i32 0
-// CHECK-NEXT:    ret i1 [[MATRIXEXT]]
+// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <4 x i32> [[TMP0]], i32 0
+// CHECK-NEXT:    store i32 [[MATRIXEXT]], ptr [[RETVAL]], align 4
+// CHECK-NEXT:    [[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 4
+// CHECK-NEXT:    ret i1 [[TMP1]]
 //
 bool fn1() {
   bool2x2 B = {true,true,true,true};
@@ -27,6 +29,7 @@ bool fn1() {
 // CHECK-SAME: i1 noundef [[V:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
+// CHECK-NEXT:    [[RETVAL:%.*]] = alloca <4 x i1>, align 4
 // CHECK-NEXT:    [[V_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:    [[A:%.*]] = alloca [2 x <2 x i32>], align 4
 // CHECK-NEXT:    [[STOREDV:%.*]] = zext i1 [[V]] to i32
@@ -42,8 +45,9 @@ bool fn1() {
 // CHECK-NEXT:    [[TMP2:%.*]] = zext <4 x i1> [[VECINIT4]] to <4 x i32>
 // CHECK-NEXT:    store <4 x i32> [[TMP2]], ptr [[A]], align 4
 // CHECK-NEXT:    [[TMP3:%.*]] = load <4 x i32>, ptr [[A]], align 4
-// CHECK-NEXT:    [[TRUNC:%.*]] = trunc <4 x i32> [[TMP3]] to <4 x i1>
-// CHECK-NEXT:    ret <4 x i1> [[TRUNC]]
+// CHECK-NEXT:    store <4 x i32> [[TMP3]], ptr [[RETVAL]], align 4
+// CHECK-NEXT:    [[TMP4:%.*]] = load <4 x i1>, ptr [[RETVAL]], align 4
+// CHECK-NEXT:    ret <4 x i1> [[TMP4]]
 //
 bool2x2 fn2(bool V) {
   bool2x2 A = {V, true, V, false};
@@ -54,13 +58,15 @@ bool2x2 fn2(bool V) {
 // CHECK-SAME: ) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
+// CHECK-NEXT:    [[RETVAL:%.*]] = alloca i1, align 4
 // CHECK-NEXT:    [[S:%.*]] = alloca [[STRUCT_S:%.*]], align 1
 // CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i32(ptr align 1 [[S]], ptr align 1 @__const._Z3fn3v.s, i32 20, i1 false)
 // CHECK-NEXT:    [[BM:%.*]] = getelementptr inbounds nuw [[STRUCT_S]], ptr [[S]], i32 0, i32 0
 // CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i32>, ptr [[BM]], align 1
-// CHECK-NEXT:    [[TRUNC:%.*]] = trunc <4 x i32> [[TMP0]] to <4 x i1>
-// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <4 x i1> [[TRUNC]], i32 0
-// CHECK-NEXT:    ret i1 [[MATRIXEXT]]
+// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <4 x i32> [[TMP0]], i32 0
+// CHECK-NEXT:    store i32 [[MATRIXEXT]], ptr [[RETVAL]], align 4
+// CHECK-NEXT:    [[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 4
+// CHECK-NEXT:    ret i1 [[TMP1]]
 //
 bool fn3() {
   S s = {{true,true,false,false}, 1.0};
@@ -71,13 +77,15 @@ bool fn3() {
 // CHECK-SAME: ) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
+// CHECK-NEXT:    [[RETVAL:%.*]] = alloca i1, align 4
 // CHECK-NEXT:    [[ARR:%.*]] = alloca [2 x [2 x <2 x i32>]], align 4
 // CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[ARR]], ptr align 4 @constinit, i32 32, i1 false)
 // CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds [2 x [2 x <2 x i32>]], ptr [[ARR]], i32 0, i32 0
 // CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i32>, ptr [[ARRAYIDX]], align 4
-// CHECK-NEXT:    [[TRUNC:%.*]] = trunc <4 x i32> [[TMP0]] to <4 x i1>
-// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <4 x i1> [[TRUNC]], i32 1
-// CHECK-NEXT:    ret i1 [[MATRIXEXT]]
+// CHECK-NEXT:    [[MATRIXEXT:%.*]] = extractelement <4 x i32> [[TMP0]], i32 1
+// CHECK-NEXT:    store i32 [[MATRIXEXT]], ptr [[RETVAL]], align 4
+// CHECK-NEXT:    [[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 4
+// CHECK-NEXT:    ret i1 [[TMP1]]
 //
 bool fn4() {
   bool2x2 Arr[2] = {{true,true,true,true}, {false,false,false,false}};
@@ -141,12 +149,14 @@ void fn7() {
 // CHECK-SAME: <16 x i1> noundef [[M:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:    %[[#C_ENTRY:]] = call token @llvm.experimental.convergence.entry()
+// CHECK-NEXT:    [[RETVAL:%.*]] = alloca <16 x i1>, align 4
 // CHECK-NEXT:    [[M_ADDR:%.*]] = alloca [4 x <4 x i32>], align 4
 // CHECK-NEXT:    [[TMP0:%.*]] = zext <16 x i1> [[M]] to <16 x i32>
 // CHECK-NEXT:    store <16 x i32> [[TMP0]], ptr [[M_ADDR]], align 4
 // CHECK-NEXT:    [[TMP1:%.*]] = load <16 x i32>, ptr [[M_ADDR]], align 4
-// CHECK-NEXT:    [[TRUNC:%.*]] = trunc <16 x i32> [[TMP1]] to <16 x i1>
-// CHECK-NEXT:    ret <16 x i1> [[TRUNC]]
+// CHECK-NEXT:    store <16 x i32> [[TMP1]], ptr [[RETVAL]], align 4
+// CHECK-NEXT:    [[TMP2:%.*]] = load <16 x i1>, ptr [[RETVAL]], align 4
+// CHECK-NEXT:    ret <16 x i1> [[TMP2]]
 //
 bool4x4 fn8(bool4x4 m) {
   return m;
diff --git a/clang/test/CodeGenHLSL/builtins/and_mat.hlsl b/clang/test/CodeGenHLSL/builtins/and_mat.hlsl
index 66c87c5de9453..c070dd90d9568 100644
--- a/clang/test/CodeGenHLSL/builtins/and_mat.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/and_mat.hlsl
@@ -5,8 +5,8 @@
 // CHECK-LABEL: define hidden noundef <2 x i1> @_Z16test_and_bool1x2u11matrix_typeILm1ELm2EbES_(
 // CHECK-SAME: <2 x i1> noundef [[X:%.*]], <2 x i1> noundef [[Y:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <2 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <2 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <2 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <2 x i1> [[HLSL_AND_CAST:%.*]]
 bool1x2 test_and_bool1x2(bool1x2 x, bool1x2 y)
 {
     return and(x, y);
@@ -15,8 +15,8 @@ bool1x2 test_and_bool1x2(bool1x2 x, bool1x2 y)
 // CHECK-LABEL: define hidden noundef <3 x i1> @_Z16test_and_bool1x3u11matrix_typeILm1ELm3EbES_(
 // CHECK-SAME: <3 x i1> noundef [[X:%.*]], <3 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <3 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <3 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <3 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <3 x i1> [[HLSL_AND_CAST:%.*]]
 bool1x3 test_and_bool1x3(bool1x3 x, bool1x3 y)
 {
     return and(x, y);
@@ -25,8 +25,8 @@ bool1x3 test_and_bool1x3(bool1x3 x, bool1x3 y)
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z16test_and_bool1x4u11matrix_typeILm1ELm4EbES_(
 // CHECK-SAME: <4 x i1> noundef [[X:%.*]], <4 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <4 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <4 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <4 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <4 x i1> [[HLSL_AND_CAST:%.*]]
 bool1x4 test_and_bool1x4(bool1x4 x, bool1x4 y)
 {
     return and(x, y);
@@ -35,8 +35,8 @@ bool1x4 test_and_bool1x4(bool1x4 x, bool1x4 y)
 // CHECK-LABEL: define hidden noundef <2 x i1> @_Z16test_and_bool2x1u11matrix_typeILm2ELm1EbES_(
 // CHECK-SAME: <2 x i1> noundef [[X:%.*]], <2 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <2 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <2 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <2 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <2 x i1> [[HLSL_AND_CAST:%.*]]
 bool2x1 test_and_bool2x1(bool2x1 x, bool2x1 y)
 {
     return and(x, y);
@@ -46,8 +46,8 @@ bool2x1 test_and_bool2x1(bool2x1 x, bool2x1 y)
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z16test_and_bool2x2u11matrix_typeILm2ELm2EbES_(
 // CHECK-SAME: <4 x i1> noundef [[X:%.*]], <4 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <4 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <4 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <4 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <4 x i1> [[HLSL_AND_CAST:%.*]]
 bool2x2 test_and_bool2x2(bool2x2 x, bool2x2 y)
 {
     return and(x, y);
@@ -56,8 +56,8 @@ bool2x2 test_and_bool2x2(bool2x2 x, bool2x2 y)
 // CHECK-LABEL: define hidden noundef <6 x i1> @_Z16test_and_bool2x3u11matrix_typeILm2ELm3EbES_(
 // CHECK-SAME: <6 x i1> noundef [[X:%.*]], <6 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <6 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <6 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <6 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <6 x i1> [[HLSL_AND_CAST:%.*]]
 bool2x3 test_and_bool2x3(bool2x3 x, bool2x3 y)
 {
     return and(x, y);
@@ -66,8 +66,8 @@ bool2x3 test_and_bool2x3(bool2x3 x, bool2x3 y)
 // CHECK-LABEL: define hidden noundef <8 x i1> @_Z16test_and_bool2x4u11matrix_typeILm2ELm4EbES_(
 // CHECK-SAME: <8 x i1> noundef [[X:%.*]], <8 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <8 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <8 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <8 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <8 x i1> [[HLSL_AND_CAST:%.*]]
 bool2x4 test_and_bool2x4(bool2x4 x, bool2x4 y)
 {
     return and(x, y);
@@ -76,8 +76,8 @@ bool2x4 test_and_bool2x4(bool2x4 x, bool2x4 y)
 // CHECK-LABEL: define hidden noundef <3 x i1> @_Z16test_and_bool3x1u11matrix_typeILm3ELm1EbES_(
 // CHECK-SAME: <3 x i1> noundef [[X:%.*]], <3 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <3 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <3 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <3 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <3 x i1> [[HLSL_AND_CAST:%.*]]
 bool3x1 test_and_bool3x1(bool3x1 x, bool3x1 y)
 {
     return and(x, y);
@@ -86,8 +86,8 @@ bool3x1 test_and_bool3x1(bool3x1 x, bool3x1 y)
 // CHECK-LABEL: define hidden noundef <6 x i1> @_Z16test_and_bool3x2u11matrix_typeILm3ELm2EbES_(
 // CHECK-SAME: <6 x i1> noundef [[X:%.*]], <6 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <6 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <6 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <6 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <6 x i1> [[HLSL_AND_CAST:%.*]]
 bool3x2 test_and_bool3x2(bool3x2 x, bool3x2 y)
 {
     return and(x, y);
@@ -97,8 +97,8 @@ bool3x2 test_and_bool3x2(bool3x2 x, bool3x2 y)
 // CHECK-LABEL: define hidden noundef <9 x i1> @_Z16test_and_bool3x3u11matrix_typeILm3ELm3EbES_(
 // CHECK-SAME: <9 x i1> noundef [[X:%.*]], <9 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <9 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <9 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <9 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <9 x i1> [[HLSL_AND_CAST:%.*]]
 bool3x3 test_and_bool3x3(bool3x3 x, bool3x3 y)
 {
     return and(x, y);
@@ -107,8 +107,8 @@ bool3x3 test_and_bool3x3(bool3x3 x, bool3x3 y)
 // CHECK-LABEL: define hidden noundef <12 x i1> @_Z16test_and_bool3x4u11matrix_typeILm3ELm4EbES_(
 // CHECK-SAME: <12 x i1> noundef [[X:%.*]], <12 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <12 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <12 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <12 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <12 x i1> [[HLSL_AND_CAST:%.*]]
 bool3x4 test_and_bool3x4(bool3x4 x, bool3x4 y)
 {
     return and(x, y);
@@ -117,8 +117,8 @@ bool3x4 test_and_bool3x4(bool3x4 x, bool3x4 y)
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z16test_and_bool4x1u11matrix_typeILm4ELm1EbES_(
 // CHECK-SAME: <4 x i1> noundef [[X:%.*]], <4 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <4 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <4 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <4 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <4 x i1> [[HLSL_AND_CAST:%.*]]
 bool4x1 test_and_bool4x1(bool4x1 x, bool4x1 y)
 {
     return and(x, y);
@@ -127,8 +127,8 @@ bool4x1 test_and_bool4x1(bool4x1 x, bool4x1 y)
 // CHECK-LABEL: define hidden noundef <8 x i1> @_Z16test_and_bool4x2u11matrix_typeILm4ELm2EbES_(
 // CHECK-SAME: <8 x i1> noundef [[X:%.*]], <8 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <8 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <8 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <8 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <8 x i1> [[HLSL_AND_CAST:%.*]]
 bool4x2 test_and_bool4x2(bool4x2 x, bool4x2 y)
 {
     return and(x, y);
@@ -137,8 +137,8 @@ bool4x2 test_and_bool4x2(bool4x2 x, bool4x2 y)
 // CHECK-LABEL: define hidden noundef <12 x i1> @_Z16test_and_bool4x3u11matrix_typeILm4ELm3EbES_(
 // CHECK-SAME: <12 x i1> noundef [[X:%.*]], <12 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <12 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <12 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <12 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <12 x i1> [[HLSL_AND_CAST:%.*]]
 bool4x3 test_and_bool4x3(bool4x3 x, bool4x3 y)
 {
     return and(x, y);
@@ -147,8 +147,8 @@ bool4x3 test_and_bool4x3(bool4x3 x, bool4x3 y)
 // CHECK-LABEL: define hidden noundef <16 x i1> @_Z16test_and_bool4x4u11matrix_typeILm4ELm4EbES_(
 // CHECK-SAME: <16 x i1> noundef [[X:%.*]], <16 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_AND:%.*]] = and <16 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <16 x i1> [[HLSL_AND]]
+// CHECK:         [[HLSL_AND:%.*]] = and <16 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <16 x i1> [[HLSL_AND_CAST:%.*]]
 bool4x4 test_and_bool4x4(bool4x4 x, bool4x4 y)
 {
     return and(x, y);
diff --git a/clang/test/CodeGenHLSL/builtins/or.hlsl b/clang/test/CodeGenHLSL/builtins/or.hlsl
index bd6f9c3f21d49..cf07d2fb7b42b 100644
--- a/clang/test/CodeGenHLSL/builtins/or.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/or.hlsl
@@ -81,8 +81,8 @@ bool4 test_or_float4(float4 x, float4 y)
 // CHECK-LABEL: define hidden noundef <2 x i1> @_Z15test_or_bool1x2u11matrix_typeILm1ELm2EbES_(
 // CHECK-SAME: <2 x i1> noundef [[X:%.*]], <2 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <2 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <2 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <2 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <2 x i1> [[HLSL_OR_CAST:%.*]]
 bool1x2 test_or_bool1x2(bool1x2 x, bool1x2 y)
 {
     return or(x, y);
@@ -91,8 +91,8 @@ bool1x2 test_or_bool1x2(bool1x2 x, bool1x2 y)
 // CHECK-LABEL: define hidden noundef <3 x i1> @_Z15test_or_bool1x3u11matrix_typeILm1ELm3EbES_(
 // CHECK-SAME: <3 x i1> noundef [[X:%.*]], <3 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <3 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <3 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <3 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <3 x i1> [[HLSL_OR_CAST:%.*]]
 bool1x3 test_or_bool1x3(bool1x3 x, bool1x3 y)
 {
     return or(x, y);
@@ -101,8 +101,8 @@ bool1x3 test_or_bool1x3(bool1x3 x, bool1x3 y)
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z15test_or_bool1x4u11matrix_typeILm1ELm4EbES_(
 // CHECK-SAME: <4 x i1> noundef [[X:%.*]], <4 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <4 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <4 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <4 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <4 x i1> [[HLSL_OR_CAST:%.*]]
 bool1x4 test_or_bool1x4(bool1x4 x, bool1x4 y)
 {
     return or(x, y);
@@ -111,8 +111,8 @@ bool1x4 test_or_bool1x4(bool1x4 x, bool1x4 y)
 // CHECK-LABEL: define hidden noundef <2 x i1> @_Z15test_or_bool2x1u11matrix_typeILm2ELm1EbES_(
 // CHECK-SAME: <2 x i1> noundef [[X:%.*]], <2 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <2 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <2 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <2 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <2 x i1> [[HLSL_OR_CAST:%.*]]
 bool2x1 test_or_bool2x1(bool2x1 x, bool2x1 y)
 {
     return or(x, y);
@@ -122,8 +122,8 @@ bool2x1 test_or_bool2x1(bool2x1 x, bool2x1 y)
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z15test_or_bool2x2u11matrix_typeILm2ELm2EbES_(
 // CHECK-SAME: <4 x i1> noundef [[X:%.*]], <4 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <4 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <4 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <4 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <4 x i1> [[HLSL_OR_CAST:%.*]]
 bool2x2 test_or_bool2x2(bool2x2 x, bool2x2 y)
 {
     return or(x, y);
@@ -132,8 +132,8 @@ bool2x2 test_or_bool2x2(bool2x2 x, bool2x2 y)
 // CHECK-LABEL: define hidden noundef <6 x i1> @_Z15test_or_bool2x3u11matrix_typeILm2ELm3EbES_(
 // CHECK-SAME: <6 x i1> noundef [[X:%.*]], <6 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <6 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <6 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <6 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <6 x i1> [[HLSL_OR_CAST:%.*]]
 bool2x3 test_or_bool2x3(bool2x3 x, bool2x3 y)
 {
     return or(x, y);
@@ -142,8 +142,8 @@ bool2x3 test_or_bool2x3(bool2x3 x, bool2x3 y)
 // CHECK-LABEL: define hidden noundef <8 x i1> @_Z15test_or_bool2x4u11matrix_typeILm2ELm4EbES_(
 // CHECK-SAME: <8 x i1> noundef [[X:%.*]], <8 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <8 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <8 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <8 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <8 x i1> [[HLSL_OR_CAST:%.*]]
 bool2x4 test_or_bool2x4(bool2x4 x, bool2x4 y)
 {
     return or(x, y);
@@ -152,8 +152,8 @@ bool2x4 test_or_bool2x4(bool2x4 x, bool2x4 y)
 // CHECK-LABEL: define hidden noundef <3 x i1> @_Z15test_or_bool3x1u11matrix_typeILm3ELm1EbES_(
 // CHECK-SAME: <3 x i1> noundef [[X:%.*]], <3 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <3 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <3 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <3 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <3 x i1> [[HLSL_OR_CAST:%.*]]
 bool3x1 test_or_bool3x1(bool3x1 x, bool3x1 y)
 {
     return or(x, y);
@@ -162,8 +162,8 @@ bool3x1 test_or_bool3x1(bool3x1 x, bool3x1 y)
 // CHECK-LABEL: define hidden noundef <6 x i1> @_Z15test_or_bool3x2u11matrix_typeILm3ELm2EbES_(
 // CHECK-SAME: <6 x i1> noundef [[X:%.*]], <6 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <6 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <6 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <6 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <6 x i1> [[HLSL_OR_CAST:%.*]]
 bool3x2 test_or_bool3x2(bool3x2 x, bool3x2 y)
 {
     return or(x, y);
@@ -173,8 +173,8 @@ bool3x2 test_or_bool3x2(bool3x2 x, bool3x2 y)
 // CHECK-LABEL: define hidden noundef <9 x i1> @_Z15test_or_bool3x3u11matrix_typeILm3ELm3EbES_(
 // CHECK-SAME: <9 x i1> noundef [[X:%.*]], <9 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <9 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <9 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <9 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <9 x i1> [[HLSL_OR_CAST:%.*]]
 bool3x3 test_or_bool3x3(bool3x3 x, bool3x3 y)
 {
     return or(x, y);
@@ -183,8 +183,8 @@ bool3x3 test_or_bool3x3(bool3x3 x, bool3x3 y)
 // CHECK-LABEL: define hidden noundef <12 x i1> @_Z15test_or_bool3x4u11matrix_typeILm3ELm4EbES_(
 // CHECK-SAME: <12 x i1> noundef [[X:%.*]], <12 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <12 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <12 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <12 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <12 x i1> [[HLSL_OR_CAST:%.*]]
 bool3x4 test_or_bool3x4(bool3x4 x, bool3x4 y)
 {
     return or(x, y);
@@ -193,8 +193,8 @@ bool3x4 test_or_bool3x4(bool3x4 x, bool3x4 y)
 // CHECK-LABEL: define hidden noundef <4 x i1> @_Z15test_or_bool4x1u11matrix_typeILm4ELm1EbES_(
 // CHECK-SAME: <4 x i1> noundef [[X:%.*]], <4 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <4 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <4 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <4 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <4 x i1> [[HLSL_OR_CAST:%.*]]
 bool4x1 test_or_bool4x1(bool4x1 x, bool4x1 y)
 {
     return or(x, y);
@@ -203,8 +203,8 @@ bool4x1 test_or_bool4x1(bool4x1 x, bool4x1 y)
 // CHECK-LABEL: define hidden noundef <8 x i1> @_Z15test_or_bool4x2u11matrix_typeILm4ELm2EbES_(
 // CHECK-SAME: <8 x i1> noundef [[X:%.*]], <8 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <8 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <8 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <8 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <8 x i1> [[HLSL_OR_CAST:%.*]]
 bool4x2 test_or_bool4x2(bool4x2 x, bool4x2 y)
 {
     return or(x, y);
@@ -213,8 +213,8 @@ bool4x2 test_or_bool4x2(bool4x2 x, bool4x2 y)
 // CHECK-LABEL: define hidden noundef <12 x i1> @_Z15test_or_bool4x3u11matrix_typeILm4ELm3EbES_(
 // CHECK-SAME: <12 x i1> noundef [[X:%.*]], <12 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <12 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <12 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <12 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <12 x i1> [[HLSL_OR_CAST:%.*]]
 bool4x3 test_or_bool4x3(bool4x3 x, bool4x3 y)
 {
     return or(x, y);
@@ -223,8 +223,8 @@ bool4x3 test_or_bool4x3(bool4x3 x, bool4x3 y)
 // CHECK-LABEL: define hidden noundef <16 x i1> @_Z15test_or_bool4x4u11matrix_typeILm4ELm4EbES_(
 // CHECK-SAME: <16 x i1> noundef [[X:%.*]], <16 x i1> noundef [[Y:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK:         [[HLSL_OR:%.*]] = or <16 x i1> [[A:%.*]], [[B:%.*]]
-// CHECK:         ret <16 x i1> [[HLSL_OR]]
+// CHECK:         [[HLSL_OR:%.*]] = or <16 x i32> [[A:%.*]], [[B:%.*]]
+// CHECK:         ret <16 x i1> [[HLSL_OR_CAST:%.*]]
 bool4x4 test_or_bool4x4(bool4x4 x, bool4x4 y)
 {
     return or(x, y);
diff --git a/clang/test/CodeGenHLSL/builtins/transpose.hlsl b/clang/test/CodeGenHLSL/builtins/transpose.hlsl
index 0863fba6190c1..d8430fcf5bf9d 100644
--- a/clang/test/CodeGenHLSL/builtins/transpose.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/transpose.hlsl
@@ -9,9 +9,8 @@
 // CHECK:       [[A_EXT:%.*]] = zext <6 x i1> %{{.*}} to <6 x i32>
 // CHECK:       store <6 x i32> [[A_EXT]], ptr [[A_ADDR]], align 4
 // CHECK:       [[A:%.*]] = load <6 x i32>, ptr [[A_ADDR]], align 4
-// CHECK:       [[TRUNC:%.*]] = trunc <6 x i32> [[A]] to <6 x i1>
-// COLMAJOR:    [[TRANS:%.*]] = call <6 x i1> @llvm.matrix.transpose.v6i1(<6 x i1> [[TRUNC]], i32 2, i32 3)
-// ROWMAJOR:    [[TRANS:%.*]] = call <6 x i1> @llvm.matrix.transpose.v6i1(<6 x i1> [[TRUNC]], i32 3, i32 2)
+// COLMAJOR:    [[TRANS:%.*]] = call <6 x i32> @llvm.matrix.transpose.v6i32(<6 x i32> [[A]], i32 2, i32 3)
+// ROWMAJOR:    [[TRANS:%.*]] = call <6 x i32> @llvm.matrix.transpose.v6i32(<6 x i32> [[A]], i32 3, i32 2)
 bool3x2 test_transpose_bool2x3(bool2x3 a) {
   return transpose(a);
 }

>From e87d7d27946966882aaa10b130dc1c08b8a2e71a Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Tue, 28 Jul 2026 21:59:54 -0600
Subject: [PATCH 06/17] Remove redundant matrix tests

---
 clang/test/CodeGenHLSL/builtins/isnan.hlsl | 161 ---------------------
 1 file changed, 161 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/isnan.hlsl b/clang/test/CodeGenHLSL/builtins/isnan.hlsl
index 546f45373e60d..88907cef0bd07 100644
--- a/clang/test/CodeGenHLSL/builtins/isnan.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isnan.hlsl
@@ -60,164 +60,3 @@ 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); }

>From 1e50d313eb7dce74933f290df2404e49447f58fb Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Tue, 28 Jul 2026 22:07:57 -0600
Subject: [PATCH 07/17] Change "compute" to "library" in triples

---
 clang/test/CodeGenHLSL/builtins/isinf-overloads_mat.hlsl | 4 ++--
 clang/test/CodeGenHLSL/builtins/isinf_mat.hlsl           | 4 ++--
 clang/test/CodeGenHLSL/builtins/isnan-overloads_mat.hlsl | 4 ++--
 clang/test/CodeGenHLSL/builtins/isnan_mat.hlsl           | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/isinf-overloads_mat.hlsl b/clang/test/CodeGenHLSL/builtins/isinf-overloads_mat.hlsl
index 2a00eab249ed1..0ba2f91f0a65d 100644
--- a/clang/test/CodeGenHLSL/builtins/isinf-overloads_mat.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isinf-overloads_mat.hlsl
@@ -3,12 +3,12 @@
 // 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:   spirv-unknown-vulkan-library %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: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple spirv-unknown-vulkan-library %s \
 // RUN:   -verify -verify-ignore-unexpected=note
 
 // CHECK: define [[FNATTRS]] <2 x i1> @
diff --git a/clang/test/CodeGenHLSL/builtins/isinf_mat.hlsl b/clang/test/CodeGenHLSL/builtins/isinf_mat.hlsl
index 2d9eea3a8ec04..3284c9f64d8a4 100644
--- a/clang/test/CodeGenHLSL/builtins/isinf_mat.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isinf_mat.hlsl
@@ -7,11 +7,11 @@
 // 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:   spirv-unknown-vulkan-library %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:   spirv-unknown-vulkan-library %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> @
diff --git a/clang/test/CodeGenHLSL/builtins/isnan-overloads_mat.hlsl b/clang/test/CodeGenHLSL/builtins/isnan-overloads_mat.hlsl
index 234897e456663..949ee4a2dbb32 100644
--- a/clang/test/CodeGenHLSL/builtins/isnan-overloads_mat.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isnan-overloads_mat.hlsl
@@ -3,12 +3,12 @@
 // 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:   spirv-unknown-vulkan-library %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: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple spirv-unknown-vulkan-library %s \
 // RUN:   -verify -verify-ignore-unexpected=note
 
 // CHECK: define [[FNATTRS]] <2 x i1> @
diff --git a/clang/test/CodeGenHLSL/builtins/isnan_mat.hlsl b/clang/test/CodeGenHLSL/builtins/isnan_mat.hlsl
index d354e0aed55e5..0f7996f4ca914 100644
--- a/clang/test/CodeGenHLSL/builtins/isnan_mat.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isnan_mat.hlsl
@@ -7,11 +7,11 @@
 // 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:   spirv-unknown-vulkan-library %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:   spirv-unknown-vulkan-library %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> @

>From da949c3ea74dc66563d76722dbee0deb67b6b5c2 Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Tue, 28 Jul 2026 22:09:54 -0600
Subject: [PATCH 08/17] Back out incorrect change to bool matrix memory layout

---
 clang/lib/CodeGen/CGExprScalar.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index e9f461c05aa2b..67014904ffb37 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2223,7 +2223,7 @@ Value *ScalarExprEmitter::VisitMatrixSingleSubscriptExpr(
     MB.CreateIndexAssumption(RowIdx, NumRows);
 
   Value *FlatMatrix = Visit(E->getBase());
-  llvm::Type *ElemTy = CGF.ConvertType(MatrixTy->getElementType());
+  llvm::Type *ElemTy = CGF.ConvertTypeForMem(MatrixTy->getElementType());
   auto *ResultTy = llvm::FixedVectorType::get(ElemTy, NumColumns);
   Value *RowVec = llvm::PoisonValue::get(ResultTy);
 

>From c37db62ce714069e5d5ea5465b81502f96db8629 Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Tue, 28 Jul 2026 22:12:11 -0600
Subject: [PATCH 09/17] Address more review comments

---
 .../clang/Basic/DiagnosticSemaKinds.td        |  3 +-
 clang/lib/CodeGen/CGExpr.cpp                  |  3 --
 clang/lib/CodeGen/CGHLSLBuiltins.cpp          | 37 ++++++++-----------
 clang/lib/Sema/SemaChecking.cpp               |  5 +--
 clang/lib/Sema/SemaHLSL.cpp                   |  3 +-
 5 files changed, 21 insertions(+), 30 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index b57ff6c197d1d..8ce8cb1563015 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -13399,7 +13399,8 @@ def err_builtin_is_within_lifetime_invalid_arg : Error<
 def err_builtin_invalid_arg_type: Error<
   "%ordinal0 argument must be a "
   // First component: scalar or container types
-  "%select{|scalar|vector|matrix|vector of|scalar or vector of}1"
+  "%select{|scalar|vector|matrix|vector of|scalar or vector of|"
+  "scalar, vector, or matrix of}1"
   // A comma after generic vector/matrix types if there are non-empty second
   // and third components, to initiate a list.
   "%plural{[2,3]:%plural{0:|:%plural{0:|:,}2}3|:}1"
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 53e633eb97e54..9201e40bc13a1 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2316,9 +2316,6 @@ 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 86ed0da28d07b..c5d688d9e6de7 100644
--- a/clang/lib/CodeGen/CGHLSLBuiltins.cpp
+++ b/clang/lib/CodeGen/CGHLSLBuiltins.cpp
@@ -558,6 +558,17 @@ static Value *emitGetDimensions(CodeGenFunction &CGF, const CallExpr *E,
   return LastStore;
 }
 
+static llvm::Type *getAggregateType(llvm::Type *ScalarTy, QualType ArgTy) {
+  if (auto *MatTy = ArgTy->getAs<ConstantMatrixType>())
+    return llvm::VectorType::get(
+        ScalarTy,
+        ElementCount::getFixed(MatTy->getNumRows() * MatTy->getNumColumns()));
+  if (auto *VecTy = ArgTy->getAs<VectorType>())
+    return llvm::VectorType::get(
+        ScalarTy, ElementCount::getFixed(VecTy->getNumElements()));
+  return ScalarTy;
+}
+
 Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
                                             const CallExpr *E,
                                             ReturnValueSlot ReturnValue) {
@@ -1166,38 +1177,20 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
   }
   case Builtin::BI__builtin_hlsl_elementwise_isinf: {
     Value *Op0 = EmitScalarExpr(E->getArg(0));
-    llvm::Type *Xty = Op0->getType();
-    llvm::Type *retType = llvm::Type::getInt1Ty(this->getLLVMContext());
-    if (Xty->isVectorTy()) {
-      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");
+    llvm::Type *retType = getAggregateType(
+        llvm::Type::getInt1Ty(getLLVMContext()), E->getArg(0)->getType());
     return Builder.CreateIntrinsic(
         retType, CGM.getHLSLRuntime().getIsInfIntrinsic(),
         ArrayRef<Value *>{Op0}, nullptr, "hlsl.isinf");
   }
   case Builtin::BI__builtin_hlsl_elementwise_isnan: {
     Value *Op0 = EmitScalarExpr(E->getArg(0));
-    llvm::Type *Xty = Op0->getType();
-    llvm::Type *retType = llvm::Type::getInt1Ty(this->getLLVMContext());
-    if (Xty->isVectorTy()) {
-      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");
+    llvm::Type *retType = getAggregateType(
+        llvm::Type::getInt1Ty(getLLVMContext()), E->getArg(0)->getType());
     return Builder.CreateIntrinsic(
         retType, CGM.getHLSLRuntime().getIsNaNIntrinsic(),
         ArrayRef<Value *>{Op0}, nullptr, "hlsl.isnan");
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index f2f38c84dc5f8..992763a0a037a 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2361,10 +2361,9 @@ checkMathBuiltinElementType(Sema &S, SourceLocation Loc, QualType ArgTy,
     break;
   case Sema::EltwiseBuiltinArgTyRestriction::FloatTy:
     if (!EltTy->isRealFloatingType()) {
-      // FIXME: make diagnostic's wording correct for matrices
       return S.Diag(Loc, diag::err_builtin_invalid_arg_type)
-             << ArgOrdinal << /* scalar or vector */ 5 << /* no int */ 0
-             << /* floating-point */ 1 << ArgTy;
+             << ArgOrdinal << /* scalar, vector, or matrix of */ 6
+             << /* no int */ 0 << /* floating-point */ 1 << ArgTy;
     }
     break;
   case Sema::EltwiseBuiltinArgTyRestriction::IntegerTy:
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 84a13690f291a..333de4b565576 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -4463,7 +4463,8 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
     if (CheckAllArgTypesAreCorrect(&SemaRef, TheCall,
                                    CheckFloatOrHalfRepresentation))
       return true;
-    if (SemaRef.PrepareBuiltinElementwiseMathOneArgCall(TheCall))
+    if (SemaRef.PrepareBuiltinElementwiseMathOneArgCall(
+            TheCall, Sema::EltwiseBuiltinArgTyRestriction::FloatTy))
       return true;
     SetElementTypeAsReturnType(&SemaRef, TheCall, getASTContext().BoolTy);
     break;

>From 32eb30a82f9698417732e4fa127e8fb742f432cb Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Wed, 29 Jul 2026 00:34:14 -0600
Subject: [PATCH 10/17] Qualify clang::VectorType to resolve ambiguity

---
 clang/lib/CodeGen/CGHLSLBuiltins.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CGHLSLBuiltins.cpp b/clang/lib/CodeGen/CGHLSLBuiltins.cpp
index c5d688d9e6de7..f7c1d4dbeb2db 100644
--- a/clang/lib/CodeGen/CGHLSLBuiltins.cpp
+++ b/clang/lib/CodeGen/CGHLSLBuiltins.cpp
@@ -563,7 +563,7 @@ static llvm::Type *getAggregateType(llvm::Type *ScalarTy, QualType ArgTy) {
     return llvm::VectorType::get(
         ScalarTy,
         ElementCount::getFixed(MatTy->getNumRows() * MatTy->getNumColumns()));
-  if (auto *VecTy = ArgTy->getAs<VectorType>())
+  if (auto *VecTy = ArgTy->getAs<clang::VectorType>())
     return llvm::VectorType::get(
         ScalarTy, ElementCount::getFixed(VecTy->getNumElements()));
   return ScalarTy;

>From 9c77f04bbfa187d03ce8bef705cfd1fe5b5d464a Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Wed, 29 Jul 2026 17:04:03 -0600
Subject: [PATCH 11/17] Change vulkan-compute to vulkan-library

---
 clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl b/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl
index 8e2a1326e7b1b..040f34d63fc21 100644
--- a/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl
@@ -3,12 +3,12 @@
 // 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:   spirv-unknown-vulkan-library %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: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple spirv-unknown-vulkan-library %s \
 // RUN:   -verify -verify-ignore-unexpected=note
 
 // CHECK: define [[FNATTRS]] i1 @

>From 8b2f34b24c42ef5775653a6f8a3e7b5eee6200e6 Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Fri, 31 Jul 2026 10:53:33 -0600
Subject: [PATCH 12/17] Back out diagnostic change

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 3 +--
 clang/lib/Sema/SemaChecking.cpp                  | 5 +++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8ce8cb1563015..b57ff6c197d1d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -13399,8 +13399,7 @@ def err_builtin_is_within_lifetime_invalid_arg : Error<
 def err_builtin_invalid_arg_type: Error<
   "%ordinal0 argument must be a "
   // First component: scalar or container types
-  "%select{|scalar|vector|matrix|vector of|scalar or vector of|"
-  "scalar, vector, or matrix of}1"
+  "%select{|scalar|vector|matrix|vector of|scalar or vector of}1"
   // A comma after generic vector/matrix types if there are non-empty second
   // and third components, to initiate a list.
   "%plural{[2,3]:%plural{0:|:%plural{0:|:,}2}3|:}1"
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 992763a0a037a..f2f38c84dc5f8 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2361,9 +2361,10 @@ checkMathBuiltinElementType(Sema &S, SourceLocation Loc, QualType ArgTy,
     break;
   case Sema::EltwiseBuiltinArgTyRestriction::FloatTy:
     if (!EltTy->isRealFloatingType()) {
+      // FIXME: make diagnostic's wording correct for matrices
       return S.Diag(Loc, diag::err_builtin_invalid_arg_type)
-             << ArgOrdinal << /* scalar, vector, or matrix of */ 6
-             << /* no int */ 0 << /* floating-point */ 1 << ArgTy;
+             << ArgOrdinal << /* scalar or vector */ 5 << /* no int */ 0
+             << /* floating-point */ 1 << ArgTy;
     }
     break;
   case Sema::EltwiseBuiltinArgTyRestriction::IntegerTy:

>From 19d242290e2a111d4b66f4e2152b1b510cff0903 Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Fri, 31 Jul 2026 15:31:40 -0600
Subject: [PATCH 13/17] Revert more changes that don't belong in PR

---
 clang/include/clang/Basic/Builtins.td         |  4 +--
 .../CodeGenHLSL/builtins/isnan-overloads.hlsl | 31 ++++++-------------
 .../test/SemaHLSL/BuiltIns/isinf-errors.hlsl  | 11 +++++++
 .../test/SemaHLSL/BuiltIns/isnan-errors.hlsl  | 11 +++++++
 4 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td
index e9034e59f92b3..ea8dbb96fab56 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -5697,13 +5697,13 @@ def HLSLFrac : LangBuiltin<"HLSL_LANG"> {
 
 def HLSLIsinf : LangBuiltin<"HLSL_LANG"> {
   let Spellings = ["__builtin_hlsl_elementwise_isinf"];
-  let Attributes = [NoThrow, Const, CustomTypeChecking];
+  let Attributes = [NoThrow, Const];
   let Prototype = "void(...)";
 }
 
 def HLSLIsnan : LangBuiltin<"HLSL_LANG"> {
   let Spellings = ["__builtin_hlsl_elementwise_isnan"];
-  let Attributes = [NoThrow, Const, CustomTypeChecking];
+  let Attributes = [NoThrow, Const];
   let Prototype = "void(...)";
 }
 
diff --git a/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl b/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl
index 040f34d63fc21..a0c3eee5da636 100644
--- a/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl
@@ -1,33 +1,20 @@
 // 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-library %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-library %s \
-// RUN:   -verify -verify-ignore-unexpected=note
+// RUN:   -o - | FileCheck %s
 
-// CHECK: define [[FNATTRS]] i1 @
-// CHECK: %hlsl.isnan = call i1 @llvm.[[TARGET]].isnan.f32(
+// CHECK: define hidden noundef i1 @
+// CHECK: %hlsl.isnan = call i1 @llvm.dx.isnan.f32(
 // CHECK: ret i1 %hlsl.isnan
-// expected-warning at +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 [[FNATTRS]] <2 x i1> @
-// CHECK: %hlsl.isnan = call <2 x i1> @llvm.[[TARGET]].isnan.v2f32
+// 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
-// expected-warning at +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 [[FNATTRS]] <3 x i1> @
-// CHECK: %hlsl.isnan = call <3 x i1> @llvm.[[TARGET]].isnan.v3f32
+// 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
-// expected-warning at +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 [[FNATTRS]] <4 x i1> @
-// CHECK: %hlsl.isnan = call <4 x i1> @llvm.[[TARGET]].isnan.v4f32
+// 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
-// expected-warning at +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/SemaHLSL/BuiltIns/isinf-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/isinf-errors.hlsl
index 7ffc750f2d941..a32bc9628a295 100644
--- a/clang/test/SemaHLSL/BuiltIns/isinf-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/isinf-errors.hlsl
@@ -25,3 +25,14 @@ bool2 builtin_isinf_int2_to_float2_promotion(int2 p1) {
   return __builtin_hlsl_elementwise_isinf(p1);
   // expected-error at -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 at -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 at -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.hlsl b/clang/test/SemaHLSL/BuiltIns/isnan-errors.hlsl
index 1af44ec2dd38f..625c415f91de2 100644
--- a/clang/test/SemaHLSL/BuiltIns/isnan-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/isnan-errors.hlsl
@@ -25,3 +25,14 @@ bool2 builtin_isnan_int2_to_float2_promotion(int2 p1) {
   return __builtin_hlsl_elementwise_isnan(p1);
   // expected-error at -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 at -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 at -1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'double')}}
+}

>From 31aa42b74d5698cf77a81225182ffb278445a1a4 Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Fri, 31 Jul 2026 15:52:01 -0600
Subject: [PATCH 14/17] Address additional review comments

---
 clang/lib/Sema/SemaHLSL.cpp                   |  12 +-
 ...oads_mat.hlsl => isinf_mat-overloads.hlsl} | 111 ++++++++++--------
 ...oads_mat.hlsl => isnan_mat-overloads.hlsl} | 111 ++++++++++--------
 ...-errors_mat.hlsl => isinf_mat-errors.hlsl} |   0
 ...-errors_mat.hlsl => isnan_mat-errors.hlsl} |   0
 5 files changed, 130 insertions(+), 104 deletions(-)
 rename clang/test/CodeGenHLSL/builtins/{isinf-overloads_mat.hlsl => isinf_mat-overloads.hlsl} (50%)
 rename clang/test/CodeGenHLSL/builtins/{isnan-overloads_mat.hlsl => isnan_mat-overloads.hlsl} (50%)
 rename clang/test/SemaHLSL/BuiltIns/{isinf-errors_mat.hlsl => isinf_mat-errors.hlsl} (100%)
 rename clang/test/SemaHLSL/BuiltIns/{isnan-errors_mat.hlsl => isnan_mat-errors.hlsl} (100%)

diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 333de4b565576..9c1b72f99de3c 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -3381,12 +3381,12 @@ static bool CheckAllArgTypesAreCorrect(
 static bool CheckFloatRepresentation(Sema *S, SourceLocation Loc,
                                      int ArgOrdinal,
                                      clang::QualType PassedType) {
-  clang::QualType BaseType =
-      PassedType->isVectorType()
-          ? PassedType->castAs<clang::VectorType>()->getElementType()
-      : PassedType->getAs<clang::ConstantMatrixType>()
-          ? PassedType->castAs<clang::ConstantMatrixType>()->getElementType()
-          : PassedType;
+  clang::QualType BaseType = PassedType;
+  if (const auto *VT = PassedType->getAs<clang::VectorType>())
+    BaseType = VT->getElementType();
+  else if (const auto *MT = PassedType->getAs<clang::MatrixType>())
+    BaseType = MT->getElementType();
+
   if (!BaseType->isFloat32Type())
     return S->Diag(Loc, diag::err_builtin_invalid_arg_type)
            << ArgOrdinal << /* scalar or vector of */ 5 << /* no int */ 0
diff --git a/clang/test/CodeGenHLSL/builtins/isinf-overloads_mat.hlsl b/clang/test/CodeGenHLSL/builtins/isinf_mat-overloads.hlsl
similarity index 50%
rename from clang/test/CodeGenHLSL/builtins/isinf-overloads_mat.hlsl
rename to clang/test/CodeGenHLSL/builtins/isinf_mat-overloads.hlsl
index 0ba2f91f0a65d..2d25d78bb8e14 100644
--- a/clang/test/CodeGenHLSL/builtins/isinf-overloads_mat.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isinf_mat-overloads.hlsl
@@ -1,88 +1,101 @@
 // 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:   -o - | FileCheck %s -DTARGET=dx
 // RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -Wdeprecated-declarations -o - | FileCheck %s \
-// RUN:   -DFNATTRS="hidden spir_func noundef" -DTARGET=spv
+// RUN:   -o - | FileCheck %s -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-library %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
+// CHECK-LABEL: define {{.*}} <2 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float>
+// CHECK:    [[RET:%.*]] = call <2 x i1> @llvm.[[TARGET]].isinf.v2f32(<2 x float> [[CONV]])
+// CHECK:    ret <2 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <3 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float>
+// CHECK:    [[RET:%.*]] = call <3 x i1> @llvm.[[TARGET]].isinf.v3f32(<3 x float> [[CONV]])
+// CHECK:    ret <3 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <4 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
+// CHECK:    [[RET:%.*]] = call <4 x i1> @llvm.[[TARGET]].isinf.v4f32(<4 x float> [[CONV]])
+// CHECK:    ret <4 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <2 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float>
+// CHECK:    [[RET:%.*]] = call <2 x i1> @llvm.[[TARGET]].isinf.v2f32(<2 x float> [[CONV]])
+// CHECK:    ret <2 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <4 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
+// CHECK:    [[RET:%.*]] = call <4 x i1> @llvm.[[TARGET]].isinf.v4f32(<4 x float> [[CONV]])
+// CHECK:    ret <4 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <6 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <6 x double> %{{.*}} to <6 x float>
+// CHECK:    [[RET:%.*]] = call <6 x i1> @llvm.[[TARGET]].isinf.v6f32(<6 x float> [[CONV]])
+// CHECK:    ret <6 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <8 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <8 x double> %{{.*}} to <8 x float>
+// CHECK:    [[RET:%.*]] = call <8 x i1> @llvm.[[TARGET]].isinf.v8f32(<8 x float> [[CONV]])
+// CHECK:    ret <8 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <3 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float>
+// CHECK:    [[RET:%.*]] = call <3 x i1> @llvm.[[TARGET]].isinf.v3f32(<3 x float> [[CONV]])
+// CHECK:    ret <3 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <6 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <6 x double> %{{.*}} to <6 x float>
+// CHECK:    [[RET:%.*]] = call <6 x i1> @llvm.[[TARGET]].isinf.v6f32(<6 x float> [[CONV]])
+// CHECK:    ret <6 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <9 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <9 x double> %{{.*}} to <9 x float>
+// CHECK:    [[RET:%.*]] = call <9 x i1> @llvm.[[TARGET]].isinf.v9f32(<9 x float> [[CONV]])
+// CHECK:    ret <9 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <12 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <12 x double> %{{.*}} to <12 x float>
+// CHECK:    [[RET:%.*]] = call <12 x i1> @llvm.[[TARGET]].isinf.v12f32(<12 x float> [[CONV]])
+// CHECK:    ret <12 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <4 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
+// CHECK:    [[RET:%.*]] = call <4 x i1> @llvm.[[TARGET]].isinf.v4f32(<4 x float> [[CONV]])
+// CHECK:    ret <4 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <8 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <8 x double> %{{.*}} to <8 x float>
+// CHECK:    [[RET:%.*]] = call <8 x i1> @llvm.[[TARGET]].isinf.v8f32(<8 x float> [[CONV]])
+// CHECK:    ret <8 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <12 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <12 x double> %{{.*}} to <12 x float>
+// CHECK:    [[RET:%.*]] = call <12 x i1> @llvm.[[TARGET]].isinf.v12f32(<12 x float> [[CONV]])
+// CHECK:    ret <12 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <16 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <16 x double> %{{.*}} to <16 x float>
+// CHECK:    [[RET:%.*]] = call <16 x i1> @llvm.[[TARGET]].isinf.v16f32(<16 x float> [[CONV]])
+// CHECK:    ret <16 x i1> [[RET]]
 // expected-warning at +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/isnan-overloads_mat.hlsl b/clang/test/CodeGenHLSL/builtins/isnan_mat-overloads.hlsl
similarity index 50%
rename from clang/test/CodeGenHLSL/builtins/isnan-overloads_mat.hlsl
rename to clang/test/CodeGenHLSL/builtins/isnan_mat-overloads.hlsl
index 949ee4a2dbb32..9f1156cfd45b6 100644
--- a/clang/test/CodeGenHLSL/builtins/isnan-overloads_mat.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isnan_mat-overloads.hlsl
@@ -1,88 +1,101 @@
 // 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:   -o - | FileCheck %s -DTARGET=dx
 // RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -Wdeprecated-declarations -o - | FileCheck %s \
-// RUN:   -DFNATTRS="hidden spir_func noundef" -DTARGET=spv
+// RUN:   -o - | FileCheck %s -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-library %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
+// CHECK-LABEL: define {{.*}} <2 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float>
+// CHECK:    [[RET:%.*]] = call <2 x i1> @llvm.[[TARGET]].isnan.v2f32(<2 x float> [[CONV]])
+// CHECK:    ret <2 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <3 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float>
+// CHECK:    [[RET:%.*]] = call <3 x i1> @llvm.[[TARGET]].isnan.v3f32(<3 x float> [[CONV]])
+// CHECK:    ret <3 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <4 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
+// CHECK:    [[RET:%.*]] = call <4 x i1> @llvm.[[TARGET]].isnan.v4f32(<4 x float> [[CONV]])
+// CHECK:    ret <4 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <2 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float>
+// CHECK:    [[RET:%.*]] = call <2 x i1> @llvm.[[TARGET]].isnan.v2f32(<2 x float> [[CONV]])
+// CHECK:    ret <2 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <4 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
+// CHECK:    [[RET:%.*]] = call <4 x i1> @llvm.[[TARGET]].isnan.v4f32(<4 x float> [[CONV]])
+// CHECK:    ret <4 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <6 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <6 x double> %{{.*}} to <6 x float>
+// CHECK:    [[RET:%.*]] = call <6 x i1> @llvm.[[TARGET]].isnan.v6f32(<6 x float> [[CONV]])
+// CHECK:    ret <6 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <8 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <8 x double> %{{.*}} to <8 x float>
+// CHECK:    [[RET:%.*]] = call <8 x i1> @llvm.[[TARGET]].isnan.v8f32(<8 x float> [[CONV]])
+// CHECK:    ret <8 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <3 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float>
+// CHECK:    [[RET:%.*]] = call <3 x i1> @llvm.[[TARGET]].isnan.v3f32(<3 x float> [[CONV]])
+// CHECK:    ret <3 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <6 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <6 x double> %{{.*}} to <6 x float>
+// CHECK:    [[RET:%.*]] = call <6 x i1> @llvm.[[TARGET]].isnan.v6f32(<6 x float> [[CONV]])
+// CHECK:    ret <6 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <9 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <9 x double> %{{.*}} to <9 x float>
+// CHECK:    [[RET:%.*]] = call <9 x i1> @llvm.[[TARGET]].isnan.v9f32(<9 x float> [[CONV]])
+// CHECK:    ret <9 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <12 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <12 x double> %{{.*}} to <12 x float>
+// CHECK:    [[RET:%.*]] = call <12 x i1> @llvm.[[TARGET]].isnan.v12f32(<12 x float> [[CONV]])
+// CHECK:    ret <12 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <4 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
+// CHECK:    [[RET:%.*]] = call <4 x i1> @llvm.[[TARGET]].isnan.v4f32(<4 x float> [[CONV]])
+// CHECK:    ret <4 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <8 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <8 x double> %{{.*}} to <8 x float>
+// CHECK:    [[RET:%.*]] = call <8 x i1> @llvm.[[TARGET]].isnan.v8f32(<8 x float> [[CONV]])
+// CHECK:    ret <8 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <12 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <12 x double> %{{.*}} to <12 x float>
+// CHECK:    [[RET:%.*]] = call <12 x i1> @llvm.[[TARGET]].isnan.v12f32(<12 x float> [[CONV]])
+// CHECK:    ret <12 x i1> [[RET]]
 // expected-warning at +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
+// CHECK-LABEL: define {{.*}} <16 x i1> @
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <16 x double> %{{.*}} to <16 x float>
+// CHECK:    [[RET:%.*]] = call <16 x i1> @llvm.[[TARGET]].isnan.v16f32(<16 x float> [[CONV]])
+// CHECK:    ret <16 x i1> [[RET]]
 // expected-warning at +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/SemaHLSL/BuiltIns/isinf-errors_mat.hlsl b/clang/test/SemaHLSL/BuiltIns/isinf_mat-errors.hlsl
similarity index 100%
rename from clang/test/SemaHLSL/BuiltIns/isinf-errors_mat.hlsl
rename to clang/test/SemaHLSL/BuiltIns/isinf_mat-errors.hlsl
diff --git a/clang/test/SemaHLSL/BuiltIns/isnan-errors_mat.hlsl b/clang/test/SemaHLSL/BuiltIns/isnan_mat-errors.hlsl
similarity index 100%
rename from clang/test/SemaHLSL/BuiltIns/isnan-errors_mat.hlsl
rename to clang/test/SemaHLSL/BuiltIns/isnan_mat-errors.hlsl

>From c5210d8ee22e927f8f9e4dc686828a908a456669 Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Fri, 31 Jul 2026 16:58:52 -0600
Subject: [PATCH 15/17] Restore custom type checking

---
 clang/include/clang/Basic/Builtins.td | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td
index ea8dbb96fab56..e9034e59f92b3 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -5697,13 +5697,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(...)";
 }
 

>From af482a85ac0e8882df4e80271505513228f368ba Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Fri, 31 Jul 2026 17:56:16 -0600
Subject: [PATCH 16/17] Re-delete tests for spurious errors eliminated by
 custom type checking

---
 clang/test/SemaHLSL/BuiltIns/isinf-errors.hlsl | 11 -----------
 clang/test/SemaHLSL/BuiltIns/isnan-errors.hlsl | 11 -----------
 2 files changed, 22 deletions(-)

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 at -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 at -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 at -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.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 at -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 at -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 at -1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'double')}}
-}

>From 5653bca58338893c85d9c229127e6172569c0976 Mon Sep 17 00:00:00 2001
From: danbrown-amd <danbrown at amd.com>
Date: Thu, 6 Aug 2026 21:10:24 -0600
Subject: [PATCH 17/17] Address further review comments

---
 clang/lib/CodeGen/CGHLSLBuiltins.cpp          |  3 +-
 .../lib/Headers/hlsl/hlsl_compat_overloads.h  | 76 +++++++++----------
 clang/lib/Sema/SemaHLSL.cpp                   | 13 ++--
 .../CodeGenHLSL/builtins/isinf-overloads.hlsl | 56 +++++++-------
 .../builtins/isinf_mat-overloads.hlsl         | 74 ++++++++++--------
 .../test/CodeGenHLSL/builtins/isinf_mat.hlsl  | 61 ++++++++-------
 .../CodeGenHLSL/builtins/isnan-overloads.hlsl | 45 +++++++----
 .../builtins/isnan_mat-overloads.hlsl         | 74 ++++++++++--------
 .../test/CodeGenHLSL/builtins/isnan_mat.hlsl  | 61 ++++++++-------
 .../SemaHLSL/BuiltIns/isinf_mat-errors.hlsl   | 15 ++++
 .../SemaHLSL/BuiltIns/isnan_mat-errors.hlsl   | 15 ++++
 11 files changed, 281 insertions(+), 212 deletions(-)

diff --git a/clang/lib/CodeGen/CGHLSLBuiltins.cpp b/clang/lib/CodeGen/CGHLSLBuiltins.cpp
index f7c1d4dbeb2db..43b64875243eb 100644
--- a/clang/lib/CodeGen/CGHLSLBuiltins.cpp
+++ b/clang/lib/CodeGen/CGHLSLBuiltins.cpp
@@ -561,8 +561,7 @@ static Value *emitGetDimensions(CodeGenFunction &CGF, const CallExpr *E,
 static llvm::Type *getAggregateType(llvm::Type *ScalarTy, QualType ArgTy) {
   if (auto *MatTy = ArgTy->getAs<ConstantMatrixType>())
     return llvm::VectorType::get(
-        ScalarTy,
-        ElementCount::getFixed(MatTy->getNumRows() * MatTy->getNumColumns()));
+        ScalarTy, ElementCount::getFixed(MatTy->getNumElementsFlattened()));
   if (auto *VecTy = ArgTy->getAs<clang::VectorType>())
     return llvm::VectorType::get(
         ScalarTy, ElementCount::getFixed(VecTy->getNumElements()));
diff --git a/clang/lib/Headers/hlsl/hlsl_compat_overloads.h b/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
index d8e1e453a5b13..2c0c7677be36f 100644
--- a/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
+++ b/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
@@ -382,86 +382,86 @@ _DXC_COMPAT_UNARY_INTEGER_OVERLOADS(frac)
 // isinf builtins overloads
 //===----------------------------------------------------------------------===//
 
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool isinf(double V) { return isinf((float)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool2 isinf(double2 V) { return isinf((float2)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool3 isinf(double3 V) { return isinf((float3)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool4 isinf(double4 V) { return isinf((float4)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool1x2 isinf(double1x2 V) { return isinf((float1x2)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool1x3 isinf(double1x3 V) { return isinf((float1x3)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool1x4 isinf(double1x4 V) { return isinf((float1x4)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool2x1 isinf(double2x1 V) { return isinf((float2x1)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool2x2 isinf(double2x2 V) { return isinf((float2x2)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool2x3 isinf(double2x3 V) { return isinf((float2x3)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool2x4 isinf(double2x4 V) { return isinf((float2x4)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool3x1 isinf(double3x1 V) { return isinf((float3x1)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool3x2 isinf(double3x2 V) { return isinf((float3x2)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool3x3 isinf(double3x3 V) { return isinf((float3x3)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool3x4 isinf(double3x4 V) { return isinf((float3x4)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool4x1 isinf(double4x1 V) { return isinf((float4x1)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool4x2 isinf(double4x2 V) { return isinf((float4x2)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool4x3 isinf(double4x3 V) { return isinf((float4x3)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isinf)
 constexpr bool4x4 isinf(double4x4 V) { return isinf((float4x4)V); }
 
 //===----------------------------------------------------------------------===//
 // isnan builtins overloads
 //===----------------------------------------------------------------------===//
 
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool isnan(double V) { return isnan((float)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool2 isnan(double2 V) { return isnan((float2)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool3 isnan(double3 V) { return isnan((float3)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool4 isnan(double4 V) { return isnan((float4)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool1x2 isnan(double1x2 V) { return isnan((float1x2)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool1x3 isnan(double1x3 V) { return isnan((float1x3)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool1x4 isnan(double1x4 V) { return isnan((float1x4)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool2x1 isnan(double2x1 V) { return isnan((float2x1)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool2x2 isnan(double2x2 V) { return isnan((float2x2)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool2x3 isnan(double2x3 V) { return isnan((float2x3)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool2x4 isnan(double2x4 V) { return isnan((float2x4)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool3x1 isnan(double3x1 V) { return isnan((float3x1)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool3x2 isnan(double3x2 V) { return isnan((float3x2)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool3x3 isnan(double3x3 V) { return isnan((float3x3)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool3x4 isnan(double3x4 V) { return isnan((float3x4)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool4x1 isnan(double4x1 V) { return isnan((float4x1)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool4x2 isnan(double4x2 V) { return isnan((float4x2)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool4x3 isnan(double4x3 V) { return isnan((float4x3)V); }
-_DXC_DEPRECATED_64BIT_FN(fn)
+_DXC_DEPRECATED_64BIT_FN(isnan)
 constexpr bool4x4 isnan(double4x4 V) { return isnan((float4x4)V); }
 
 //===----------------------------------------------------------------------===//
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 9c1b72f99de3c..110efe1a2bc2e 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -3381,12 +3381,10 @@ static bool CheckAllArgTypesAreCorrect(
 static bool CheckFloatRepresentation(Sema *S, SourceLocation Loc,
                                      int ArgOrdinal,
                                      clang::QualType PassedType) {
-  clang::QualType BaseType = PassedType;
-  if (const auto *VT = PassedType->getAs<clang::VectorType>())
-    BaseType = VT->getElementType();
-  else if (const auto *MT = PassedType->getAs<clang::MatrixType>())
-    BaseType = MT->getElementType();
-
+  clang::QualType BaseType =
+      PassedType->isVectorType()
+          ? PassedType->castAs<clang::VectorType>()->getElementType()
+          : PassedType;
   if (!BaseType->isFloat32Type())
     return S->Diag(Loc, diag::err_builtin_invalid_arg_type)
            << ArgOrdinal << /* scalar or vector of */ 5 << /* no int */ 0
@@ -4463,8 +4461,7 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
     if (CheckAllArgTypesAreCorrect(&SemaRef, TheCall,
                                    CheckFloatOrHalfRepresentation))
       return true;
-    if (SemaRef.PrepareBuiltinElementwiseMathOneArgCall(
-            TheCall, Sema::EltwiseBuiltinArgTyRestriction::FloatTy))
+    if (SemaRef.PrepareBuiltinElementwiseMathOneArgCall(TheCall))
       return true;
     SetElementTypeAsReturnType(&SemaRef, TheCall, getASTContext().BoolTy);
     break;
diff --git a/clang/test/CodeGenHLSL/builtins/isinf-overloads.hlsl b/clang/test/CodeGenHLSL/builtins/isinf-overloads.hlsl
index dee6ae013b966..787ca62233b50 100644
--- a/clang/test/CodeGenHLSL/builtins/isinf-overloads.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isinf-overloads.hlsl
@@ -1,37 +1,37 @@
 // RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm \
-// RUN:   -Wdeprecated-declarations -o - | FileCheck %s --check-prefixes=CHECK \
-// RUN:   -DFNATTRS="hidden noundef" -DTARGET=dx
+// RUN:   -Wdeprecated-declarations -o - | FileCheck %s -DTARGET=dx
 // RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-library %s -emit-llvm \
-// RUN:   -Wdeprecated-declarations -o - | FileCheck %s --check-prefixes=CHECK \
-// 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-library %s  \
-// RUN:   -verify -verify-ignore-unexpected=note
+// RUN:   -Wdeprecated-declarations -o - | FileCheck %s -DTARGET=spv
+// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -verify \
+// RUN:   -verify-ignore-unexpected=note
+// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-library %s -verify \
+// RUN:   -verify-ignore-unexpected=note
 
-// CHECK: define [[FNATTRS]] i1 @_Z17test_isinf_doubled(
-// CHECK:    [[CONVI:%.*]] = fptrunc {{.*}} double %{{.*}} to float
-// CHECK:    [[HLSLISINFI:%.*]] = call noundef i1 @llvm.[[TARGET]].isinf.f32(float [[CONVI]])
-// CHECK:    ret i1 [[HLSLISINFI]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// CHECK: define {{.*}} i1 @_Z17test_isinf_doubled(
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} double %{{.*}} to float
+// CHECK:    [[RET:%.*]] = call noundef i1 @llvm.[[TARGET]].isinf.f32(float [[CONV]])
+// CHECK:    ret i1 [[RET]]
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool test_isinf_double(double p0) { return isinf(p0); }
-// CHECK: define [[FNATTRS]] <2 x i1> @_Z18test_isinf_double2Dv2_d(
-// CHECK:    [[CONVI:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float>
-// CHECK:    [[HLSLISINFI:%.*]] = call noundef <2 x i1> @llvm.[[TARGET]].isinf.v2f32(<2 x float> [[CONVI]])
-// CHECK:    ret <2 x i1> [[HLSLISINFI]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// CHECK: define {{.*}} <2 x i1> @_Z18test_isinf_double2Dv2_d(
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float>
+// CHECK:    [[RET:%.*]] = call noundef <2 x i1> @llvm.[[TARGET]].isinf.v2f32(<2 x float> [[CONV]])
+// CHECK:    ret <2 x i1> [[RET]]
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool2 test_isinf_double2(double2 p0) { return isinf(p0); }
-// CHECK: define [[FNATTRS]] <3 x i1> @_Z18test_isinf_double3Dv3_d(
-// CHECK:    [[CONVI:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float>
-// CHECK:    [[HLSLISINFI:%.*]] = call noundef <3 x i1> @llvm.[[TARGET]].isinf.v3f32(<3 x float> [[CONVI]])
-// CHECK:    ret <3 x i1> [[HLSLISINFI]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// CHECK: define {{.*}} <3 x i1> @_Z18test_isinf_double3Dv3_d(
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float>
+// CHECK:    [[RET:%.*]] = call noundef <3 x i1> @llvm.[[TARGET]].isinf.v3f32(<3 x float> [[CONV]])
+// CHECK:    ret <3 x i1> [[RET]]
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool3 test_isinf_double3(double3 p0) { return isinf(p0); }
-// CHECK: define [[FNATTRS]] <4 x i1> @_Z18test_isinf_double4Dv4_d(
-// CHECK:    [[CONVI:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
-// CHECK:    [[HLSLISINFI:%.*]] = call noundef <4 x i1> @llvm.[[TARGET]].isinf.v4f32(<4 x float> [[CONVI]])
-// CHECK:    ret <4 x i1> [[HLSLISINFI]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// CHECK: define {{.*}} <4 x i1> @_Z18test_isinf_double4Dv4_d(
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
+// CHECK:    [[RET:%.*]] = call noundef <4 x i1> @llvm.[[TARGET]].isinf.v4f32(<4 x float> [[CONV]])
+// CHECK:    ret <4 x i1> [[RET]]
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool4 test_isinf_double4(double4 p0) { return isinf(p0); }
diff --git a/clang/test/CodeGenHLSL/builtins/isinf_mat-overloads.hlsl b/clang/test/CodeGenHLSL/builtins/isinf_mat-overloads.hlsl
index 2d25d78bb8e14..01ddfe785911c 100644
--- a/clang/test/CodeGenHLSL/builtins/isinf_mat-overloads.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isinf_mat-overloads.hlsl
@@ -9,93 +9,107 @@
 // RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple spirv-unknown-vulkan-library %s \
 // RUN:   -verify -verify-ignore-unexpected=note
 
-// CHECK-LABEL: define {{.*}} <2 x i1> @
+// CHECK-LABEL: define {{.*}} <2 x i1> @_{{.*}}test_isinf_double1x2{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float>
 // CHECK:    [[RET:%.*]] = call <2 x i1> @llvm.[[TARGET]].isinf.v2f32(<2 x float> [[CONV]])
 // CHECK:    ret <2 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool1x2 test_isinf_double1x2(double1x2 p0) { return isinf(p0); }
-// CHECK-LABEL: define {{.*}} <3 x i1> @
+
+// CHECK-LABEL: define {{.*}} <3 x i1> @_{{.*}}test_isinf_double1x3{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float>
 // CHECK:    [[RET:%.*]] = call <3 x i1> @llvm.[[TARGET]].isinf.v3f32(<3 x float> [[CONV]])
 // CHECK:    ret <3 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool1x3 test_isinf_double1x3(double1x3 p0) { return isinf(p0); }
-// CHECK-LABEL: define {{.*}} <4 x i1> @
+
+// CHECK-LABEL: define {{.*}} <4 x i1> @_{{.*}}test_isinf_double1x4{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
 // CHECK:    [[RET:%.*]] = call <4 x i1> @llvm.[[TARGET]].isinf.v4f32(<4 x float> [[CONV]])
 // CHECK:    ret <4 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool1x4 test_isinf_double1x4(double1x4 p0) { return isinf(p0); }
-// CHECK-LABEL: define {{.*}} <2 x i1> @
+
+// CHECK-LABEL: define {{.*}} <2 x i1> @_{{.*}}test_isinf_double2x1{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float>
 // CHECK:    [[RET:%.*]] = call <2 x i1> @llvm.[[TARGET]].isinf.v2f32(<2 x float> [[CONV]])
 // CHECK:    ret <2 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool2x1 test_isinf_double2x1(double2x1 p0) { return isinf(p0); }
-// CHECK-LABEL: define {{.*}} <4 x i1> @
+
+// CHECK-LABEL: define {{.*}} <4 x i1> @_{{.*}}test_isinf_double2x2{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
 // CHECK:    [[RET:%.*]] = call <4 x i1> @llvm.[[TARGET]].isinf.v4f32(<4 x float> [[CONV]])
 // CHECK:    ret <4 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool2x2 test_isinf_double2x2(double2x2 p0) { return isinf(p0); }
-// CHECK-LABEL: define {{.*}} <6 x i1> @
+
+// CHECK-LABEL: define {{.*}} <6 x i1> @_{{.*}}test_isinf_double2x3{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <6 x double> %{{.*}} to <6 x float>
 // CHECK:    [[RET:%.*]] = call <6 x i1> @llvm.[[TARGET]].isinf.v6f32(<6 x float> [[CONV]])
 // CHECK:    ret <6 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool2x3 test_isinf_double2x3(double2x3 p0) { return isinf(p0); }
-// CHECK-LABEL: define {{.*}} <8 x i1> @
+
+// CHECK-LABEL: define {{.*}} <8 x i1> @_{{.*}}test_isinf_double2x4{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <8 x double> %{{.*}} to <8 x float>
 // CHECK:    [[RET:%.*]] = call <8 x i1> @llvm.[[TARGET]].isinf.v8f32(<8 x float> [[CONV]])
 // CHECK:    ret <8 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool2x4 test_isinf_double2x4(double2x4 p0) { return isinf(p0); }
-// CHECK-LABEL: define {{.*}} <3 x i1> @
+
+// CHECK-LABEL: define {{.*}} <3 x i1> @_{{.*}}test_isinf_double3x1{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float>
 // CHECK:    [[RET:%.*]] = call <3 x i1> @llvm.[[TARGET]].isinf.v3f32(<3 x float> [[CONV]])
 // CHECK:    ret <3 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool3x1 test_isinf_double3x1(double3x1 p0) { return isinf(p0); }
-// CHECK-LABEL: define {{.*}} <6 x i1> @
+
+// CHECK-LABEL: define {{.*}} <6 x i1> @_{{.*}}test_isinf_double3x2{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <6 x double> %{{.*}} to <6 x float>
 // CHECK:    [[RET:%.*]] = call <6 x i1> @llvm.[[TARGET]].isinf.v6f32(<6 x float> [[CONV]])
 // CHECK:    ret <6 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool3x2 test_isinf_double3x2(double3x2 p0) { return isinf(p0); }
-// CHECK-LABEL: define {{.*}} <9 x i1> @
+
+// CHECK-LABEL: define {{.*}} <9 x i1> @_{{.*}}test_isinf_double3x3{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <9 x double> %{{.*}} to <9 x float>
 // CHECK:    [[RET:%.*]] = call <9 x i1> @llvm.[[TARGET]].isinf.v9f32(<9 x float> [[CONV]])
 // CHECK:    ret <9 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool3x3 test_isinf_double3x3(double3x3 p0) { return isinf(p0); }
-// CHECK-LABEL: define {{.*}} <12 x i1> @
+
+// CHECK-LABEL: define {{.*}} <12 x i1> @_{{.*}}test_isinf_double3x4{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <12 x double> %{{.*}} to <12 x float>
 // CHECK:    [[RET:%.*]] = call <12 x i1> @llvm.[[TARGET]].isinf.v12f32(<12 x float> [[CONV]])
 // CHECK:    ret <12 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool3x4 test_isinf_double3x4(double3x4 p0) { return isinf(p0); }
-// CHECK-LABEL: define {{.*}} <4 x i1> @
+
+// CHECK-LABEL: define {{.*}} <4 x i1> @_{{.*}}test_isinf_double4x1{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
 // CHECK:    [[RET:%.*]] = call <4 x i1> @llvm.[[TARGET]].isinf.v4f32(<4 x float> [[CONV]])
 // CHECK:    ret <4 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool4x1 test_isinf_double4x1(double4x1 p0) { return isinf(p0); }
-// CHECK-LABEL: define {{.*}} <8 x i1> @
+
+// CHECK-LABEL: define {{.*}} <8 x i1> @_{{.*}}test_isinf_double4x2{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <8 x double> %{{.*}} to <8 x float>
 // CHECK:    [[RET:%.*]] = call <8 x i1> @llvm.[[TARGET]].isinf.v8f32(<8 x float> [[CONV]])
 // CHECK:    ret <8 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool4x2 test_isinf_double4x2(double4x2 p0) { return isinf(p0); }
-// CHECK-LABEL: define {{.*}} <12 x i1> @
+
+// CHECK-LABEL: define {{.*}} <12 x i1> @_{{.*}}test_isinf_double4x3{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <12 x double> %{{.*}} to <12 x float>
 // CHECK:    [[RET:%.*]] = call <12 x i1> @llvm.[[TARGET]].isinf.v12f32(<12 x float> [[CONV]])
 // CHECK:    ret <12 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool4x3 test_isinf_double4x3(double4x3 p0) { return isinf(p0); }
-// CHECK-LABEL: define {{.*}} <16 x i1> @
+
+// CHECK-LABEL: define {{.*}} <16 x i1> @_{{.*}}test_isinf_double4x4{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <16 x double> %{{.*}} to <16 x float>
 // CHECK:    [[RET:%.*]] = call <16 x i1> @llvm.[[TARGET]].isinf.v16f32(<16 x float> [[CONV]])
 // CHECK:    ret <16 x i1> [[RET]]
-// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isinf' is deprecated: In 202x 64 bit API lowering for isinf 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
index 3284c9f64d8a4..ffa15516967d5 100644
--- a/clang/test/CodeGenHLSL/builtins/isinf_mat.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isinf_mat.hlsl
@@ -14,169 +14,168 @@
 // RUN:   spirv-unknown-vulkan-library %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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <2 x i1> @_{{.*}}test_isinf_float1x2{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <3 x i1> @_{{.*}}test_isinf_float1x3{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <4 x i1> @_{{.*}}test_isinf_float1x4{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <2 x i1> @_{{.*}}test_isinf_float2x1{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <4 x i1> @_{{.*}}test_isinf_float2x2{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <6 x i1> @_{{.*}}test_isinf_float2x3{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <8 x i1> @_{{.*}}test_isinf_float2x4{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <3 x i1> @_{{.*}}test_isinf_float3x1{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <6 x i1> @_{{.*}}test_isinf_float3x2{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <9 x i1> @_{{.*}}test_isinf_float3x3{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <12 x i1> @_{{.*}}test_isinf_float3x4{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <4 x i1> @_{{.*}}test_isinf_float4x1{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <8 x i1> @_{{.*}}test_isinf_float4x2{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <12 x i1> @_{{.*}}test_isinf_float4x3{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <16 x i1> @_{{.*}}test_isinf_float4x4{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <2 x i1> @_{{.*}}test_isinf_half1x2{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <3 x i1> @_{{.*}}test_isinf_half1x3{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <4 x i1> @_{{.*}}test_isinf_half1x4{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <2 x i1> @_{{.*}}test_isinf_half2x1{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <4 x i1> @_{{.*}}test_isinf_half2x2{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <6 x i1> @_{{.*}}test_isinf_half2x3{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <8 x i1> @_{{.*}}test_isinf_half2x4{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <3 x i1> @_{{.*}}test_isinf_half3x1{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <6 x i1> @_{{.*}}test_isinf_half3x2{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <9 x i1> @_{{.*}}test_isinf_half3x3{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <12 x i1> @_{{.*}}test_isinf_half3x4{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <4 x i1> @_{{.*}}test_isinf_half4x1{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <8 x i1> @_{{.*}}test_isinf_half4x2{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <12 x i1> @_{{.*}}test_isinf_half4x3{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <16 x i1> @_{{.*}}test_isinf_half4x4{{.*}}(
 // 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
diff --git a/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl b/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl
index a0c3eee5da636..c783eadc6db3b 100644
--- a/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isnan-overloads.hlsl
@@ -1,20 +1,37 @@
 // 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:   dxil-pc-shadermodel6.3-library %s -emit-llvm \
+// RUN:   -Wdeprecated-declarations -o - | FileCheck %s -DTARGET=dx
+// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-library %s -emit-llvm \
+// RUN:   -Wdeprecated-declarations -o - | FileCheck %s -DTARGET=spv
+// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -verify \
+// RUN:   -verify-ignore-unexpected=note
+// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-library %s -verify \
+// RUN:   -verify-ignore-unexpected=note
 
-// CHECK: define hidden noundef i1 @
-// CHECK: %hlsl.isnan = call i1 @llvm.dx.isnan.f32(
-// CHECK: ret i1 %hlsl.isnan
+// CHECK: define {{.*}} i1 @_Z17test_isnan_doubled(
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} double %{{.*}} to float
+// CHECK:    [[RET:%.*]] = call noundef i1 @llvm.[[TARGET]].isnan.f32(float [[CONV]])
+// CHECK:    ret i1 [[RET]]
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan 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: ret <2 x i1> %hlsl.isnan
+// CHECK: define {{.*}} <2 x i1> @_Z18test_isnan_double2Dv2_d(
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float>
+// CHECK:    [[RET:%.*]] = call noundef <2 x i1> @llvm.[[TARGET]].isnan.v2f32(<2 x float> [[CONV]])
+// CHECK:    ret <2 x i1> [[RET]]
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan 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: ret <3 x i1> %hlsl.isnan
+// CHECK: define {{.*}} <3 x i1> @_Z18test_isnan_double3Dv3_d(
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float>
+// CHECK:    [[RET:%.*]] = call noundef <3 x i1> @llvm.[[TARGET]].isnan.v3f32(<3 x float> [[CONV]])
+// CHECK:    ret <3 x i1> [[RET]]
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan 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: ret <4 x i1> %hlsl.isnan
+// CHECK: define {{.*}} <4 x i1> @_Z18test_isnan_double4Dv4_d(
+// CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
+// CHECK:    [[RET:%.*]] = call noundef <4 x i1> @llvm.[[TARGET]].isnan.v4f32(<4 x float> [[CONV]])
+// CHECK:    ret <4 x i1> [[RET]]
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan 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_mat-overloads.hlsl b/clang/test/CodeGenHLSL/builtins/isnan_mat-overloads.hlsl
index 9f1156cfd45b6..d1f4ae1700d29 100644
--- a/clang/test/CodeGenHLSL/builtins/isnan_mat-overloads.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isnan_mat-overloads.hlsl
@@ -9,93 +9,107 @@
 // RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple spirv-unknown-vulkan-library %s \
 // RUN:   -verify -verify-ignore-unexpected=note
 
-// CHECK-LABEL: define {{.*}} <2 x i1> @
+// CHECK-LABEL: define {{.*}} <2 x i1> @_{{.*}}test_isnan_double1x2{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float>
 // CHECK:    [[RET:%.*]] = call <2 x i1> @llvm.[[TARGET]].isnan.v2f32(<2 x float> [[CONV]])
 // CHECK:    ret <2 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool1x2 test_isnan_double1x2(double1x2 p0) { return isnan(p0); }
-// CHECK-LABEL: define {{.*}} <3 x i1> @
+
+// CHECK-LABEL: define {{.*}} <3 x i1> @_{{.*}}test_isnan_double1x3{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float>
 // CHECK:    [[RET:%.*]] = call <3 x i1> @llvm.[[TARGET]].isnan.v3f32(<3 x float> [[CONV]])
 // CHECK:    ret <3 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool1x3 test_isnan_double1x3(double1x3 p0) { return isnan(p0); }
-// CHECK-LABEL: define {{.*}} <4 x i1> @
+
+// CHECK-LABEL: define {{.*}} <4 x i1> @_{{.*}}test_isnan_double1x4{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
 // CHECK:    [[RET:%.*]] = call <4 x i1> @llvm.[[TARGET]].isnan.v4f32(<4 x float> [[CONV]])
 // CHECK:    ret <4 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool1x4 test_isnan_double1x4(double1x4 p0) { return isnan(p0); }
-// CHECK-LABEL: define {{.*}} <2 x i1> @
+
+// CHECK-LABEL: define {{.*}} <2 x i1> @_{{.*}}test_isnan_double2x1{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <2 x double> %{{.*}} to <2 x float>
 // CHECK:    [[RET:%.*]] = call <2 x i1> @llvm.[[TARGET]].isnan.v2f32(<2 x float> [[CONV]])
 // CHECK:    ret <2 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool2x1 test_isnan_double2x1(double2x1 p0) { return isnan(p0); }
-// CHECK-LABEL: define {{.*}} <4 x i1> @
+
+// CHECK-LABEL: define {{.*}} <4 x i1> @_{{.*}}test_isnan_double2x2{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
 // CHECK:    [[RET:%.*]] = call <4 x i1> @llvm.[[TARGET]].isnan.v4f32(<4 x float> [[CONV]])
 // CHECK:    ret <4 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool2x2 test_isnan_double2x2(double2x2 p0) { return isnan(p0); }
-// CHECK-LABEL: define {{.*}} <6 x i1> @
+
+// CHECK-LABEL: define {{.*}} <6 x i1> @_{{.*}}test_isnan_double2x3{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <6 x double> %{{.*}} to <6 x float>
 // CHECK:    [[RET:%.*]] = call <6 x i1> @llvm.[[TARGET]].isnan.v6f32(<6 x float> [[CONV]])
 // CHECK:    ret <6 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool2x3 test_isnan_double2x3(double2x3 p0) { return isnan(p0); }
-// CHECK-LABEL: define {{.*}} <8 x i1> @
+
+// CHECK-LABEL: define {{.*}} <8 x i1> @_{{.*}}test_isnan_double2x4{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <8 x double> %{{.*}} to <8 x float>
 // CHECK:    [[RET:%.*]] = call <8 x i1> @llvm.[[TARGET]].isnan.v8f32(<8 x float> [[CONV]])
 // CHECK:    ret <8 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool2x4 test_isnan_double2x4(double2x4 p0) { return isnan(p0); }
-// CHECK-LABEL: define {{.*}} <3 x i1> @
+
+// CHECK-LABEL: define {{.*}} <3 x i1> @_{{.*}}test_isnan_double3x1{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <3 x double> %{{.*}} to <3 x float>
 // CHECK:    [[RET:%.*]] = call <3 x i1> @llvm.[[TARGET]].isnan.v3f32(<3 x float> [[CONV]])
 // CHECK:    ret <3 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool3x1 test_isnan_double3x1(double3x1 p0) { return isnan(p0); }
-// CHECK-LABEL: define {{.*}} <6 x i1> @
+
+// CHECK-LABEL: define {{.*}} <6 x i1> @_{{.*}}test_isnan_double3x2{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <6 x double> %{{.*}} to <6 x float>
 // CHECK:    [[RET:%.*]] = call <6 x i1> @llvm.[[TARGET]].isnan.v6f32(<6 x float> [[CONV]])
 // CHECK:    ret <6 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool3x2 test_isnan_double3x2(double3x2 p0) { return isnan(p0); }
-// CHECK-LABEL: define {{.*}} <9 x i1> @
+
+// CHECK-LABEL: define {{.*}} <9 x i1> @_{{.*}}test_isnan_double3x3{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <9 x double> %{{.*}} to <9 x float>
 // CHECK:    [[RET:%.*]] = call <9 x i1> @llvm.[[TARGET]].isnan.v9f32(<9 x float> [[CONV]])
 // CHECK:    ret <9 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool3x3 test_isnan_double3x3(double3x3 p0) { return isnan(p0); }
-// CHECK-LABEL: define {{.*}} <12 x i1> @
+
+// CHECK-LABEL: define {{.*}} <12 x i1> @_{{.*}}test_isnan_double3x4{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <12 x double> %{{.*}} to <12 x float>
 // CHECK:    [[RET:%.*]] = call <12 x i1> @llvm.[[TARGET]].isnan.v12f32(<12 x float> [[CONV]])
 // CHECK:    ret <12 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool3x4 test_isnan_double3x4(double3x4 p0) { return isnan(p0); }
-// CHECK-LABEL: define {{.*}} <4 x i1> @
+
+// CHECK-LABEL: define {{.*}} <4 x i1> @_{{.*}}test_isnan_double4x1{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <4 x double> %{{.*}} to <4 x float>
 // CHECK:    [[RET:%.*]] = call <4 x i1> @llvm.[[TARGET]].isnan.v4f32(<4 x float> [[CONV]])
 // CHECK:    ret <4 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool4x1 test_isnan_double4x1(double4x1 p0) { return isnan(p0); }
-// CHECK-LABEL: define {{.*}} <8 x i1> @
+
+// CHECK-LABEL: define {{.*}} <8 x i1> @_{{.*}}test_isnan_double4x2{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <8 x double> %{{.*}} to <8 x float>
 // CHECK:    [[RET:%.*]] = call <8 x i1> @llvm.[[TARGET]].isnan.v8f32(<8 x float> [[CONV]])
 // CHECK:    ret <8 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool4x2 test_isnan_double4x2(double4x2 p0) { return isnan(p0); }
-// CHECK-LABEL: define {{.*}} <12 x i1> @
+
+// CHECK-LABEL: define {{.*}} <12 x i1> @_{{.*}}test_isnan_double4x3{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <12 x double> %{{.*}} to <12 x float>
 // CHECK:    [[RET:%.*]] = call <12 x i1> @llvm.[[TARGET]].isnan.v12f32(<12 x float> [[CONV]])
 // CHECK:    ret <12 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
 bool4x3 test_isnan_double4x3(double4x3 p0) { return isnan(p0); }
-// CHECK-LABEL: define {{.*}} <16 x i1> @
+
+// CHECK-LABEL: define {{.*}} <16 x i1> @_{{.*}}test_isnan_double4x4{{.*}}(
 // CHECK:    [[CONV:%.*]] = fptrunc {{.*}} <16 x double> %{{.*}} to <16 x float>
 // CHECK:    [[RET:%.*]] = call <16 x i1> @llvm.[[TARGET]].isnan.v16f32(<16 x float> [[CONV]])
 // CHECK:    ret <16 x i1> [[RET]]
-// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for fn is deprecated. Explicitly cast parameters to 32 or 16 bit types.}}
+// expected-warning at +1 {{'isnan' is deprecated: In 202x 64 bit API lowering for isnan 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_mat.hlsl b/clang/test/CodeGenHLSL/builtins/isnan_mat.hlsl
index 0f7996f4ca914..a6f31f5e17acf 100644
--- a/clang/test/CodeGenHLSL/builtins/isnan_mat.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isnan_mat.hlsl
@@ -14,169 +14,168 @@
 // RUN:   spirv-unknown-vulkan-library %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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <2 x i1> @_{{.*}}test_isnan_float1x2{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <3 x i1> @_{{.*}}test_isnan_float1x3{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <4 x i1> @_{{.*}}test_isnan_float1x4{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <2 x i1> @_{{.*}}test_isnan_float2x1{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <4 x i1> @_{{.*}}test_isnan_float2x2{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <6 x i1> @_{{.*}}test_isnan_float2x3{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <8 x i1> @_{{.*}}test_isnan_float2x4{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <3 x i1> @_{{.*}}test_isnan_float3x1{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <6 x i1> @_{{.*}}test_isnan_float3x2{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <9 x i1> @_{{.*}}test_isnan_float3x3{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <12 x i1> @_{{.*}}test_isnan_float3x4{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <4 x i1> @_{{.*}}test_isnan_float4x1{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <8 x i1> @_{{.*}}test_isnan_float4x2{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <12 x i1> @_{{.*}}test_isnan_float4x3{{.*}}(
 // 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-LABEL: define hidden {{.*}}noundef <16 x i1> @_{{.*}}test_isnan_float4x4{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <2 x i1> @_{{.*}}test_isnan_half1x2{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <3 x i1> @_{{.*}}test_isnan_half1x3{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <4 x i1> @_{{.*}}test_isnan_half1x4{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <2 x i1> @_{{.*}}test_isnan_half2x1{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <4 x i1> @_{{.*}}test_isnan_half2x2{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <6 x i1> @_{{.*}}test_isnan_half2x3{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <8 x i1> @_{{.*}}test_isnan_half2x4{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <3 x i1> @_{{.*}}test_isnan_half3x1{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <6 x i1> @_{{.*}}test_isnan_half3x2{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <9 x i1> @_{{.*}}test_isnan_half3x3{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <12 x i1> @_{{.*}}test_isnan_half3x4{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <4 x i1> @_{{.*}}test_isnan_half4x1{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <8 x i1> @_{{.*}}test_isnan_half4x2{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <12 x i1> @_{{.*}}test_isnan_half4x3{{.*}}(
 // 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> @
+// CHECK-LABEL: define hidden {{.*}}noundef <16 x i1> @_{{.*}}test_isnan_half4x4{{.*}}(
 // 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
diff --git a/clang/test/SemaHLSL/BuiltIns/isinf_mat-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/isinf_mat-errors.hlsl
index 70d2a68ca16dd..18d7df3280bbf 100644
--- a/clang/test/SemaHLSL/BuiltIns/isinf_mat-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/isinf_mat-errors.hlsl
@@ -1,5 +1,20 @@
 // 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_too_few_arg() {
+  return __builtin_hlsl_elementwise_isinf();
+  // expected-error at -1 {{too few arguments to function call, expected 1, have 0}}
+}
+
+bool2x2 test_too_many_arg(float2x2 p0) {
+  return __builtin_hlsl_elementwise_isinf(p0, p0);
+  // expected-error at -1 {{too many arguments to function call, expected 1, have 2}}
+}
+
+bool2x2 test_builtin_isinf_int_matrix(int2x2 p0) {
+  return __builtin_hlsl_elementwise_isinf(p0);
+  // expected-error at -1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'int2x2' (aka 'matrix<int, 2, 2>'))}}
+}
+
 bool2x2 test_builtin_isinf_double_matrix(double2x2 p0) {
   return __builtin_hlsl_elementwise_isinf(p0);
   // expected-error at -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_mat-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/isnan_mat-errors.hlsl
index b8728c78bab22..fbcb50422ec3e 100644
--- a/clang/test/SemaHLSL/BuiltIns/isnan_mat-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/isnan_mat-errors.hlsl
@@ -1,5 +1,20 @@
 // 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_too_few_arg() {
+  return __builtin_hlsl_elementwise_isnan();
+  // expected-error at -1 {{too few arguments to function call, expected 1, have 0}}
+}
+
+bool2x2 test_too_many_arg(float2x2 p0) {
+  return __builtin_hlsl_elementwise_isnan(p0, p0);
+  // expected-error at -1 {{too many arguments to function call, expected 1, have 2}}
+}
+
+bool2x2 test_builtin_isnan_int_matrix(int2x2 p0) {
+  return __builtin_hlsl_elementwise_isnan(p0);
+  // expected-error at -1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'int2x2' (aka 'matrix<int, 2, 2>'))}}
+}
+
 bool2x2 test_builtin_isnan_double_matrix(double2x2 p0) {
   return __builtin_hlsl_elementwise_isnan(p0);
   // expected-error at -1 {{1st argument must be a scalar or vector of 16 or 32 bit floating-point types (was 'double2x2' (aka 'matrix<double, 2, 2>'))}}



More information about the cfe-commits mailing list