[mlir][affine] Prevent vectorizer test from crash without any map
authorKai Sasaki <lewuathe@gmail.com>
Thu, 23 Mar 2023 00:59:29 +0000 (09:59 +0900)
committerKai Sasaki <lewuathe@gmail.com>
Thu, 23 Mar 2023 01:08:53 +0000 (10:08 +0900)
If the vectorizer test pass does not get any affine map, it should output nothing instead of crash.

Issue: https://github.com/llvm/llvm-project/issues/61534

Reviewed By: nicolasvasilache, dcaballe

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

mlir/test/Dialect/Affine/SuperVectorize/compose_maps.mlir
mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp

index 3b7820c..b53fc55 100644 (file)
@@ -159,3 +159,11 @@ func.func @multi_symbols() {
   "test_affine_map"() { affine_map = affine_map<(d0, d1)[s0, s1] -> (d0 + 1 + s1, d1 - 1 - s0)> } : () -> ()
   return
 }
+
+// -----
+
+// CHECK-LABEL: @no_affine_maps
+func.func @no_affine_maps() {
+  // CHECK: return
+  return
+}
index 61428bb..b31dd3f 100644 (file)
@@ -215,6 +215,9 @@ void VectorizerTestPass::testComposeMaps(llvm::raw_ostream &outs) {
                    .getValue();
     maps.push_back(map);
   }
+  if (maps.empty())
+    // Nothing to compose
+    return;
   AffineMap res;
   for (auto m : maps) {
     res = res ? res.compose(m) : m;