[Mlir-commits] [mlir] 9215357 - [MLIR] Fix TestAffineDataCopy for test cases with no load ops

Uday Bondhugula llvmlistbot at llvm.org
Mon May 3 10:13:38 PDT 2021


Author: Uday Bondhugula
Date: 2021-05-03T22:42:52+05:30
New Revision: 92153575e64bf8e2e14ed236416bbb33cf7e2c2e

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

LOG: [MLIR] Fix TestAffineDataCopy for test cases with no load ops

Add missing check in -test-affine-data-copy without which a test case
that has no affine.loads at all would crash this test pass. Fix two
clang-tidy warnings in the file while at this. (Not adding a test case
given the triviality.)

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

Added: 
    

Modified: 
    mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp b/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp
index b2d454bb23e04..593e549fa2ecf 100644
--- a/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp
+++ b/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp
@@ -76,6 +76,8 @@ void TestAffineDataCopy::runOnFunction() {
       }
     }
   }
+  if (!load)
+    return;
 
   AffineCopyOptions copyOptions = {/*generateDma=*/false,
                                    /*slowMemorySpace=*/0,
@@ -95,7 +97,7 @@ void TestAffineDataCopy::runOnFunction() {
   // Promote any single iteration loops in the copy nests and simplify
   // load/stores.
   SmallVector<Operation *, 4> copyOps;
-  for (auto nest : copyNests)
+  for (Operation *nest : copyNests) {
     // With a post order walk, the erasure of loops does not affect
     // continuation of the walk or the collection of load/store ops.
     nest->walk([&](Operation *op) {
@@ -106,12 +108,13 @@ void TestAffineDataCopy::runOnFunction() {
       else if (auto storeOp = dyn_cast<AffineStoreOp>(op))
         copyOps.push_back(storeOp);
     });
+  }
 
   // Promoting single iteration loops could lead to simplification of
   // generated load's/store's, and the latter could anyway also be
   // canonicalized.
   RewritePatternSet patterns(&getContext());
-  for (auto op : copyOps) {
+  for (Operation *op : copyOps) {
     patterns.clear();
     if (isa<AffineLoadOp>(op)) {
       AffineLoadOp::getCanonicalizationPatterns(patterns, &getContext());


        


More information about the Mlir-commits mailing list