[Mlir-commits] [mlir] f9f6b4f - [mlir] Silence GCC warnings

Diego Caballero llvmlistbot at llvm.org
Thu Feb 4 10:55:05 PST 2021


Author: Diego Caballero
Date: 2021-02-04T20:54:18+02:00
New Revision: f9f6b4f30b761864e263481bec4593869700b5ba

URL: https://github.com/llvm/llvm-project/commit/f9f6b4f30b761864e263481bec4593869700b5ba
DIFF: https://github.com/llvm/llvm-project/commit/f9f6b4f30b761864e263481bec4593869700b5ba.diff

LOG: [mlir] Silence GCC warnings

Reviewed By: mehdi_amini, rriddle

Differential Revision: https://reviews.llvm.org/D95906

Added: 
    

Modified: 
    mlir/include/mlir/CAPI/IntegerSet.h
    mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/CAPI/IntegerSet.h b/mlir/include/mlir/CAPI/IntegerSet.h
index 465b1f9cda00..bb7f899042d8 100644
--- a/mlir/include/mlir/CAPI/IntegerSet.h
+++ b/mlir/include/mlir/CAPI/IntegerSet.h
@@ -19,6 +19,6 @@
 #include "mlir/CAPI/Wrap.h"
 #include "mlir/IR/IntegerSet.h"
 
-DEFINE_C_API_METHODS(MlirIntegerSet, mlir::IntegerSet);
+DEFINE_C_API_METHODS(MlirIntegerSet, mlir::IntegerSet)
 
 #endif // MLIR_CAPI_INTEGERSET_H

diff  --git a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
index d8b535057f6e..e2f3d8e41f72 100644
--- a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
@@ -1335,34 +1335,36 @@ void Vectorize::runOnFunction() {
 ///   * There must be a single root loop (nesting level 0).
 ///   * Each loop at a given nesting level must be nested in a loop from a
 ///     previous nesting level.
-static void
+static LogicalResult
 verifyLoopNesting(const std::vector<SmallVector<AffineForOp, 2>> &loops) {
-  assert(!loops.empty() && "Expected at least one loop");
-  assert(loops[0].size() == 1 && "Expected only one root loop");
+  // Expected at least one loop.
+  if (loops.empty())
+    return failure();
+
+  // Expected only one root loop.
+  if (loops[0].size() != 1)
+    return failure();
 
   // Traverse loops outer-to-inner to check some invariants.
   for (int i = 1, end = loops.size(); i < end; ++i) {
     for (AffineForOp loop : loops[i]) {
       //  Check that each loop at this level is nested in one of the loops from
       //  the previous level.
-      bool parentFound = false;
-      for (AffineForOp maybeParent : loops[i - 1]) {
-        if (maybeParent->isProperAncestor(loop)) {
-          parentFound = true;
-          break;
-        }
-      }
-      assert(parentFound && "Child loop not nested in any parent loop");
+      if (none_of(loops[i - 1], [&](AffineForOp maybeParent) {
+            return maybeParent->isProperAncestor(loop);
+          }))
+        return failure();
 
       //  Check that each loop at this level is not nested in another loop from
       //  this level.
-#ifndef NDEBUG
-      for (AffineForOp sibling : loops[i])
-        assert(!sibling->isProperAncestor(loop) &&
-               "Loops at the same level are nested");
-#endif
+      for (AffineForOp sibling : loops[i]) {
+        if (sibling->isProperAncestor(loop))
+          return failure();
+      }
     }
   }
+
+  return success();
 }
 
 namespace mlir {
@@ -1420,7 +1422,8 @@ vectorizeAffineLoopNest(std::vector<SmallVector<AffineForOp, 2>> &loops,
                         const VectorizationStrategy &strategy) {
   // Thread-safe RAII local context, BumpPtrAllocator freed on exit.
   NestedPatternContext mlContext;
-  verifyLoopNesting(loops);
+  if (failed(verifyLoopNesting(loops)))
+    return failure();
   return vectorizeLoopNest(loops, strategy);
 }
 


        


More information about the Mlir-commits mailing list