microsoft / microsoft/DirectXShaderCompiler

LLVM error when accessing an array of matrices using a vector subscript on the final column.

Open
#7,642 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Description
Error in the LLVM when trying to compile code that uses an array of matrices and trying to index the final element by the subscript .a. Switching this to [3] fixes the issue.

Steps to Reproduce
Gobolt.org link
Command line: -T cs_6_6 -E main -Od

void swap(inout uint lhs, inout uint rhs)
{
    uint tmp = lhs;
    lhs = rhs;
    rhs = tmp;
}

[numthreads(64,1,1)]
void main(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID)
{
    uint2x4 a[2];
    uint2x4 b = a[0];
    
    swap(b[0].a, b[1].a); // Work
    swap(a[0][0].a, a[0][1].a); // Doesn't work
}

Actual Behavior


error: validation errors
error: Module bitcode is invalid.
error: Instruction does not dominate all uses!
  %41 = load i32, i32* %40
  store i32 %41, i32* %38

Validation failed.


Compiler returned: 5

Environment
DXC version 1.6.2112 to DXC version 1.8.2502
Windows 11, version 22631.5039

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 failure with the linked Godbolt HLSL example using DXC and the command line -T cs_6_6 -E main -Od. Compare the failing a[0][0].a access with the working equivalent accesses, then verify that the compiler no longer reports invalid LLVM bitcode or dominance errors.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.