You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The instruction v12 = array_get v5, index v2 -> u32 is executed inside of the inner loop body in b6, when it can be executed in the preheader to the inner loop b3.
Happy Case
Looking at the example above, even though v2 comes from a block parameter, we know it is an induction variable on a loop with a constant bound. From this information, we can determine whether array_get is a safe index to move out of the loop.
We should be able to treat basic induction variables from parent loops as loop invariants when we are performing loop invariant code motion for inner loops.
To better note the benefit the optimization provides:
Writing out the above snippet manually for an upper_bound of 4 actually reduced the number of opcodes executed from 332 to 104.
Additional Context
No response
Project Impact
None
Blocker Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered:
Problem
When we have a nested loop as such:
We generate the following SSA:
The instruction
v12 = array_get v5, index v2 -> u32
is executed inside of the inner loop body inb6
, when it can be executed in the preheader to the inner loopb3
.Happy Case
Looking at the example above, even though
v2
comes from a block parameter, we know it is an induction variable on a loop with a constant bound. From this information, we can determine whetherarray_get
is a safe index to move out of the loop.We should be able to treat basic induction variables from parent loops as loop invariants when we are performing loop invariant code motion for inner loops.
Workaround
Yes
Workaround Description
Manually moving the loop invariant.
e.g. for the snippet above:
To better note the benefit the optimization provides:
Writing out the above snippet manually for an
upper_bound
of 4 actually reduced the number of opcodes executed from 332 to 104.Additional Context
No response
Project Impact
None
Blocker Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: