Skip to content

Commit b49efbc

Browse files
committed
!fixup updates after merging
1 parent a2a1372 commit b49efbc

File tree

8 files changed

+35
-18
lines changed

8 files changed

+35
-18
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7170,7 +7170,8 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
71707170
// TODO: Move to VPlan transform stage once the transition to the VPlan-based
71717171
// cost model is complete for better cost estimates.
71727172
VPlanTransforms::runPass(VPlanTransforms::unrollByUF, BestVPlan, BestUF);
7173-
VPlanTransforms::runPass(VPlanTransforms::materializeBuildVectors, BestVPlan);
7173+
VPlanTransforms::runPass(VPlanTransforms::materializeBuildAndUnpackVectors,
7174+
BestVPlan);
71747175
VPlanTransforms::runPass(VPlanTransforms::materializeBroadcasts, BestVPlan);
71757176
VPlanTransforms::runPass(VPlanTransforms::replicateByVF, BestVPlan, BestVF);
71767177
bool HasBranchWeights =

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,8 @@ class LLVM_ABI_FOR_TEST VPInstruction : public VPRecipeWithIRFlags,
10601060
ResumeForEpilogue,
10611061
/// Returns the value for vscale.
10621062
VScale,
1063-
Unpack,
1063+
/// Extracts all lanes from its (non-scalable) vector operand.
1064+
UnpackVector,
10641065
};
10651066

10661067
/// Returns true if this VPInstruction generates scalar values for all lanes.
@@ -2704,6 +2705,15 @@ class LLVM_ABI_FOR_TEST VPReductionRecipe : public VPRecipeWithIRFlags {
27042705
return R && classof(R);
27052706
}
27062707

2708+
static inline bool classof(const VPValue *VPV) {
2709+
const VPRecipeBase *R = VPV->getDefiningRecipe();
2710+
return R && classof(R);
2711+
}
2712+
2713+
static inline bool classof(const VPSingleDefRecipe *R) {
2714+
return classof(static_cast<const VPRecipeBase *>(R));
2715+
}
2716+
27072717
/// Generate the reduction in the loop.
27082718
void execute(VPTransformState &State) override;
27092719

llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPInstruction *R) {
109109
case VPInstruction::AnyOf:
110110
case VPInstruction::BuildStructVector:
111111
case VPInstruction::BuildVector:
112-
case VPInstruction::Unpack:
112+
case VPInstruction::UnpackVector:
113113
return SetResultTyFromOp();
114114
case VPInstruction::ExtractLane:
115115
return inferScalarType(R->getOperand(1));

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ unsigned VPInstruction::getNumOperandsForOpcode(unsigned Opcode) {
506506
case VPInstruction::ExtractPenultimateElement:
507507
case VPInstruction::FirstActiveLane:
508508
case VPInstruction::Not:
509-
case VPInstruction::Unpack:
509+
case VPInstruction::UnpackVector:
510510
return 1;
511511
case Instruction::ICmp:
512512
case Instruction::FCmp:
@@ -1232,7 +1232,7 @@ bool VPInstruction::opcodeMayReadOrWriteFromMemory() const {
12321232
case VPInstruction::StepVector:
12331233
case VPInstruction::ReductionStartVector:
12341234
case VPInstruction::VScale:
1235-
case VPInstruction::Unpack:
1235+
case VPInstruction::UnpackVector:
12361236
return false;
12371237
default:
12381238
return true;
@@ -1399,7 +1399,7 @@ void VPInstruction::print(raw_ostream &O, const Twine &Indent,
13991399
case VPInstruction::ResumeForEpilogue:
14001400
O << "resume-for-epilogue";
14011401
break;
1402-
case VPInstruction::Unpack:
1402+
case VPInstruction::UnpackVector:
14031403
O << "unpack-into-scalars";
14041404
break;
14051405
default:

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
12301230
m_VPValue(Idx)))) {
12311231
auto *BuildVector = cast<VPInstruction>(R.getOperand(0));
12321232
Def->replaceAllUsesWith(BuildVector->getOperand(
1233-
dyn_cast<ConstantInt>(Idx->getLiveInIRValue())->getZExtValue()));
1233+
cast<ConstantInt>(Idx->getLiveInIRValue())->getZExtValue()));
12341234
return;
12351235
}
12361236

@@ -3694,7 +3694,7 @@ void VPlanTransforms::materializeBackedgeTakenCount(VPlan &Plan,
36943694
BTC->replaceAllUsesWith(TCMO);
36953695
}
36963696

3697-
void VPlanTransforms::materializeBuildVectors(VPlan &Plan) {
3697+
void VPlanTransforms::materializeBuildAndUnpackVectors(VPlan &Plan) {
36983698
if (Plan.hasScalarVFOnly())
36993699
return;
37003700

@@ -3770,13 +3770,14 @@ void VPlanTransforms::materializeBuildVectors(VPlan &Plan) {
37703770
}))
37713771
continue;
37723772

