Skip to content

Commit 2052b9d

Browse files
committed
modify code with best practices
1 parent 99f6885 commit 2052b9d

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "mlir/Dialect/Vector/IR/VectorOps.h"
2525
#include "mlir/Dialect/Vector/Utils/VectorUtils.h"
2626
#include "mlir/IR/IRMapping.h"
27+
#include "mlir/IR/Value.h"
2728
#include "mlir/Pass/Pass.h"
2829
#include "mlir/Support/LLVM.h"
2930
#include "llvm/ADT/STLExtras.h"
@@ -1192,19 +1193,20 @@ static bool isIVMappedToMultipleIndices(
11921193
for (auto &kvp : loopToVectorDim) {
11931194
AffineForOp forOp = cast<AffineForOp>(kvp.first);
11941195
// Find which indices are invariant w.r.t. this loop IV.
1195-
auto invariants =
1196+
llvm::DenseSet<Value> invariants =
11961197
affine::getInvariantAccesses(forOp.getInductionVar(), indices);
11971198
// Count how many vary (i.e. are not invariant).
11981199
unsigned nonInvariant = 0;
1199-
for (Value idx : indices)
1200-
if (!invariants.count(idx))
1201-
++nonInvariant;
1202-
// Bail if more than one index varies for this single loop IV.
1203-
if (nonInvariant > 1) {
1204-
LLVM_DEBUG(dbgs() << "[early‑vect] Bail out: IV "
1205-
<< forOp.getInductionVar() << " drives " << nonInvariant
1206-
<< " indices\n");
1207-
return true;
1200+
for (Value idx : indices) {
1201+
if (invariants.count(idx))
1202+
continue;
1203+
1204+
if (++nonInvariant > 1) {
1205+
LLVM_DEBUG(dbgs() << "[early‑vect] Bail out: IV "
1206+
<< forOp.getInductionVar() << " drives "
1207+
<< nonInvariant << " indices\n");
1208+
return true;
1209+
}
12081210
}
12091211
}
12101212
return false;

mlir/test/Dialect/Affine/SuperVectorize/vectorize_unsupported.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ func.func @iv_mapped_to_multiple_indices_unsupported(%arg0: index) -> memref<2x2
3333
// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0)[s0] -> (d0 mod s0)>
3434

3535
// CHECK-LABEL: func.func @iv_mapped_to_multiple_indices_unsupported(
36-
// CHECK-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: index) -> memref<2x2xf32> {
36+
// CHECK-SAME: %[[VAL_0:.*]]: index) -> memref<2x2xf32> {
3737
// CHECK: %[[VAL_1:.*]] = arith.constant 2 : index
3838
// CHECK: affine.for %[[VAL_4:.*]] = 0 to 4 {
3939
// CHECK: %[[VAL_5:.*]] = affine.apply #[[$ATTR_0]](%[[VAL_4]]){{\[}}%[[VAL_1]]]
4040
// CHECK: %[[VAL_6:.*]] = affine.apply #[[$ATTR_1]](%[[VAL_4]]){{\[}}%[[VAL_1]]]
4141
// CHECK: }
42-
// CHECK: }
42+
// CHECK: }

0 commit comments

Comments
 (0)