microsoft / microsoft/DirectXShaderCompiler

[SPIR-V] sign() codegen uses incorrect vector size for non-square uint matrices with at least two rows/columns

Open
#8,860 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage spirv
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

Godbolt

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.