Skip to content

spirv-opt: handle mixed-width shifts in RedundantAndShift#6504

Merged
s-perron merged 1 commit intoKhronosGroup:mainfrom
spencer005:main
Feb 6, 2026
Merged

spirv-opt: handle mixed-width shifts in RedundantAndShift#6504
s-perron merged 1 commit intoKhronosGroup:mainfrom
spencer005:main

Conversation

@spencer005
Copy link
Contributor

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

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
@s-perron s-perron requested a review from luciechoi January 27, 2026 15:41
@s-perron s-perron enabled auto-merge (squash) February 5, 2026 16:06
@s-perron s-perron disabled auto-merge February 5, 2026 17:16
@s-perron s-perron merged commit a8afb02 into KhronosGroup:main Feb 6, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants