Skip to content

Commit 6bcaac8

Browse files
committed
!fixup address comments, thanks
1 parent f9c3619 commit 6bcaac8

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,9 @@ bool VPInstruction::onlyFirstLaneUsed(const VPValue *Op) const {
12681268
return true;
12691269
case VPInstruction::BuildStructVector:
12701270
case VPInstruction::BuildVector:
1271+
// Before replicating by VF, Build(Struct)Vector uses all lanes of the
1272+
// operand, after replicating its operands only the first lane is used.
1273+
// Before replicating, it will only have a single operand.
12711274
return getNumOperands() > 1;
12721275
case VPInstruction::PtrAdd:
12731276
return Op == getOperand(0) || vputils::onlyFirstLaneUsed(this);

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3706,7 +3706,7 @@ void VPlanTransforms::materializeBuildVectors(VPlan &Plan) {
37063706
for (VPRecipeBase &R : make_early_inc_range(*VPBB)) {
37073707
if (!isa<VPReplicateRecipe, VPInstruction>(&R))
37083708
continue;
3709-
auto *DefR = dyn_cast<VPRecipeWithIRFlags>(&R);
3709+
auto *DefR = cast<VPRecipeWithIRFlags>(&R);
37103710
auto UsesVectorOrInsideReplicateRegion = [DefR, LoopRegion](VPUser *U) {
37113711
VPRegionBlock *ParentRegion =
37123712
cast<VPRecipeBase>(U)->getParent()->getParent();
@@ -3715,8 +3715,8 @@ void VPlanTransforms::materializeBuildVectors(VPlan &Plan) {
37153715
if ((isa<VPReplicateRecipe>(DefR) &&
37163716
cast<VPReplicateRecipe>(DefR)->isSingleScalar()) ||
37173717
(isa<VPInstruction>(DefR) &&
3718-
!cast<VPInstruction>(DefR)->doesGeneratePerAllLanes()) ||
3719-
vputils::onlyFirstLaneUsed(DefR) ||
3718+
(vputils::onlyFirstLaneUsed(DefR) ||
3719+
!cast<VPInstruction>(DefR)->doesGeneratePerAllLanes())) ||
37203720
none_of(DefR->users(), UsesVectorOrInsideReplicateRegion))
37213721
continue;
37223722

llvm/lib/Transforms/Vectorize/VPlanTransforms.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ struct VPlanTransforms {
160160

161161
/// Replace each replicating VPReplicateRecipe and VPInstruction outside of
162162
/// any replicate region in \p Plan with \p VF single-scalar recipes.
163-
/// TODO: Also replicate VPReplicateRecipes inside replicate regions, thereby
164-
/// dissolving the latter.
163+
/// TODO: Also replicate VPScalarIVSteps and VPReplicateRecipes inside
164+
/// replicate regions, thereby dissolving the latter.
165165
static void replicateByVF(VPlan &Plan, ElementCount VF);
166166

167167
/// Optimize \p Plan based on \p BestVF and \p BestUF. This may restrict the

llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,8 @@ void VPlanTransforms::unrollByUF(VPlan &Plan, unsigned UF) {
463463
VPlanTransforms::removeDeadRecipes(Plan);
464464
}
465465

466-
/// Create a single-scalar clone of \p DefR (must either be a VPReplicateRecipe
467-
/// or VPInstruction) for lane \p Lane. Use \p Def2LaneDefs to look up scalar
466+
/// Create a single-scalar clone of \p DefR (must be a VPReplicateRecipe or
467+
/// VPInstruction) for lane \p Lane. Use \p Def2LaneDefs to look up scalar
468468
/// definitions for operands of \DefR.
469469
static VPRecipeWithIRFlags *
470470
cloneForLane(VPlan &Plan, VPBuilder &Builder, Type *IdxTy,
@@ -512,7 +512,7 @@ cloneForLane(VPlan &Plan, VPBuilder &Builder, Type *IdxTy,
512512
/*IsSingleScalar=*/true, /*Mask=*/nullptr, *RepR);
513513
} else {
514514
assert(isa<VPInstruction>(DefR) &&
515-
"DefR must either be a VPReplicateRecipe or VPInstruction");
515+
"DefR must be a VPReplicateRecipe or VPInstruction");
516516
New = DefR->clone();
517517
for (const auto &[Idx, Op] : enumerate(NewOps)) {
518518
New->setOperand(Idx, Op);
@@ -551,7 +551,7 @@ void VPlanTransforms::replicateByVF(VPlan &Plan, ElementCount VF) {
551551
!cast<VPInstruction>(&R)->doesGeneratePerAllLanes()))
552552
continue;
553553

554-
auto *DefR = dyn_cast<VPRecipeWithIRFlags>(&R);
554+
auto *DefR = cast<VPRecipeWithIRFlags>(&R);
555555
VPBuilder Builder(DefR);
556556
if (DefR->getNumUsers() == 0) {
557557
// Create single-scalar version of DefR for all lanes.

0 commit comments

Comments
 (0)