Skip to content

Fix the return types of dot4add_i8packed and dot4add_u8packed. #7401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tools/clang/lib/Sema/SemaHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6737,8 +6737,8 @@ bool HLSLExternalSource::MatchArguments(
(iArg != retArgIdx && retTypeIdx == pIntrinsicArg->uComponentTypeId);
// For literal arg which don't affect return type, find concrete type.
// For literal arg affect return type,
// TryEvalIntrinsic in CGHLSLMS.cpp will take care of cases
// where all argumentss are literal.
// TryEvalIntrinsic in CGHLSLMSFinishCodeGen.cpp will take care of
// cases where all arguments are literal.
// CombineBasicTypes will cover the rest cases.
if (!affectRetType) {
TypeInfoEltKind =
Expand Down
34 changes: 34 additions & 0 deletions tools/clang/test/DXC/dot4add_i8_u8_packed-types.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// RUN: %dxc /enable-16bit-types /T cs_6_8 %s | FileCheck %s

// Compiling this HLSL would fail this assertion in TranslateDot4AddPacked:
//
// DXASSERT(
// !accTy->isVectorTy() && accTy->isIntegerTy(32),
// "otherwise, unexpected vector support in high level intrinsic template");
//
// Bug was fixed by changing the declarations of dot4add_i8packed and
// dot4add_u8packed in utils/hct/gen_intrin_main.txt to simply write
// out their argument and return types, rather than using the $typeN
// reference syntax.

// CHECK: call i32 @dx.op.dot4AddPacked.i32{{.*}}Dot4AddI8Packed(acc,a,b)
// CHECK: call i32 @dx.op.dot4AddPacked.i32{{.*}}Dot4AddU8Packed(acc,a,b)
// CHECK: call float @dx.op.dot2AddHalf.f32{{.*}}Dot2AddHalf(acc,ax,ay,bx,by)

RWByteAddressBuffer buf;

[numthreads(1, 1, 1)]
void main()
{
int a = dot4add_i8packed(0, 0, 0);
int b = dot4add_i8packed(0, 0, a);
buf.Store<int>(0, b);

uint c = dot4add_u8packed(0, 0, 0);
uint d = dot4add_u8packed(0, 0, c);
buf.Store<uint>(4, d);

float e = dot2add(half2(0,0), half2(0,0), 1.0);
float f = dot2add(half2(0,0), half2(0,0), e);
buf.Store<float>(8, f);
}
6 changes: 3 additions & 3 deletions utils/hct/gen_intrin_main.txt
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ float<4,3> [[rn]] ObjectToWorld4x3();
float<4,3> [[rn]] WorldToObject4x3();

// Packed dot products with accumulate:
$type3 [[rn]] dot4add_u8packed(in uint a, in $type1 b, in uint c);
$type3 [[rn]] dot4add_i8packed(in uint a, in $type1 b, in int c);
$type3 [[rn]] dot2add(in float16_t<2> a, in $type1 b, in float c);
uint [[rn]] dot4add_u8packed(in uint a, in $type1 b, in uint c);
int [[rn]] dot4add_i8packed(in uint a, in $type1 b, in int c);
float [[rn]] dot2add(in float16_t<2> a, in $type1 b, in float c);

// Unpacking intrinsics
int16_t<4> [[rn]] unpack_s8s16(in p32i8 pk);
Expand Down