microsoft / microsoft/DirectXShaderCompiler
Shader compiler doesn't generate a loop where one should exist
Open
Nobody has claimed this yet.
bug
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
Moved from internal bug 32923212
See https://godbolt.org/z/nGYxzTPn1
uint2 WaveMatchAdam(uint value)
{
do
{
bool isOurValue = (WaveReadLaneFirst(value) == value);
if (isOurValue)
{
return WaveActiveBallot(isOurValue).xy;
}
} while (true);
}
StructuredBuffer<uint> values : register(t0);
RWStructuredBuffer<uint2> matchMasks : register(u0);
[RootSignature("SRV(t0), UAV(u0)")]
[numthreads(64,1,1)]
void main(uint DTid : SV_DispatchThreadID)
{
uint value = values[DTid.x];
matchMasks[DTid.x] = WaveMatchAdam(value);
}
Generated DXIL doesn't contain a loop.
Steps to Reproduce
See https://godbolt.org/z/nGYxzTPn1
Environment
- libdxcompiler.so: 1.8(dev;1-b197bec6)
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
Start with the Godbolt reproduction at https://godbolt.org/z/nGYxzTPn1 and inspect the generated DXIL from libdxcompiler.so 1.8. Compare it with the HLSL do-while loop in the report and trace the compiler stage where the loop is lost. Done when the reproduction generates DXIL containing the expected loop.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100