summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Transforms/MaterializeVectors.cpp
diff options
context:
space:
mode:
authorNicolas Vasilache <ntv@google.com>2019-01-09 00:41:54 -0800
committerjpienaar <jpienaar@google.com>2019-03-29 15:05:55 -0700
commit1f78d63f05abdf32dbfcd7d4699b310213c87b7e (patch)
tree4d83d280107fb7f87d0fce76c0b8ab3d6962abe6 /mlir/lib/Transforms/MaterializeVectors.cpp
parent3e5ee82b817ce0c0188f046b5ef3b01a329d8041 (diff)
downloadbcm5719-llvm-1f78d63f05abdf32dbfcd7d4699b310213c87b7e.tar.gz
bcm5719-llvm-1f78d63f05abdf32dbfcd7d4699b310213c87b7e.zip
[MLIR] Make SuperVectorization use normalized AffineApplyOp
Supervectorization does not plan on handling multi-result AffineMaps and non-canonical chains of > 1 AffineApplyOp. This CL uses the simpler single-result unbounded AffineApplyOp in the MaterializeVectors pass. PiperOrigin-RevId: 228469085
Diffstat (limited to 'mlir/lib/Transforms/MaterializeVectors.cpp')
-rw-r--r--mlir/lib/Transforms/MaterializeVectors.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/mlir/lib/Transforms/MaterializeVectors.cpp b/mlir/lib/Transforms/MaterializeVectors.cpp
index 8c8e1e88a08..12a83c08c7c 100644
--- a/mlir/lib/Transforms/MaterializeVectors.cpp
+++ b/mlir/lib/Transforms/MaterializeVectors.cpp
@@ -373,12 +373,16 @@ reindexAffineIndices(FuncBuilder *b, VectorType hwVectorType,
auto stride = vectorShape[i - numMemRefIndices - numSuperVectorIndices];
affineExprs.push_back(d_i + offset * stride);
}
- auto affineMap = AffineMap::get(numIndices, 0, affineExprs, {});
- // TODO(ntv): support a concrete map and composition.
- auto app = b->create<AffineApplyOp>(b->getInsertionPoint()->getLoc(),
- affineMap, memrefIndices);
- return SmallVector<mlir::Value *, 8>{app->getResults()};
+ // Create a bunch of single result maps.
+ return functional::map(
+ [b, numIndices, memrefIndices](AffineExpr expr) {
+ auto map = AffineMap::get(numIndices, 0, expr, {});
+ auto app = makeNormalizedAffineApply(
+ b, b->getInsertionPoint()->getLoc(), map, memrefIndices);
+ return app->getResult(0);
+ },
+ affineExprs);
}
/// Returns attributes with the following substitutions applied:
@@ -553,11 +557,17 @@ static bool instantiateMaterialization(Instruction *inst,
// Create a builder here for unroll-and-jam effects.
FuncBuilder b(inst);
auto *opInst = cast<OperationInst>(inst);
+ // AffineApplyOp are ignored: instantiating the proper vector op will take
+ // care of AffineApplyOps by composing them properly.
+ if (opInst->isa<AffineApplyOp>()) {
+ return false;
+ }
if (auto write = opInst->dyn_cast<VectorTransferWriteOp>()) {
auto *clone = instantiate(&b, write, state->hwVectorType,
state->hwVectorInstance, state->substitutionsMap);
return clone == nullptr;
- } else if (auto read = opInst->dyn_cast<VectorTransferReadOp>()) {
+ }
+ if (auto read = opInst->dyn_cast<VectorTransferReadOp>()) {
auto *clone = instantiate(&b, read, state->hwVectorType,
state->hwVectorInstance, state->substitutionsMap);
if (!clone) {
@@ -570,10 +580,12 @@ static bool instantiateMaterialization(Instruction *inst,
// The only op with 0 results reaching this point must, by construction, be
// VectorTransferWriteOps and have been caught above. Ops with >= 2 results
// are not yet supported. So just support 1 result.
- if (opInst->getNumResults() != 1)
+ if (opInst->getNumResults() != 1) {
return inst->emitError("NYI: ops with != 1 results");
- if (opInst->getResult(0)->getType() != state->superVectorType)
+ }
+ if (opInst->getResult(0)->getType() != state->superVectorType) {
return inst->emitError("Op does not return a supervector.");
+ }
auto *clone =
instantiate(&b, opInst, state->hwVectorType, state->substitutionsMap);
if (!clone) {
OpenPOWER on IntegriCloud