[Mlir-commits] [mlir] [mlir] Use getArgNumber to get argument index (NFC) (PR #162959)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Oct 10 20:18:04 PDT 2025


================
@@ -324,8 +324,7 @@ static LoopLikeOpInterface hoistSubsetAtIterArg(RewriterBase &rewriter,
                                                 LoopLikeOpInterface loopLike,
                                                 BlockArgument iterArg) {
   assert(iterArg.getOwner()->getParentOp() == loopLike && "invalid iter_arg");
-  BlockArgument *it = llvm::find(loopLike.getRegionIterArgs(), iterArg);
-  int64_t iterArgIdx = std::distance(loopLike.getRegionIterArgs().begin(), it);
+  int64_t iterArgIdx = iterArg.getArgNumber() - 1;
----------------
PragmaTwice wrote:

Hmm I think it can be `iterArg.getArgNumber() - N` depending on how `getRegionIterArgs()` is defined for the specific looplike op? For `scf.for` it can always be `N = 1`, but is it applicable for other ops (`forall`, `while`..)?

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


More information about the Mlir-commits mailing list