[Mlir-commits] [mlir] [mlir][NFC] Simplify constant checks with isZeroIndex and isOneIndex. (PR #139340)

Han-Chung Wang llvmlistbot at llvm.org
Mon May 12 10:54:10 PDT 2025


================
@@ -251,10 +251,7 @@ struct LoadStoreLikeOpRewriter : public OpRewritePattern<LoadStoreLikeOp> {
     // to do.
     SmallVector<OpFoldResult> indices =
         getAsOpFoldResult(loadStoreLikeOp.getIndices());
-    if (std::all_of(indices.begin(), indices.end(),
-                    [](const OpFoldResult &opFold) {
-                      return isConstantIntValue(opFold, 0);
-                    })) {
+    if (std::all_of(indices.begin(), indices.end(), isZeroIndex)) {
----------------
hanhanW wrote:

Thanks for pointing it out. I'm not the author of the snippet, but I'm happy to fix it because I'm touching the code.

I can see a reason of using llvm::all_of. It is more common in MLIR codebase, though there are few std::all_of uses. I'm happy to learn about your though of the suggestion, if you don't mind.

(This is a neutral change to me because the scope of the PR is simplifying the checks of constants and it touches the code. I'm not going to fix all the std::all_of use within the PR, but I can do it in a follow-up. I'm +1 on the change for consistency.)

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


More information about the Mlir-commits mailing list