spirv-opt: Adding nested reassociation rules#6453
Open
alister-chowdhury wants to merge 3 commits intoKhronosGroup:mainfrom
Open
spirv-opt: Adding nested reassociation rules#6453alister-chowdhury wants to merge 3 commits intoKhronosGroup:mainfrom
alister-chowdhury wants to merge 3 commits intoKhronosGroup:mainfrom
Conversation
**ReassociateNestedGenericInt** Reassociate integer instructions where both operands share the same opcode and both source instructions contain a constant. e.g: ``` (a * C0) * (C1 * b) = (C0 * C1) * (a * b) (a ^ C0) ^ (b ^ C1) = (C0 ^ C1) ^ (a ^ b) (C0 | a) | (b | C1) = (C0 | C1) | (a | b) (a & C0) & (b & C1) = (C0 & C1) & (a & b) ``` **ReassociateNestedMulDivFloat** Reassociate floating point mul/div instructions, which have mul/div inputs, both of which contain a constant. e.g: ``` (a * C0) / (C1 / b) = (C0 / C1) * (a * b) (C0 / a) * (b / C1) = (C0 / C1) * (b / a) (a / C0) / (b * C1) = (1 / (C0 * C1)) * (a / b) ``` **ReassociateNestedAddSub** Reassociate add/sub instructions, which have add/sub inputs, both of which contain a constant. e.g: ``` (a + C0) - (C1 - b) = (C0 - C1) + (a + b) (C0 - a) + (b - C1) = (C0 - C1) + (b - a) (a - C0) - (b + C1) = (-C0 - C1) + (a - b) ```
22c9241 to
3ceddc7
Compare
luciechoi
approved these changes
Jan 23, 2026
Contributor
Author
|
@luciechoi I'm not totally sure if the CI fails are related to my changes (but will happily fix them if they are). |
Collaborator
|
The failure in CI-macos-clang-release-bazel is a timeout in the folding tests. Please resolve the conflicts, and we can look into the time out more. We might see if we can splitup the folding tests if it was not just a fluke. |
auto-merge was automatically disabled
February 6, 2026 06:14
Head branch was pushed to by a user without write access
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.
ReassociateNestedGenericInt
Reassociate integer instructions where both operands share the same opcode and both source instructions contain a constant.
e.g:
ReassociateNestedMulDivFloat
Reassociate floating point mul/div instructions, which have mul/div inputs, both of which contain a constant.
e.g:
ReassociateNestedAddSub
Reassociate add/sub instructions, which have add/sub inputs, both of which contain a constant.
e.g: