spirv-opt: handle mixed-width shifts in RedundantAndShift #6504
+157
−30
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