diff --git a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_unsupported.mlir b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_unsupported.mlir new file mode 100644 --- /dev/null +++ b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_unsupported.mlir @@ -0,0 +1,11 @@ +// RUN: mlir-opt -allow-unregistered-dialect %s -affine-super-vectorizer-test -vectorize-affine-loop-nest -split-input-file 2>&1 | FileCheck %s + +func.func @unparallel_loop_reduction_unsupported(%in: memref<256x512xf32>, %out: memref<256xf32>) { + // CHECK: Outermost loop cannot be parallel + %cst = arith.constant 1.000000e+00 : f32 + %final_red = affine.for %j = 0 to 512 iter_args(%red_iter = %cst) -> (f32) { + %add = arith.addf %red_iter, %red_iter : f32 + affine.yield %add : f32 + } + return +} diff --git a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp --- a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp +++ b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp @@ -92,7 +92,7 @@ void testComposeMaps(llvm::raw_ostream &outs); /// Test for 'vectorizeAffineLoopNest' utility. - void testVecAffineLoopNest(); + void testVecAffineLoopNest(llvm::raw_ostream &outs); }; } // namespace @@ -226,7 +226,7 @@ } /// Test for 'vectorizeAffineLoopNest' utility. -void VectorizerTestPass::testVecAffineLoopNest() { +void VectorizerTestPass::testVecAffineLoopNest(llvm::raw_ostream &outs) { std::vector> loops; gatherLoops(getOperation(), loops); @@ -239,6 +239,13 @@ VectorizationStrategy strategy; strategy.vectorSizes.push_back(4 /*vectorization factor*/); strategy.loopToVectorDim[outermostLoop] = 0; + + ReductionLoopMap reductionLoops; + SmallVector reductions; + if (!isLoopParallel(outermostLoop, &reductions)) { + outs << "Outermost loop cannot be parallel\n"; + return; + } std::vector> loopsToVectorize; loopsToVectorize.push_back({outermostLoop}); (void)vectorizeAffineLoopNest(loopsToVectorize, strategy); @@ -273,7 +280,7 @@ } if (clTestVecAffineLoopNest) - testVecAffineLoopNest(); + testVecAffineLoopNest(outs); if (!outs.str().empty()) { emitRemark(UnknownLoc::get(&getContext()), outs.str());