Skip to content

Add pack_, pack_clamp_ and unpack_ tests - #1432

Open
Alexander-Johnston wants to merge 2 commits into
llvm:mainfrom
Alexander-Johnston:pack_unpack
Open

Add pack_, pack_clamp_ and unpack_ tests#1432
Alexander-Johnston wants to merge 2 commits into
llvm:mainfrom
Alexander-Johnston:pack_unpack

Conversation

@Alexander-Johnston

Copy link
Copy Markdown
Collaborator

Adds tests covering a matrix of signed, unsigned, 16, and 32 bit pack, pack_clamp, and unpack intrinsics.

As the intrinsics/tests are all simple in nature and related in function, I've packaged together all of the pack and unpack variants.

Closes #863, #864, #865, #866, #891, #892, #893, #894,

Alexander-Johnston and others added 2 commits August 10, 2026 21:03
Adds tests covering a matrix of signed, unsigned, 16, and 32 bit
pack, pack_clamp, and unpack intrinsics.
Comment on lines +8 to +13
int16_t4 unpackedVals;
unpackedVals.x = In[0];
unpackedVals.y = In[1];
unpackedVals.z = In[2];
unpackedVals.w = In[3];
int8_t4_packed packedVals = pack_clamp_s8(unpackedVals);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(For all files)
Instead of doing this, it would be easier to declare the In buffer as int16_t4 and pass it straight into the intrinsic:

Out[0] = pack_clamp_s8(In[0]);

...
#--- end

# Unimplemented: https://github.com/llvm/llvm-project/issues/99229

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(For all files)
nit

Suggested change
# Unimplemented: https://github.com/llvm/llvm-project/issues/99229
# Unimplemented https://github.com/llvm/llvm-project/issues/99229


# Unimplemented: https://github.com/llvm/llvm-project/issues/99229
# XFAIL: Clang

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(For all 16-bit files)
Add REQUIRES: Int16


[numthreads(1, 1, 1)]
void main() {
int16_t4 unpackedVals;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(For all files)
nit: capitalize variable names

@@ -0,0 +1,65 @@
#--- source.hlsl

StructuredBuffer<uint16_t> In : register(t0);

@kmpeng kmpeng Aug 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(For both the pack_clamp_s8 tests)
The input/output buffers are declared unsigned but they're used as signed.

int8_t4_packed packedVals = pack_clamp_s8(unpackedVals);
Out[0] = packedVals;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change

Out[2] = unpackedVals.z;
Out[3] = unpackedVals.w;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change

unpackedVals.w = In[3];
int8_t4_packed packedVals = pack_clamp_s8(unpackedVals);
Out[0] = packedVals;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(For all files)
There should be a constant folding test.

- Name: In
Format: Int16
Stride: 2
Data: [ -129, -128, 127, 128 ]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(For all files)
Could we test some more values? We're only packing 1 group of values, and they all seem to be boundary values. Would be good to also test some regular mid-range ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test for pack_clamp_s8

3 participants