[Mlir-commits] [mlir] [MLIR][SideEffects][MemoryEffects] Modified LICM to be more aggressive when checking movability of ops with MemWrite effects (PR #155344)

Mehdi Amini llvmlistbot at llvm.org
Wed Aug 27 02:17:32 PDT 2025


================
@@ -317,14 +319,53 @@ bool mlir::wouldOpBeTriviallyDead(Operation *op) {
   return wouldOpBeTriviallyDeadImpl(op);
 }
 
+std::optional<bool> mlir::isZeroTrip(mlir::LoopLikeOpInterface &loop) {
+  auto lbs = loop.getLoopLowerBounds();
+  auto ubs = loop.getLoopUpperBounds();
+  auto steps = loop.getLoopSteps();
+
+  if (!lbs || !ubs || !steps)
+    return std::nullopt;
+
+  if (lbs->size() != ubs->size() || ubs->size() != steps->size())
+    return std::nullopt;
+
+  for (size_t i = 0; i < steps->size(); ++i) {
----------------
joker-eph wrote:

```suggestion
  for (auto [lb, ub, step] : llvm::zip(*lbs, *ubs, *steps)) {
```

https://github.com/llvm/llvm-project/pull/155344


More information about the Mlir-commits mailing list