microsoft / microsoft/DirectXShaderCompiler

DXC not optimizing out code related to groupshared

Open
#4,701 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

For shader like this:
groupshared float a[10];
[numthreads(8,8,1)]
void main() {
a[0] = 1;
}
the output dxil is this:
@"\01?a@@3PAMA" = external addrspace(3) global [10 x float], align 4

define void @main() {
store float 1.000000e+00, float addrspace(3)* getelementptr inbounds ([10 x float], [10 x float] addrspace(3)* @"\01?a@@3PAMA", i32 0, i32 0), align 4, !tbaa !7
ret void
}

Expect the store and the global variable to be removed because there's only store on the global variabl.

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

Start with the HLSL reproducer in the issue and inspect the generated DXIL for the groupshared global and its store. Trace the optimization path that handles this shader and add or run a regression test; done means both the unused global and its store are absent from the output.

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
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.