[all-commits] [llvm/llvm-project] 36d8e7: [mlir] Enable LICM for ops with only read side eff...
Arda Unal via All-commits
all-commits at lists.llvm.org
Tue Feb 11 15:49:18 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 36d8e7056ef08d0f51e5b1e928274a8ca7dadeb5
https://github.com/llvm/llvm-project/commit/36d8e7056ef08d0f51e5b1e928274a8ca7dadeb5
Author: Arda Unal <3157490+ardaunal at users.noreply.github.com>
Date: 2025-02-11 (Tue, 11 Feb 2025)
Changed paths:
M mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
M mlir/include/mlir/Interfaces/LoopLikeInterface.td
M mlir/include/mlir/Interfaces/SideEffectInterfaces.h
M mlir/include/mlir/Transforms/LoopInvariantCodeMotionUtils.h
M mlir/lib/Dialect/SCF/IR/SCF.cpp
M mlir/lib/Interfaces/SideEffectInterfaces.cpp
M mlir/lib/Transforms/Utils/LoopInvariantCodeMotionUtils.cpp
M mlir/test/Transforms/loop-invariant-code-motion.mlir
M mlir/test/lib/Dialect/Test/TestOps.td
Log Message:
-----------
[mlir] Enable LICM for ops with only read side effects in scf.for (#120302)
Enable ops with only read side effects in scf.for to be hoisted with a
scf.if guard that checks against the trip count
This patch takes a step towards a less conservative LICM in MLIR as
discussed in the following discourse thread:
[Speculative LICM?](https://discourse.llvm.org/t/speculative-licm/80977)
This patch in particular does the following:
1. Relaxes the original constraint for hoisting that only hoists ops
without any side effects. This patch also allows the ops with only read
side effects to be hoisted into an scf.if guard only if every op in the
loop or its nested regions is side-effect free or has only read side
effects. This scf.if guard wraps the original scf.for and checks for
**trip_count > 0**.
2. To support this, two new interface methods are added to
**LoopLikeInterface**: _wrapInTripCountCheck_ and
_unwrapTripCountCheck_. Implementation starts with wrapping the scf.for
loop into scf.if guard using _wrapInTripCountCheck_ and if there is no
op hoisted into the this guard after we are done processing the
worklist, it unwraps the guard by calling _unwrapTripCountCheck_.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list