microsoft / microsoft/DirectXShaderCompiler
[SPIR-V] sign() codegen uses incorrect vector size for non-square uint matrices with at least two rows/columns
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
sign() generates invalid SPIR-V for any non-square uintMxN matrix with at least two rows and two columns due to a shape mismatch in the generated code: it uses OpUGreaterThan to compare each N-element row vector to an M-element zero vector and uses an M-element boolean vector result type.
Steps to Reproduce
Compile with dxc -T cs_6_0 -E main -Od -spirv source.hlsl:
[numthreads(1,1,1)]
void main() {
uint2x4 u;
int2x4 result = sign(u);
}
Actual Behavior
fatal error: generated SPIR-V is invalid: Expected vector sizes of Result Type and the operands to be equal: UGreaterThan
%31 = OpUGreaterThan %v2bool %28 %8
Disabling validation, we can see the shape mismatch:
%8 = OpConstantComposite %v2uint %uint_0 %uint_0
[...]
%28 = OpCompositeExtract %v4uint %27 0
%31 = OpUGreaterThan %v2bool %28 %8
Environment
- DXC version:
libdxcompiler.so: 1.10(5474-942eeceb)(1.9.0.15470) - Host Operating System: Fedora Linux 43
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided uint2x4 HLSL example and the dxc -T cs_6_0 -E main -Od -spirv source.hlsl command, or use the linked Godbolt case. Trace sign() code generation for non-square uint matrices and verify that the generated OpUGreaterThan operands and result type use matching vector sizes and pass SPIR-V validation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100