Skip to content

Commit fb5997b

Browse files
committed
!fixup address latest comments, thanks!
1 parent 54505a8 commit fb5997b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class VPLane {
168168
static VPLane getFirstLane() { return VPLane(0, VPLane::Kind::First); }
169169

170170
static VPLane getLaneFromEnd(const ElementCount &VF, unsigned Offset) {
171-
assert(Offset <= VF.getKnownMinValue() &&
171+
assert(Offset > 0 && Offset <= VF.getKnownMinValue() &&
172172
"trying to extract with invalid offset");
173173
unsigned LaneOffset = VF.getKnownMinValue() - Offset;
174174
Kind LaneKind;
@@ -1188,9 +1188,10 @@ class VPInstruction : public VPRecipeWithIRFlags {
11881188
BranchOnCount,
11891189
BranchOnCond,
11901190
ComputeReductionResult,
1191-
// Takes the VPValue to extract from as first operand and the lane to
1192-
// extract from as second operand. The second operand must be a constant and
1193-
// <= VF when extracting from a vector or <= UF when extracting from a
1191+
// Takes the VPValue to extract from as first operand and the lane or part
1192+
// to extract as second operand, counting from the end starting with 1 for
1193+
// last. The second operand must be a positive constant and <= VF when
1194+
// extracting from a vector or <= UF when extracting from an unrolled
11941195
// scalar.
11951196
ExtractFromEnd,
11961197
LogicalAnd, // Non-poison propagating logical And.
@@ -1230,10 +1231,6 @@ class VPInstruction : public VPRecipeWithIRFlags {
12301231
/// value for lane \p Lane.
12311232
Value *generatePerLane(VPTransformState &State, const VPIteration &Lane);
12321233

1233-
/// Returns true if this VPInstruction converts a vector value to a scalar,
1234-
/// e.g. by performing a reduction or extracting a lane.
1235-
bool isVectorToScalar() const;
1236-
12371234
#if !defined(NDEBUG)
12381235
/// Return true if the VPInstruction is a floating point math operation, i.e.
12391236
/// has fast-math flags.
@@ -1342,6 +1339,10 @@ class VPInstruction : public VPRecipeWithIRFlags {
13421339
};
13431340
llvm_unreachable("switch should return");
13441341
}
1342+
1343+
/// Returns true if this VPInstruction produces a scalar value from a vector,
1344+
/// e.g. by performing a reduction or extracting a lane.
1345+
bool isVectorToScalar() const;
13451346
};
13461347

13471348
/// VPWidenRecipe is a recipe for producing a copy of vector type its
@@ -3672,8 +3673,7 @@ inline bool isUniformAfterVectorization(VPValue *VPV) {
36723673
if (auto *GEP = dyn_cast<VPWidenGEPRecipe>(Def))
36733674
return all_of(GEP->operands(), isUniformAfterVectorization);
36743675
if (auto *VPI = dyn_cast<VPInstruction>(Def))
3675-
return VPI->getOpcode() == VPInstruction::ComputeReductionResult ||
3676-
VPI->getOpcode() == VPInstruction::ExtractFromEnd;
3676+
return VPI->isVectorToScalar();
36773677
return false;
36783678
}
36793679
} // end namespace vputils

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ Value *VPInstruction::generatePerPart(VPTransformState &State, unsigned Part) {
565565

566566
auto *CI = cast<ConstantInt>(getOperand(1)->getLiveInIRValue());
567567
unsigned Offset = CI->getZExtValue();
568-
568+
assert(Offset > 0 && "Offset from end must be positive");
569569
Value *Res;
570570
if (State.VF.isVector()) {
571571
assert(Offset <= State.VF.getKnownMinValue() &&

0 commit comments

Comments
 (0)