Repository navigation
opt: Fix invalid OpSelect folding in spirv-opt - #6827
Merged
Merged
Conversation
MergeBinaryOpSelect rule was folding binary operations with select instructions even when the result was a vector and the condition was scalar, which is only valid in SPIR-V 1.4+. This change restricts this folding in SPIR-V versions prior to 1.4. Assisted by: Antigravity Fixes #8603
sudonatalie
approved these changes
Aug 5, 2026
s-perron
enabled auto-merge (squash)
August 5, 2026 17:42
damyanp
added a commit
to damyanp/DirectXShaderCompiler
that referenced
this pull request
Aug 5, 2026
…#8603) Advances external/SPIRV-Tools from b707790a to 1c336172, which includes KhronosGroup/SPIRV-Tools#6827 "opt: Fix invalid OpSelect folding in spirv-opt". The MergeBinaryOpSelect folding rule was merging a binary op with an OpSelect even when the result type was a vector and the select's condition was a scalar bool. That form of OpSelect is only legal from SPIR-V 1.4 onwards, so targeting vulkan1.1 (SPIR-V 1.3) produced a module that failed validation: fatal error: generated SPIR-V is invalid: Expected vector sizes of Result Type and the condition to be equal: Select %91 = OpSelect %v3float %87 %38 %39 The upstream fix skips the fold in that case for SPIR-V versions before 1.4. DXC always constructs spvtools::Optimizer with the target env from -fspv-target-env, so the guard applies to all DXC SPIR-V codegen. b707790a is an ancestor of 1c336172, so this keeps the loop-unrolling duplicate decoration fix that resolves microsoft#8609. SPIRV-Headers needs no change: 1c336172 pins 29981f65, which is what this branch already uses. Fixes microsoft#8603 Co-authored-by: Copilot <[email protected]> Copilot-Session: b04b21af-2d8b-4af5-b9ad-1b84073588f5
|
@s-perron - in the future, could you please avoid putting a "fixes xxxx" note in PRs here for issues that are in the DXC repo? It auto-closes those issues, which isn't really the desired behavior since we still have work to do to integrate the fix into DXC. |
This was referenced Aug 6, 2026
damyanp
added a commit
to microsoft/DirectXShaderCompiler
that referenced
this pull request
Aug 6, 2026
Fixes two SPIR-V validation failures under -O3: - #8609: loop unrolling duplicated RelaxedPrecision decorations (KhronosGroup/SPIRV-Tools#6690) - #8603: MergeBinaryOpSelect produced an OpSelect with a vector result type and a scalar condition, only legal in SPIR-V 1.4+ (KhronosGroup/SPIRV-Tools#6827) SPIRV-Headers moves to 29981f65 to match; SPIRV-Tools 1c336172 does not build against the older headers. XFAIL resource-heap-ext-texture: the validator now requires explicit layout for UniformConstant when SPV_EXT_descriptor_heap is used (KhronosGroup/SPIRV-Tools#6792). Assisted-by: copilot Co-authored-by: Copilot <[email protected]> Copilot-Session: b04b21af-2d8b-4af5-b9ad-1b84073588f5 Co-authored-by: Copilot <[email protected]> Copilot-Session: b04b21af-2d8b-4af5-b9ad-1b84073588f5
damyanp
added a commit
to microsoft/DirectXShaderCompiler
that referenced
this pull request
Aug 6, 2026
Fixes #8603: MergeBinaryOpSelect produced an OpSelect with a vector result type and a scalar condition, which is only legal in SPIR-V 1.4+ (KhronosGroup/SPIRV-Tools#6827). This exposes #8740 where the resource-heap-ext-texture.hlsl test fails validation - for now this is worked around by disabling the test, since #8517 looks like it is reworking it anyway. Assisted-by: copilot --------- Co-authored-by: Copilot <[email protected]> Copilot-Session: b04b21af-2d8b-4af5-b9ad-1b84073588f5
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.
MergeBinaryOpSelect rule was folding binary operations with select
instructions even when the result was a vector and the condition was
scalar, which is only valid in SPIR-V 1.4+. This change restricts
this folding in SPIR-V versions prior to 1.4.
Assisted by: Antigravity
Fixes microsoft/DirectXShaderCompiler#8603