Where the affine.apply cannot fold into the loop due to %arg1 not being the loop induction variable. In such case, the pass should hoist the affine.apply out of the for loop in order to fix value domination, since affine.apply is a pure op that doesn't touch memory and can therefore hoist safely.
Below shows the standard case that the pass has been supporting, where the
affine.apply
can get folded into thescf.for
loop bounds:However, user-provided code could come in the following form too:
Where the
affine.apply
cannot fold into the loop due to%arg1
not being the loop induction variable. In such case, the pass should hoist theaffine.apply
out of the for loop in order to fix value domination, sinceaffine.apply
is a pure op that doesn't touch memory and can therefore hoist safely.