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
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
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.