return false;
}
+ // No vectorization for ops with operand or result types that are not
+ // vectorizable.
+ auto types = matcher::Op([](Operation &op) -> bool {
+ if (llvm::any_of(op.getOperandTypes(), [](Type type) {
+ if (MemRefType t = dyn_cast<MemRefType>(type))
+ return !VectorType::isValidElementType(t.getElementType());
+ return !VectorType::isValidElementType(type);
+ }))
+ return true;
+ return llvm::any_of(op.getResultTypes(), [](Type type) {
+ return !VectorType::isValidElementType(type);
+ });
+ });
+ SmallVector<NestedMatch, 8> opsMatched;
+ types.match(forOp, &opsMatched);
+ if (!opsMatched.empty()) {
+ return false;
+ }
+
// No vectorization across unknown regions.
auto regions = matcher::Op([](Operation &op) -> bool {
return op.getNumRegions() != 0 && !isa<AffineIfOp, AffineForOp>(op);
--- /dev/null
+// RUN: mlir-opt %s -affine-super-vectorize="virtual-vector-size=128" -split-input-file | FileCheck %s
+
+// CHECK-LABEL: func @invalid_operand
+func.func @invalid_operand(%a : vector<4xf32>, %b : vector<4xf32>) {
+// CHECK: affine.for %{{.*}} = 0 to 10
+// CHECK: %{{.*}} = vector.reduction <add>, %{{.*}} : vector<4xf32> into f32
+// CHECK: }
+// CHECK: return
+ affine.for %j = 0 to 10 {
+ %1 = vector.reduction <add>, %a : vector<4xf32> into f32
+ }
+ return
+}
+
+// CHECK-LABEL: func @invalid_result
+func.func @invalid_result(%a : memref<10x20xf32>, %b : memref<10x20xf32>) {
+// CHECK: affine.for %{{.*}} = 0 to 10
+// CHECK: affine.for %{{.*}} = 0 to 5
+// CHECK: %{{.*}} = affine.vector_load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x20xf32>, vector<4xf32>
+// CHECK: affine.vector_store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x20xf32>, vector<4xf32>
+// CHECK: }
+// CHECK: }
+// CHECK: return
+ affine.for %j = 0 to 10 {
+ affine.for %i = 0 to 5 {
+ %ld0 = affine.vector_load %a[%j, %i] : memref<10x20xf32>, vector<4xf32>
+ affine.vector_store %ld0, %b[%j, %i] : memref<10x20xf32>, vector<4xf32>
+ }
+ }
+ return
+}