[Mlir-commits] [mlir] [mlir] Allow unroll & jam on SCF loops with results (PR #98887)

Aviad Cohen llvmlistbot at llvm.org
Mon Jul 15 13:14:45 PDT 2024


================
@@ -486,12 +486,15 @@ LogicalResult mlir::loopUnrollByFactor(
 }
 
 /// Check if bounds of all inner loops are defined outside of `forOp`
-/// and return false if not.
+/// or defined by constants, and return false if not.
 static bool areInnerBoundsInvariant(scf::ForOp forOp) {
   auto walkResult = forOp.walk([&](scf::ForOp innerForOp) {
-    if (!forOp.isDefinedOutsideOfLoop(innerForOp.getLowerBound()) ||
-        !forOp.isDefinedOutsideOfLoop(innerForOp.getUpperBound()) ||
-        !forOp.isDefinedOutsideOfLoop(innerForOp.getStep()))
+    if (!(forOp.isDefinedOutsideOfLoop(innerForOp.getLowerBound()) ||
----------------
AviadCo wrote:

nit: can you define a lambda to check if a given Value is either `forOp.isDefinedOutsideOfLoop(v) || isa<arith::ConstantOp>` and use it in the `if` condition?

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


More information about the Mlir-commits mailing list