[Mlir-commits] [mlir] [mlir] Enable LICM for ops with only read side effects in scf.for (PR #120302)

Jakub Kuderski llvmlistbot at llvm.org
Wed Jan 22 09:22:52 PST 2025


================
@@ -363,6 +363,16 @@ mlir::getEffectsRecursively(Operation *rootOp) {
   return effects;
 }
 
+bool mlir::isMemoryEffectFreeOrOnlyRead(Operation *op) {
+  std::optional<SmallVector<MemoryEffects::EffectInstance>> effects =
+      getEffectsRecursively(op);
+  if (!effects)
+    return false;
+  return std::all_of(effects->begin(), effects->end(), [](auto &effect) {
----------------
kuhar wrote:

Use `llvm::all_of`. Also, the lambda doesn't have to have a generic argument type.

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


More information about the Mlir-commits mailing list