Skip to content

Commit b7d00b8

Browse files
authored
[VPlan] Uniformly use VPlanPatternMatch in transforms (NFC) (#151488)
1 parent 462c208 commit b7d00b8

File tree

1 file changed

+3
-31
lines changed

1 file changed

+3
-31
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
#include "llvm/Analysis/VectorUtils.h"
3333
#include "llvm/IR/Intrinsics.h"
3434
#include "llvm/IR/MDBuilder.h"
35-
#include "llvm/IR/PatternMatch.h"
3635
#include "llvm/Support/Casting.h"
3736
#include "llvm/Support/TypeSize.h"
3837

3938
using namespace llvm;
39+
using namespace VPlanPatternMatch;
4040

4141
bool VPlanTransforms::tryToConvertVPInstructionsToVPRecipes(
4242
VPlanPtr &Plan,
@@ -528,13 +528,11 @@ static void removeRedundantCanonicalIVs(VPlan &Plan) {
528528

529529
/// Returns true if \p R is dead and can be removed.
530530
static bool isDeadRecipe(VPRecipeBase &R) {
531-
using namespace llvm::PatternMatch;
532531
// Do remove conditional assume instructions as their conditions may be
533532
// flattened.
534533
auto *RepR = dyn_cast<VPReplicateRecipe>(&R);
535-
bool IsConditionalAssume =
536-
RepR && RepR->isPredicated() &&
537-
match(RepR->getUnderlyingInstr(), m_Intrinsic<Intrinsic::assume>());
534+
bool IsConditionalAssume = RepR && RepR->isPredicated() &&
535+
match(RepR, m_Intrinsic<Intrinsic::assume>());
538536
if (IsConditionalAssume)
539537
return true;
540538

@@ -625,7 +623,6 @@ static SmallVector<VPUser *> collectUsersRecursively(VPValue *V) {
625623
/// original IV's users. This is an optional optimization to reduce the needs of
626624
/// vector extracts.
627625
static void legalizeAndOptimizeInductions(VPlan &Plan) {
628-
using namespace llvm::VPlanPatternMatch;
629626
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
630627
bool HasOnlyVectorVFs = !Plan.hasScalarVFOnly();
631628
VPBuilder Builder(HeaderVPBB, HeaderVPBB->getFirstNonPhi());
@@ -727,7 +724,6 @@ static VPWidenInductionRecipe *getOptimizableIVOf(VPValue *VPV) {
727724
return nullptr;
728725

729726
auto IsWideIVInc = [&]() {
730-
using namespace VPlanPatternMatch;
731727
auto &ID = WideIV->getInductionDescriptor();
732728

733729
// Check if VPV increments the induction by the induction step.
@@ -771,8 +767,6 @@ static VPValue *optimizeEarlyExitInductionUser(VPlan &Plan,
771767
VPTypeAnalysis &TypeInfo,
772768
VPBlockBase *PredVPBB,
773769
VPValue *Op) {
774-
using namespace VPlanPatternMatch;
775-
776770
VPValue *Incoming, *Mask;
777771
if (!match(Op, m_VPInstruction<VPInstruction::ExtractLane>(
778772
m_VPInstruction<VPInstruction::FirstActiveLane>(
@@ -827,8 +821,6 @@ static VPValue *
827821
optimizeLatchExitInductionUser(VPlan &Plan, VPTypeAnalysis &TypeInfo,
828822
VPBlockBase *PredVPBB, VPValue *Op,
829823
DenseMap<VPValue *, VPValue *> &EndValues) {
830-
using namespace VPlanPatternMatch;
831-
832824
VPValue *Incoming;
833825
if (!match(Op, m_VPInstruction<VPInstruction::ExtractLastElement>(
834826
m_VPValue(Incoming))))
@@ -986,7 +978,6 @@ static Value *tryToFoldLiveIns(const VPRecipeBase &R, unsigned Opcode,
986978

987979
/// Try to simplify recipe \p R.
988980
static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
989-
using namespace llvm::VPlanPatternMatch;
990981
VPlan *Plan = R.getParent()->getPlan();
991982

992983
auto *Def = dyn_cast<VPSingleDefRecipe>(&R);
@@ -1269,7 +1260,6 @@ static void narrowToSingleScalarRecipes(VPlan &Plan) {
12691260
/// Normalize and simplify VPBlendRecipes. Should be run after simplifyRecipes
12701261
/// to make sure the masks are simplified.
12711262
static void simplifyBlends(VPlan &Plan) {
1272-
using namespace llvm::VPlanPatternMatch;
12731263
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
12741264
vp_depth_first_shallow(Plan.getVectorLoopRegion()->getEntry()))) {
12751265
for (VPRecipeBase &R : make_early_inc_range(*VPBB)) {
@@ -1393,7 +1383,6 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
13931383

13941384
// Currently only handle cases where the single user is a header-mask
13951385
// comparison with the backedge-taken-count.
1396-
using namespace VPlanPatternMatch;
13971386
if (!match(
13981387
*WideIV->user_begin(),
13991388
m_Binary<Instruction::ICmp>(
@@ -1424,7 +1413,6 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
14241413
static bool isConditionTrueViaVFAndUF(VPValue *Cond, VPlan &Plan,
14251414
ElementCount BestVF, unsigned BestUF,
14261415
ScalarEvolution &SE) {
1427-
using namespace llvm::VPlanPatternMatch;
14281416
if (match(Cond, m_Binary<Instruction::Or>(m_VPValue(), m_VPValue())))
14291417
return any_of(Cond->getDefiningRecipe()->operands(), [&Plan, BestVF, BestUF,
14301418
&SE](VPValue *C) {
@@ -1464,7 +1452,6 @@ static bool simplifyBranchConditionForVFAndUF(VPlan &Plan, ElementCount BestVF,
14641452
auto *Term = &ExitingVPBB->back();
14651453
VPValue *Cond;
14661454
ScalarEvolution &SE = *PSE.getSE();
1467-
using namespace llvm::VPlanPatternMatch;
14681455
if (match(Term, m_BranchOnCount(m_VPValue(), m_VPValue())) ||
14691456
match(Term, m_BranchOnCond(
14701457
m_Not(m_ActiveLaneMask(m_VPValue(), m_VPValue()))))) {
@@ -1847,7 +1834,6 @@ void VPlanTransforms::truncateToMinimalBitwidths(
18471834
if (auto *VPW = dyn_cast<VPRecipeWithIRFlags>(&R))
18481835
VPW->dropPoisonGeneratingFlags();
18491836

1850-
using namespace llvm::VPlanPatternMatch;
18511837
if (OldResSizeInBits != NewResSizeInBits &&
18521838
!match(&R, m_Binary<Instruction::ICmp>(m_VPValue(), m_VPValue()))) {
18531839
// Extend result to original width.
@@ -1897,7 +1883,6 @@ void VPlanTransforms::truncateToMinimalBitwidths(
18971883
}
18981884

18991885
void VPlanTransforms::removeBranchOnConst(VPlan &Plan) {
1900-
using namespace llvm::VPlanPatternMatch;
19011886
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
19021887
vp_depth_first_shallow(Plan.getEntry()))) {
19031888
VPValue *Cond;
@@ -2143,7 +2128,6 @@ static VPRecipeBase *optimizeMaskToEVL(VPValue *HeaderMask,
21432128
VPRecipeBase &CurRecipe,
21442129
VPTypeAnalysis &TypeInfo,
21452130
VPValue &AllOneMask, VPValue &EVL) {
2146-
using namespace llvm::VPlanPatternMatch;
21472131
auto GetNewMask = [&](VPValue *OrigMask) -> VPValue * {
21482132
assert(OrigMask && "Unmasked recipe when folding tail");
21492133
// HeaderMask will be handled using EVL.
@@ -2223,7 +2207,6 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
22232207
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
22242208
vp_depth_first_deep(Plan.getVectorLoopRegion()->getEntry()))) {
22252209
for (VPRecipeBase &R : *VPBB) {
2226-
using namespace VPlanPatternMatch;
22272210
VPValue *V1, *V2;
22282211
if (!match(&R,
22292212
m_VPInstruction<VPInstruction::FirstOrderRecurrenceSplice>(
@@ -2391,7 +2374,6 @@ bool VPlanTransforms::tryAddExplicitVectorLength(
23912374
}
23922375

23932376
void VPlanTransforms::canonicalizeEVLLoops(VPlan &Plan) {
2394-
using namespace llvm::VPlanPatternMatch;
23952377
// Find EVL loop entries by locating VPEVLBasedIVPHIRecipe.
23962378
// There should be only one EVL PHI in the entire plan.
23972379
VPEVLBasedIVPHIRecipe *EVLPhi = nullptr;
@@ -2480,7 +2462,6 @@ void VPlanTransforms::dropPoisonGeneratingRecipes(
24802462
// drop them directly.
24812463
if (auto *RecWithFlags = dyn_cast<VPRecipeWithIRFlags>(CurRec)) {
24822464
VPValue *A, *B;
2483-
using namespace llvm::VPlanPatternMatch;
24842465
// Dropping disjoint from an OR may yield incorrect results, as some
24852466
// analysis may have converted it to an Add implicitly (e.g. SCEV used
24862467
// for dependence analysis). Instead, replace it with an equivalent Add.
@@ -2774,8 +2755,6 @@ void VPlanTransforms::dissolveLoopRegions(VPlan &Plan) {
27742755

27752756
void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan,
27762757
Type &CanonicalIVTy) {
2777-
using namespace llvm::VPlanPatternMatch;
2778-
27792758
VPTypeAnalysis TypeInfo(&CanonicalIVTy);
27802759
SmallVector<VPRecipeBase *> ToRemove;
27812760
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
@@ -2852,8 +2831,6 @@ void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan,
28522831
void VPlanTransforms::handleUncountableEarlyExit(
28532832
VPBasicBlock *EarlyExitingVPBB, VPBasicBlock *EarlyExitVPBB, VPlan &Plan,
28542833
VPBasicBlock *HeaderVPBB, VPBasicBlock *LatchVPBB, VFRange &Range) {
2855-
using namespace llvm::VPlanPatternMatch;
2856-
28572834
VPBlockBase *MiddleVPBB = LatchVPBB->getSuccessors()[0];
28582835
if (!EarlyExitVPBB->getSinglePredecessor() &&
28592836
EarlyExitVPBB->getPredecessors()[1] == MiddleVPBB) {
@@ -2947,8 +2924,6 @@ void VPlanTransforms::handleUncountableEarlyExit(
29472924
static VPExpressionRecipe *
29482925
tryToMatchAndCreateExtendedReduction(VPReductionRecipe *Red, VPCostContext &Ctx,
29492926
VFRange &Range) {
2950-
using namespace VPlanPatternMatch;
2951-
29522927
Type *RedTy = Ctx.Types.inferScalarType(Red);
29532928
VPValue *VecOp = Red->getVecOp();
29542929

@@ -2994,8 +2969,6 @@ tryToMatchAndCreateExtendedReduction(VPReductionRecipe *Red, VPCostContext &Ctx,
29942969
static VPExpressionRecipe *
29952970
tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
29962971
VPCostContext &Ctx, VFRange &Range) {
2997-
using namespace VPlanPatternMatch;
2998-
29992972
unsigned Opcode = RecurrenceDescriptor::getOpcode(Red->getRecurrenceKind());
30002973
if (Opcode != Instruction::Add)
30012974
return nullptr;
@@ -3256,7 +3229,6 @@ static bool isAlreadyNarrow(VPValue *VPV) {
32563229

32573230
void VPlanTransforms::narrowInterleaveGroups(VPlan &Plan, ElementCount VF,
32583231
unsigned VectorRegWidth) {
3259-
using namespace llvm::VPlanPatternMatch;
32603232
VPRegionBlock *VectorLoop = Plan.getVectorLoopRegion();
32613233
if (VF.isScalable() || !VectorLoop)
32623234
return;

0 commit comments

Comments
 (0)