Skip to content

Commit fda19f9

Browse files
committed
!fixup add assert messages, default value
1 parent 96ddaa2 commit fda19f9

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

llvm/lib/Transforms/Vectorize/VPlanHelpers.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ class VPLane {
132132
unsigned Lane;
133133

134134
/// Indicates how the Lane should be interpreted, as described above.
135-
Kind LaneKind;
135+
Kind LaneKind = Kind::First;
136136

137137
public:
138-
VPLane(unsigned Lane) : Lane(Lane), LaneKind(VPLane::Kind::First) {}
138+
VPLane(unsigned Lane) : Lane(Lane) {}
139139
VPLane(unsigned Lane, Kind LaneKind) : Lane(Lane), LaneKind(LaneKind) {}
140140

141141
static VPLane getFirstLane() { return VPLane(0, VPLane::Kind::First); }
@@ -161,7 +161,8 @@ class VPLane {
161161
/// Returns a compile-time known value for the lane index and asserts if the
162162
/// lane can only be calculated at runtime.
163163
unsigned getKnownLane() const {
164-
assert(LaneKind == Kind::First);
164+
assert(LaneKind == Kind::First &&
165+
"can only get known lane from the beginning");
165166
return Lane;
166167
}
167168

@@ -179,10 +180,12 @@ class VPLane {
179180
unsigned mapToCacheIndex(const ElementCount &VF) const {
180181
switch (LaneKind) {
181182
case VPLane::Kind::ScalableLast:
182-
assert(VF.isScalable() && Lane < VF.getKnownMinValue());
183+
assert(VF.isScalable() && Lane < VF.getKnownMinValue() &&
184+
"ScalableLast can only be used with scalable VFs");
183185
return VF.getKnownMinValue() + Lane;
184186
default:
185-
assert(Lane < VF.getKnownMinValue());
187+
assert(Lane < VF.getKnownMinValue() &&
188+
"Cannot extract lane larger than VF");
186189
return Lane;
187190
}
188191
}

llvm/lib/Transforms/Vectorize/VPlanSLP.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@ void VPInterleavedAccessInfo::visitBlock(VPBlockBase *Block, Old2NewTy &Old2New,
8282
Align(IG->isReverse() ? (-1) * int(IG->getFactor())
8383
: IG->getFactor()));
8484
}
85-
} else if (VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block))
85+
} else if (VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block)) {
8686
visitRegion(Region, Old2New, IAI);
87-
else
87+
} else {
8888
llvm_unreachable("Unsupported kind of VPBlock.");
89+
}
8990
}
9091

9192
VPInterleavedAccessInfo::VPInterleavedAccessInfo(VPlan &Plan,

0 commit comments

Comments
 (0)