microsoft / microsoft/DirectXShaderCompiler

DXC does not eliminate wave intrinsic calls even when the result is unused

Open
#5,491 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description
The wave intrinsics are kept in the final dxil but I would expect them to be removed by DCE.

Steps to Reproduce

https://shader-playground.timjones.io/350a97df5de025ead832c7054409a7aa

// dxc /T ps_6_0 t.hlsl
[RootSignature("")]
void main(int a : A) {
  (void)WaveReadLaneFirst(a);
}

Actual Behavior

The output of WaveReadLaneFirst is unused, but the intrinsic call is still there in the dxil.

define void @main() {
  %1 = call i32 @dx.op.loadInput.i32(i32 4, i32 0, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %2 = call i32 @dx.op.waveReadLaneFirst.i32(i32 118, i32 %1)  ; WaveReadLaneFirst(value)
  ret void
}

Environment

  • DXC version Version: dxcompiler.dll: 1.6 - 1.6.2104.52 (e09a454eb); dxil.dll: 1.6(101.6.2104.33). Also repros on shader-playground with dxc trunc.
  • Host Operating System Windows

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 by reproducing the shader from the Shader Playground link with DXC and inspect the generated DXIL. Trace how DXC applies dead-code elimination to the unused WaveReadLaneFirst call, then verify that the intrinsic is absent from the output while compilation still succeeds.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.