[Mlir-commits] [mlir] 9be6178 - [mlir][Vector] Make VectorToSCF deterministic
Nicolas Vasilache
llvmlistbot at llvm.org
Tue Sep 8 01:19:36 PDT 2020
Author: Nicolas Vasilache
Date: 2020-09-08T04:18:22-04:00
New Revision: 9be6178449555576645ac922e342936319445cac
URL: https://github.com/llvm/llvm-project/commit/9be6178449555576645ac922e342936319445cac
DIFF: https://github.com/llvm/llvm-project/commit/9be6178449555576645ac922e342936319445cac.diff
LOG: [mlir][Vector] Make VectorToSCF deterministic
Differential Revision: https://reviews.llvm.org/D87273
Added:
Modified:
mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
mlir/test/Conversion/VectorToSCF/vector-to-loops.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
index 8f7d43829846..08d0117e6a17 100644
--- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
+++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
@@ -584,9 +584,9 @@ LogicalResult VectorTransferRewriter<TransferReadOp>::matchAndRewrite(
steps.push_back(std_constant_index(step));
// 2. Emit alloc-copy-load-dealloc.
+ MLIRContext *ctx = op->getContext();
Value tmp = setAllocAtFunctionEntry(tmpMemRefType(transfer), transfer);
StdIndexedValue local(tmp);
- Value vec = vector_type_cast(tmp);
loopNestBuilder(lbs, ubs, steps, [&](ValueRange loopIvs) {
auto ivs = llvm::to_vector<8>(loopIvs);
// Swap the ivs which will reorder memory accesses.
@@ -595,13 +595,12 @@ LogicalResult VectorTransferRewriter<TransferReadOp>::matchAndRewrite(
// Computes clippedScalarAccessExprs in the loop nest scope (ivs exist).
SmallVector<Value, 8> indices = clip(transfer, memRefBoundsCapture, ivs);
ArrayRef<Value> indicesRef(indices), ivsRef(ivs);
- Value pos =
- std_index_cast(IntegerType::get(32, op->getContext()), ivsRef.back());
- Value vector = vector_insert_element(remote(indicesRef),
- local(ivsRef.drop_back()), pos);
+ Value pos = std_index_cast(IntegerType::get(32, ctx), ivsRef.back());
+ Value scal = remote(indicesRef);
+ Value vector = vector_insert_element(scal, local(ivsRef.drop_back()), pos);
local(ivsRef.drop_back()) = vector;
});
- Value vectorValue = std_load(vec);
+ Value vectorValue = std_load(vector_type_cast(tmp));
// 3. Propagate.
rewriter.replaceOp(op, vectorValue);
diff --git a/mlir/test/Conversion/VectorToSCF/vector-to-loops.mlir b/mlir/test/Conversion/VectorToSCF/vector-to-loops.mlir
index 240925baf3d8..5e8aea1f5113 100644
--- a/mlir/test/Conversion/VectorToSCF/vector-to-loops.mlir
+++ b/mlir/test/Conversion/VectorToSCF/vector-to-loops.mlir
@@ -99,8 +99,8 @@ func @materialize_read(%M: index, %N: index, %O: index, %P: index) {
// CHECK-NEXT: %[[L3:.*]] = select
// CHECK-NEXT: %[[VIDX:.*]] = index_cast %[[I4]]
//
- // CHECK-DAG: %[[SCAL:.*]] = load %{{.*}}[%[[L0]], %[[L1]], %[[L2]], %[[L3]]] : memref<?x?x?x?xf32>
- // CHECK-DAG: %[[VEC:.*]] = load %[[ALLOC]][%[[I6]], %[[I5]]] : memref<5x4xvector<3xf32>>
+ // CHECK-NEXT: %[[SCAL:.*]] = load %{{.*}}[%[[L0]], %[[L1]], %[[L2]], %[[L3]]] : memref<?x?x?x?xf32>
+ // CHECK-NEXT: %[[VEC:.*]] = load %[[ALLOC]][%[[I6]], %[[I5]]] : memref<5x4xvector<3xf32>>
// CHECK-NEXT: %[[RVEC:.*]] = vector.insertelement %[[SCAL]], %[[VEC]][%[[VIDX]] : i32] : vector<3xf32>
// CHECK-NEXT: store %[[RVEC]], %[[ALLOC]][%[[I6]], %[[I5]]] : memref<5x4xvector<3xf32>>
// CHECK-NEXT: }
More information about the Mlir-commits
mailing list