Loop invariant code motion
loop_invariant_code_motion
This pass hoists operation that are invariant to the loops.
Similar to MLIR's loop invariant code motion: see external documentation.
An operation is loop-invariant if it depends only of values defined outside of the loop. LICM moves these operations out of the loop body so that they are not computed more than once.
LoopInvariantCodeMotion
Bases: RewritePattern
Source code in xdsl/transforms/loop_invariant_code_motion.py
86 87 88 89 | |
match_and_rewrite(op: scf.ForOp, rewriter: PatternRewriter) -> None
Source code in xdsl/transforms/loop_invariant_code_motion.py
87 88 89 | |
LoopInvariantCodeMotionPass
dataclass
Bases: ModulePass
Moves operations without side effects out of loops, provided they do not depend on values defined in the loops.
Source code in xdsl/transforms/loop_invariant_code_motion.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
name = 'licm'
class-attribute
instance-attribute
apply(ctx: Context, op: builtin.ModuleOp) -> None
Source code in xdsl/transforms/loop_invariant_code_motion.py
100 101 102 103 104 105 | |
can_be_hoisted(op: Operation, target_region: Region) -> bool | None
Checks whether the given op can be hoisted by checking that - the op and none of its contained operations depend on values inside of the loop.
Source code in xdsl/transforms/loop_invariant_code_motion.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
move_loop_invariant_code(loop: scf.ForOp)
Source code in xdsl/transforms/loop_invariant_code_motion.py
81 82 83 | |