Skip to content

Commit 9f87cd6

Browse files
committed
[VPlan] Add m_ExtractLastElement matcher. (NFC)
1 parent fac1984 commit 9f87cd6

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8599,8 +8599,7 @@ static void addExitUsersForFirstOrderRecurrences(VPlan &Plan, VFRange &Range) {
85998599
// the VPIRInstruction modeling the phi.
86008600
for (VPUser *U : FOR->users()) {
86018601
using namespace llvm::VPlanPatternMatch;
8602-
if (!match(U, m_VPInstruction<VPInstruction::ExtractLastElement>(
8603-
m_Specific(FOR))))
8602+
if (!match(U, m_ExtractLastElement(m_Specific(FOR))))
86048603
continue;
86058604
// For VF vscale x 1, if vscale = 1, we are unable to extract the
86068605
// penultimate value of the recurrence. Instead we rely on the existing
@@ -9242,8 +9241,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
92429241
if (FinalReductionResult == U || Parent->getParent())
92439242
continue;
92449243
U->replaceUsesOfWith(OrigExitingVPV, FinalReductionResult);
9245-
if (match(U, m_VPInstruction<VPInstruction::ExtractLastElement>(
9246-
m_VPValue())))
9244+
if (match(U, m_ExtractLastElement(m_VPValue())))
92479245
cast<VPInstruction>(U)->replaceAllUsesWith(FinalReductionResult);
92489246
}
92499247

llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ m_Broadcast(const Op0_t &Op0) {
301301
return m_VPInstruction<VPInstruction::Broadcast>(Op0);
302302
}
303303

304+
template <typename Op0_t>
305+
inline VPInstruction_match<VPInstruction::ExtractLastElement, Op0_t>
306+
m_ExtractLastElement(const Op0_t &Op0) {
307+
return m_VPInstruction<VPInstruction::ExtractLastElement>(Op0);
308+
}
304309
template <typename Op0_t, typename Op1_t>
305310
inline VPInstruction_match<VPInstruction::ActiveLaneMask, Op0_t, Op1_t>
306311
m_ActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1) {

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,7 @@ optimizeLatchExitInductionUser(VPlan &Plan, VPTypeAnalysis &TypeInfo,
832832
VPBlockBase *PredVPBB, VPValue *Op,
833833
DenseMap<VPValue *, VPValue *> &EndValues) {
834834
VPValue *Incoming;
835-
if (!match(Op, m_VPInstruction<VPInstruction::ExtractLastElement>(
836-
m_VPValue(Incoming))))
835+
if (!match(Op, m_ExtractLastElement(m_VPValue(Incoming))))
837836
return nullptr;
838837

839838
auto *WideIV = getOptimizableIVOf(Incoming);
@@ -1173,8 +1172,7 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
11731172
}
11741173

11751174
// Look through ExtractLastElement (BuildVector ....).
1176-
if (match(&R, m_VPInstruction<VPInstruction::ExtractLastElement>(
1177-
m_BuildVector()))) {
1175+
if (match(&R, m_ExtractLastElement(m_BuildVector()))) {
11781176
auto *BuildVector = cast<VPInstruction>(R.getOperand(0));
11791177
Def->replaceAllUsesWith(
11801178
BuildVector->getOperand(BuildVector->getNumOperands() - 1));
@@ -1228,15 +1226,13 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
12281226
return;
12291227
}
12301228

1231-
if (match(Def, m_VPInstruction<VPInstruction::ExtractLastElement>(
1232-
m_Broadcast(m_VPValue(A))))) {
1229+
if (match(Def, m_ExtractLastElement(m_Broadcast(m_VPValue(A))))) {
12331230
Def->replaceAllUsesWith(A);
12341231
return;
12351232
}
12361233

12371234
VPInstruction *OpVPI;
1238-
if (match(Def, m_VPInstruction<VPInstruction::ExtractLastElement>(
1239-
m_VPInstruction(OpVPI))) &&
1235+
if (match(Def, m_ExtractLastElement(m_VPInstruction(OpVPI))) &&
12401236
OpVPI->isVectorToScalar()) {
12411237
Def->replaceAllUsesWith(OpVPI);
12421238
return;

llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,7 @@ void UnrollState::unrollBlock(VPBlockBase *VPB) {
373373
R.addOperand(getValueForPart(Op1, Part));
374374
continue;
375375
}
376-
if (match(&R, m_VPInstruction<VPInstruction::ExtractLastElement>(
377-
m_VPValue(Op0))) ||
376+
if (match(&R, m_ExtractLastElement(m_VPValue(Op0))) ||
378377
match(&R, m_VPInstruction<VPInstruction::ExtractPenultimateElement>(
379378
m_VPValue(Op0)))) {
380379
addUniformForAllParts(cast<VPSingleDefRecipe>(&R));

0 commit comments

Comments
 (0)