Commit 69f1c0d
spirv-opt: Adding nested reassociation rules (KhronosGroup#6453)
**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)
```
---------
Co-authored-by: Steven Perron <[email protected]>1 parent 915b8a6 commit 69f1c0d
3 files changed
Lines changed: 2251 additions & 5 deletions
0 commit comments