https://github.com/V-FEXrt updated https://github.com/llvm/llvm-project/pull/142679
>From 7a294ecd713cf6c4fb095a1b3f6f6793d50657a8 Mon Sep 17 00:00:00 2001 From: Ashley Coleman <ascole...@microsoft.com> Date: Tue, 3 Jun 2025 16:05:24 -0600 Subject: [PATCH 1/2] [HLSL] Use ExtVector for firstbit intrinsics --- clang/lib/Sema/SemaHLSL.cpp | 3 +-- clang/test/CodeGenHLSL/builtins/firstbithigh.hlsl | 8 ++++++++ clang/test/CodeGenHLSL/builtins/firstbitlow.hlsl | 8 ++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp index 43db85594de3d..b923d1204d8d6 100644 --- a/clang/lib/Sema/SemaHLSL.cpp +++ b/clang/lib/Sema/SemaHLSL.cpp @@ -2485,8 +2485,7 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { if (auto *VecTy = EltTy->getAs<VectorType>()) { EltTy = VecTy->getElementType(); - ResTy = SemaRef.Context.getVectorType(ResTy, VecTy->getNumElements(), - VecTy->getVectorKind()); + ResTy = SemaRef.Context.getExtVectorType(ResTy, VecTy->getNumElements()); } if (!EltTy->isIntegerType()) { diff --git a/clang/test/CodeGenHLSL/builtins/firstbithigh.hlsl b/clang/test/CodeGenHLSL/builtins/firstbithigh.hlsl index debf6b6d3e3f5..a71b1878f8b55 100644 --- a/clang/test/CodeGenHLSL/builtins/firstbithigh.hlsl +++ b/clang/test/CodeGenHLSL/builtins/firstbithigh.hlsl @@ -151,3 +151,11 @@ uint3 test_firstbithigh_long3(int64_t3 p0) { uint4 test_firstbithigh_long4(int64_t4 p0) { return firstbithigh(p0); } + +// CHECK-LABEL: test_firstbithigh_upcast +// CHECK: [[FBH:%.*]] = call <4 x i32> @llvm.[[TARGET]].firstbituhigh.v4i32(<4 x i32> %{{.*}}) +// CHECK: [[CONV:%.*]] = zext <4 x i32> [[FBH]] to <4 x i64> +// CHECK: ret <4 x i64> [[CONV]] +uint64_t4 test_firstbithigh_upcast(uint4 p0) { + return firstbithigh(p0); +} diff --git a/clang/test/CodeGenHLSL/builtins/firstbitlow.hlsl b/clang/test/CodeGenHLSL/builtins/firstbitlow.hlsl index 5d490fabc5bc8..007db0c9c2ad5 100644 --- a/clang/test/CodeGenHLSL/builtins/firstbitlow.hlsl +++ b/clang/test/CodeGenHLSL/builtins/firstbitlow.hlsl @@ -151,3 +151,11 @@ uint3 test_firstbitlow_long3(int64_t3 p0) { uint4 test_firstbitlow_long4(int64_t4 p0) { return firstbitlow(p0); } + +// CHECK-LABEL: test_firstbitlow_upcast +// CHECK: [[FBL:%.*]] = call <4 x i32> @llvm.[[TARGET]].firstbitlow.v4i32(<4 x i32> %{{.*}}) +// CHECK: [[CONV:%.*]] = zext <4 x i32> [[FBL]] to <4 x i64> +// CHECK: ret <4 x i64> [[CONV]] +uint64_t4 test_firstbitlow_upcast(uint4 p0) { + return firstbitlow(p0); +} >From 9ba8e0fb9ed92ac585591c908f2510c15e50777f Mon Sep 17 00:00:00 2001 From: Ashley Coleman <ascole...@microsoft.com> Date: Wed, 4 Jun 2025 10:22:07 -0600 Subject: [PATCH 2/2] Address Comments --- clang/lib/Sema/SemaHLSL.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp index b923d1204d8d6..3ca11b17f708a 100644 --- a/clang/lib/Sema/SemaHLSL.cpp +++ b/clang/lib/Sema/SemaHLSL.cpp @@ -2171,8 +2171,9 @@ static void SetElementTypeAsReturnType(Sema *S, CallExpr *TheCall, QualType ReturnType) { auto *VecTyA = TheCall->getArg(0)->getType()->getAs<VectorType>(); if (VecTyA) - ReturnType = S->Context.getVectorType(ReturnType, VecTyA->getNumElements(), - VectorKind::Generic); + ReturnType = + S->Context.getExtVectorType(ReturnType, VecTyA->getNumElements()); + TheCall->setType(ReturnType); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits