Narrow blanket SPIR-V loop unroll in optimizer recipes#2
Draft
AnastaZIuk wants to merge 2 commits intomainfrom
Draft
Narrow blanket SPIR-V loop unroll in optimizer recipes#2AnastaZIuk wants to merge 2 commits intomainfrom
AnastaZIuk wants to merge 2 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
58kLoCRoot cause
The current SPIR-V optimizer recipes still carry two old blanket unroll decisions:
9fbcce4ca17dadded full loop unroll to legalization passes on 2018-09-193c47dac28208added full loop unroll to performance passes on 2020-05-20On a large preprocessed HLSL payload with many small
[unroll]loops this inflates the SPIR-V module far more than necessary and then pays for expensive cleanup over that self-inflated IR.LoopControl::Unrollas an IR hint is not the problem. The expensive part is treating that hint as a blanket request to immediately materialize full unroll in the generic optimizer path even when legality does not require it.A similar issue existed in the legalization tail. Some cleanup passes were effectively historical safety hammers rather than semantically required defaults. Narrowing them keeps the generic path correct while removing a large amount of unnecessary work.
DXC has the producer-side lowering context and knows when a specific HLSL pattern still requires materialized loop unroll or legalize-time SSA rewrite for correctness. The companion DXC patch in microsoft/DirectXShaderCompiler#8283 supplies that narrower signal, and its current branch head also materializes the companion SPIR-V submodule pointers.
Validation
58kLoCAMD Ryzen 5 5600G with Radeon Graphics,6physical cores,12logical processors, Windows-reported max clock3901 MHz19.161 sto6.042 s4.702 s2.464 sCodeGenSPIRVlit/FileCheck passes with the companion DXC branch:1403expected passes,2expected failures,0unexpectedCompanion DXC PR:
microsoft/DirectXShaderCompiler#8283