spirv-opt: handle mixed-width shifts in RedundantAndShift#6504
Merged
s-perron merged 1 commit intoKhronosGroup:mainfrom Feb 6, 2026
Merged
spirv-opt: handle mixed-width shifts in RedundantAndShift#6504s-perron merged 1 commit intoKhronosGroup:mainfrom
s-perron merged 1 commit intoKhronosGroup:mainfrom
Conversation
I encountered a crash with instruction foldings enabled while using shaderc (test case 15), this commit adds support for instruction folding for all different cases I interpreted as valid while reading the spirv spec. https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html 3.3.14. Bit Instructions
luciechoi
approved these changes
Feb 5, 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.
I encountered a crash with instruction folding enabled while using shaderc (reproduced in test case 15) where shaderc generated code with a 32 shift on a 64bit int, this commit adds support for instruction folding for all different cases I interpreted as valid from reading the spirv spec.
https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html 3.3.14. Bit Instructions
To the best of my knowledge this is correct and I added tests
only supports 8/16/32/64 width since that's what I saw defined in the spec but should handle things like https://github.khronos.org/SPIRV-Registry/extensions/ALTERA/SPV_ALTERA_arbitrary_precision_integers.html fine by not folding as it did before while fixing the mixed-width shift case and supporting 8/16