Repository navigation
spirv-opt: Ignore users outside basic blocks in loop peeling and fusion - #7050
Merged
s-perron merged 1 commit intoDec 3, 2026
Merged
Conversation
s-perron
approved these changes
Dec 3, 2026
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.
--loop-peeling and --loop-fusion crashed on loops whose values carry RelaxedPrecision, which glslang emits for mediump values. A #version 310 es fragment shader with a mediump loop counter is enough, and -O keeps the decorations.
The def-use manager lists annotations and debug instructions such as OpDecorate and OpName among the users of a value, and they belong to no basic block. Loop::IsLCSSA(), MakeSetClosedSSA() and LoopFusion::UsedInContinueOrConditionBlock() now skip a user without a block, as LoopFission already does. LoopFusion::IsUsedInLoop() now uses Loop::IsInsideLoop(Instruction*), which already handles that case.
The new tests PeelingPassTest.DecoratedLoopValueUsedAfterLoop and FusionPassTest.DecoratedLoopValues crash on main under ASan and UBSan and pass with this change. For glslang output of such a shader, --loop-peeling and --eliminate-local-multi-store --loop-fusion=5 exit 139 with v2025.1 and exit 0 with this change, and spirv-val accepts the output. test_opt and test_opt_loops pass.