3773-
auto *Unpack = new VPInstruction(VPInstruction::Unpack, {Def});
3773+
auto *UnpackVector =
3774+
new VPInstruction(VPInstruction::UnpackVector, {Def});
37743775
if (R.isPhi())
3775-
Unpack->insertBefore(*VPBB, VPBB->getFirstNonPhi());
3776+
UnpackVector->insertBefore(*VPBB, VPBB->getFirstNonPhi());
37763777
else
3777-
Unpack->insertAfter(&R);
3778+
UnpackVector->insertAfter(&R);
37783779
Def->replaceUsesWithIf(
3779-
Unpack,
3780+
UnpackVector,
37803781
[Def, &UsesVectorOrInsideReplicateRegion](VPUser &U, unsigned) {
37813782
return !UsesVectorOrInsideReplicateRegion(&U) &&
37823783
U.usesScalars(Def);

llvm/lib/Transforms/Vectorize/VPlanTransforms.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,9 @@ struct VPlanTransforms {
319319
VPBasicBlock *VectorPH);
320320

321321
/// Add explicit Build[Struct]Vector recipes that combine multiple scalar
322-
/// values into single vectors.
323-
static void materializeBuildVectors(VPlan &Plan);
322+
/// values into single vectors and UnpackVector to extract scalars from a
323+
/// vector as needed.
324+
static void materializeBuildAndUnpackVectors(VPlan &Plan);
324325

325326
/// Materialize VF and VFxUF to be computed explicitly using VPInstructions.
326327
static void materializeVFAndVFxUF(VPlan &Plan, VPBasicBlock *VectorPH,

llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ cloneForLane(VPlan &Plan, VPBuilder &Builder, Type *IdxTy,
472472
const DenseMap<VPValue *, SmallVector<VPValue *>> &Def2LaneDefs) {
473473

474474
VPValue *Op;
475-
if (match(DefR, m_VPInstruction<VPInstruction::Unpack>(m_VPValue(Op)))) {
475+
if (match(DefR,
476+
m_VPInstruction<VPInstruction::UnpackVector>(m_VPValue(Op)))) {
476477
auto LaneDefs = Def2LaneDefs.find(Op);
477478
if (LaneDefs != Def2LaneDefs.end())
478479
return LaneDefs->second[Lane.getKnownLane()];
@@ -486,7 +487,7 @@ cloneForLane(VPlan &Plan, VPBuilder &Builder, Type *IdxTy,
486487
SmallVector<VPValue *> NewOps;
487488
for (VPValue *Op : DefR->operands()) {
488489
if (Lane.getKind() == VPLane::Kind::ScalableLast) {
489-
match(Op, m_VPInstruction<VPInstruction::Unpack>(m_VPValue(Op)));
490+
match(Op, m_VPInstruction<VPInstruction::UnpackVector>(m_VPValue(Op)));
490491
NewOps.push_back(
491492
Builder.createNaryOp(VPInstruction::ExtractLastElement, {Op}));
492493
continue;
@@ -562,7 +563,8 @@ void VPlanTransforms::replicateByVF(VPlan &Plan, ElementCount VF) {
562563
(isa<VPReplicateRecipe>(&R) &&
563564
cast<VPReplicateRecipe>(&R)->isSingleScalar()) ||
564565
(isa<VPInstruction>(&R) &&
565-
!cast<VPInstruction>(&R)->doesGeneratePerAllLanes() && cast<VPInstruction>(&R)->getOpcode() != VPInstruction::Unpack))
566+
!cast<VPInstruction>(&R)->doesGeneratePerAllLanes() &&
567+
cast<VPInstruction>(&R)->getOpcode() != VPInstruction::UnpackVector))
566568
continue;
567569

568570
auto *DefR = cast<VPRecipeWithIRFlags>(&R);

llvm/lib/Transforms/Vectorize/VPlanUtils.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ inline bool isSingleScalar(const VPValue *VPV) {
8484
return VPI->isSingleScalar() || VPI->isVectorToScalar() ||
8585
(PreservesUniformity(VPI->getOpcode()) &&
8686
all_of(VPI->operands(), isSingleScalar));
87+
if (auto *Reduce = dyn_cast<VPReductionRecipe>(VPV))
88+
return true;
8789

8890
// VPExpandSCEVRecipes must be placed in the entry and are alway uniform.
89-
return isa<VPExpandSCEVRecipe, VPPhi>(VPV);
91+
return isa<VPExpandSCEVRecipe>(VPV);
9092
}
9193

9294
/// Return true if \p V is a header mask in \p Plan.

0 commit comments

Comments
 (0)