Bases: ModulePass
Folds perfect loop nests if they can be represented with a single loop.
Currently does this by matching the inner loop range with the outer loop step.
If the inner iteration space fits perfectly in the outer iteration step, then merge.
Other conditions:
- the only use of the induction arguments must be an add operation, this op is fused
into a single induction argument,
- the lower bound of the inner loop must be 0,
- the loops must have no iteration arguments.
Source code in xdsl/transforms/scf_for_loop_flatten.py
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163 | class ScfForLoopFlattenPass(ModulePass):
"""
Folds perfect loop nests if they can be represented with a single loop.
Currently does this by matching the inner loop range with the outer loop step.
If the inner iteration space fits perfectly in the outer iteration step, then merge.
Other conditions:
- the only use of the induction arguments must be an add operation, this op is fused
into a single induction argument,
- the lower bound of the inner loop must be 0,
- the loops must have no iteration arguments.
"""
name = "scf-for-loop-flatten"
def apply(self, ctx: Context, op: builtin.ModuleOp) -> None:
PatternRewriteWalker(FlattenNestedLoopsPattern()).rewrite_module(op)
|
Source code in xdsl/transforms/scf_for_loop_flatten.py
| def apply(self, ctx: Context, op: builtin.ModuleOp) -> None:
PatternRewriteWalker(FlattenNestedLoopsPattern()).rewrite_module(op)
|