Skip to content

opt: dissolve OpCopyLogical of OpCompositeConstruct in simplification - #6746

Merged
s-perron merged 1 commit into
KhronosGroup:mainfrom
SteveUrquhart:fold-copylogical-of-composite
Jul 14, 2026
Merged

s-perron merged 1 commit into
KhronosGroup:mainfrom
SteveUrquhart:fold-copylogical-of-composite

Conversation

@SteveUrquhart

Copy link
Copy Markdown
Contributor

As described in microsoft/DirectXShaderCompiler#8382, this PR adds a new folding rule to deal with the new SPIR-V the optimizer is receiving from dxc since microsoft/DirectXShaderCompiler#7530. By rewriting

 %0 = OpCompositeConstruct %SrcStruct c0 c1 ... cN
 %1 = OpCopyLogical        %DstStruct %0

as

 %1 = OpCompositeConstruct %DstStruct c0' c1' ... cN'

...we can continue to legalize the technically-invalid

%cc = OpCompositeConstruct %ResHolder_block %resourceVar

...which dxc has always emitted.

@s-perron s-perron left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good. However, we usually assume the spir-v is valid coming into the pass is valid, so there is not need to handle cases where it is not. Those can be asserts. The exception to that is if this is part of DXC legalization. DXC is generating invalid code, and we want to handle it to eventually make it valid.

Comment thread source/opt/folding_rules.cpp Resolved
Comment thread test/opt/simplification_test.cpp Resolved
@SteveUrquhart
SteveUrquhart force-pushed the fold-copylogical-of-composite branch 2 times, most recently from ab5f507 to 8f3ac5d Compare June 18, 2026 21:56
@SteveUrquhart
SteveUrquhart force-pushed the fold-copylogical-of-composite branch from 8f3ac5d to d9d0319 Compare June 29, 2026 23:38
@s-perron
s-perron enabled auto-merge (squash) July 8, 2026 14:54
@s-perron

Copy link
Copy Markdown
Collaborator

@SteveUrquhart Please merge the latest main into your branch, and fix the formatting. The only CI failure that is related to this change is the formatting one.

auto-merge was automatically disabled July 13, 2026 18:53

Head branch was pushed to by a user without write access

@SteveUrquhart
SteveUrquhart force-pushed the fold-copylogical-of-composite branch from d9d0319 to 4bc6f4d Compare July 13, 2026 18:53
@SteveUrquhart

Copy link
Copy Markdown
Contributor Author

@s-perron , this should be good

@s-perron
s-perron enabled auto-merge (squash) July 14, 2026 20:02
@s-perron
s-perron merged commit 6ab70dc into KhronosGroup:main Jul 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants