forked from OSchip/llvm-project
[mlir][Vector] Make VectorToSCF deterministic
Differential Revision: https://reviews.llvm.org/D87273
This commit is contained in:
parent
3cda698723
commit
9be6178449
|
@ -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);
|
||||
|
|
|
@ -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: }
|
||||
|
|
Loading…
Reference in New Issue