@@ -168,7 +168,7 @@ class VPLane {
168
168
static VPLane getFirstLane () { return VPLane (0 , VPLane::Kind::First); }
169
169
170
170
static VPLane getLaneFromEnd (const ElementCount &VF, unsigned Offset) {
171
- assert (Offset <= VF.getKnownMinValue () &&
171
+ assert (Offset > 0 && Offset <= VF.getKnownMinValue () &&
172
172
" trying to extract with invalid offset" );
173
173
unsigned LaneOffset = VF.getKnownMinValue () - Offset;
174
174
Kind LaneKind;
@@ -1188,9 +1188,10 @@ class VPInstruction : public VPRecipeWithIRFlags {
1188
1188
BranchOnCount,
1189
1189
BranchOnCond,
1190
1190
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
1194
1195
// scalar.
1195
1196
ExtractFromEnd,
1196
1197
LogicalAnd, // Non-poison propagating logical And.
@@ -1230,10 +1231,6 @@ class VPInstruction : public VPRecipeWithIRFlags {
1230
1231
// / value for lane \p Lane.
1231
1232
Value *generatePerLane (VPTransformState &State, const VPIteration &Lane);
1232
1233
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
-
1237
1234
#if !defined(NDEBUG)
1238
1235
// / Return true if the VPInstruction is a floating point math operation, i.e.
1239
1236
// / has fast-math flags.
@@ -1342,6 +1339,10 @@ class VPInstruction : public VPRecipeWithIRFlags {
1342
1339
};
1343
1340
llvm_unreachable (" switch should return" );
1344
1341
}
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 ;
1345
1346
};
1346
1347
1347
1348
// / VPWidenRecipe is a recipe for producing a copy of vector type its
@@ -3672,8 +3673,7 @@ inline bool isUniformAfterVectorization(VPValue *VPV) {
3672
3673
if (auto *GEP = dyn_cast<VPWidenGEPRecipe>(Def))
3673
3674
return all_of (GEP->operands (), isUniformAfterVectorization);
3674
3675
if (auto *VPI = dyn_cast<VPInstruction>(Def))
3675
- return VPI->getOpcode () == VPInstruction::ComputeReductionResult ||
3676
- VPI->getOpcode () == VPInstruction::ExtractFromEnd;
3676
+ return VPI->isVectorToScalar ();
3677
3677
return false ;
3678
3678
}
3679
3679
} // end namespace vputils
0 commit comments