|
32 | 32 | #include "llvm/Analysis/VectorUtils.h" |
33 | 33 | #include "llvm/IR/Intrinsics.h" |
34 | 34 | #include "llvm/IR/MDBuilder.h" |
35 | | -#include "llvm/IR/PatternMatch.h" |
36 | 35 | #include "llvm/Support/Casting.h" |
37 | 36 | #include "llvm/Support/TypeSize.h" |
38 | 37 |
|
39 | 38 | using namespace llvm; |
| 39 | +using namespace VPlanPatternMatch; |
40 | 40 |
|
41 | 41 | bool VPlanTransforms::tryToConvertVPInstructionsToVPRecipes( |
42 | 42 | VPlanPtr &Plan, |
@@ -528,13 +528,11 @@ static void removeRedundantCanonicalIVs(VPlan &Plan) { |
528 | 528 |
|
529 | 529 | /// Returns true if \p R is dead and can be removed. |
530 | 530 | static bool isDeadRecipe(VPRecipeBase &R) { |
531 | | - using namespace llvm::PatternMatch; |
532 | 531 | // Do remove conditional assume instructions as their conditions may be |
533 | 532 | // flattened. |
534 | 533 | 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>()); |
538 | 536 | if (IsConditionalAssume) |
539 | 537 | return true; |
540 | 538 |
|
@@ -625,7 +623,6 @@ static SmallVector<VPUser *> collectUsersRecursively(VPValue *V) { |
625 | 623 | /// original IV's users. This is an optional optimization to reduce the needs of |
626 | 624 | /// vector extracts. |
627 | 625 | static void legalizeAndOptimizeInductions(VPlan &Plan) { |
628 | | - using namespace llvm::VPlanPatternMatch; |
629 | 626 | VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock(); |
630 | 627 | bool HasOnlyVectorVFs = !Plan.hasScalarVFOnly(); |
631 | 628 | VPBuilder Builder(HeaderVPBB, HeaderVPBB->getFirstNonPhi()); |
@@ -727,7 +724,6 @@ static VPWidenInductionRecipe *getOptimizableIVOf(VPValue *VPV) { |
727 | 724 | return nullptr; |
728 | 725 |
|
729 | 726 | auto IsWideIVInc = [&]() { |
730 | | - using namespace VPlanPatternMatch; |
731 | 727 | auto &ID = WideIV->getInductionDescriptor(); |
732 | 728 |
|
733 | 729 | // Check if VPV increments the induction by the induction step. |
@@ -771,8 +767,6 @@ static VPValue *optimizeEarlyExitInductionUser(VPlan &Plan, |
771 | 767 | VPTypeAnalysis &TypeInfo, |
772 | 768 | VPBlockBase *PredVPBB, |
773 | 769 | VPValue *Op) { |
774 | | - using namespace VPlanPatternMatch; |
775 | | - |
776 | 770 | VPValue *Incoming, *Mask; |
777 | 771 | if (!match(Op, m_VPInstruction<VPInstruction::ExtractLane>( |
778 | 772 | m_VPInstruction<VPInstruction::FirstActiveLane>( |
@@ -827,8 +821,6 @@ static VPValue * |
827 | 821 | optimizeLatchExitInductionUser(VPlan &Plan, VPTypeAnalysis &TypeInfo, |
828 | 822 | VPBlockBase *PredVPBB, VPValue *Op, |
829 | 823 | DenseMap<VPValue *, VPValue *> &EndValues) { |
830 | | - using namespace VPlanPatternMatch; |
831 | | - |
832 | 824 | VPValue *Incoming; |
833 | 825 | if (!match(Op, m_VPInstruction<VPInstruction::ExtractLastElement>( |
834 | 826 | m_VPValue(Incoming)))) |
@@ -986,7 +978,6 @@ static Value *tryToFoldLiveIns(const VPRecipeBase &R, unsigned Opcode, |
986 | 978 |
|
987 | 979 | /// Try to simplify recipe \p R. |
988 | 980 | static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) { |
989 | | - using namespace llvm::VPlanPatternMatch; |
990 | 981 | VPlan *Plan = R.getParent()->getPlan(); |
991 | 982 |
|
992 | 983 | auto *Def = dyn_cast<VPSingleDefRecipe>(&R); |
@@ -1269,7 +1260,6 @@ static void narrowToSingleScalarRecipes(VPlan &Plan) { |
1269 | 1260 | /// Normalize and simplify VPBlendRecipes. Should be run after simplifyRecipes |
1270 | 1261 | /// to make sure the masks are simplified. |
1271 | 1262 | static void simplifyBlends(VPlan &Plan) { |
1272 | | - using namespace llvm::VPlanPatternMatch; |
1273 | 1263 | for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>( |
1274 | 1264 | vp_depth_first_shallow(Plan.getVectorLoopRegion()->getEntry()))) { |
1275 | 1265 | for (VPRecipeBase &R : make_early_inc_range(*VPBB)) { |
@@ -1393,7 +1383,6 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan, |
1393 | 1383 |
|
1394 | 1384 | // Currently only handle cases where the single user is a header-mask |
1395 | 1385 | // comparison with the backedge-taken-count. |
1396 | | - using namespace VPlanPatternMatch; |
1397 | 1386 | if (!match( |
1398 | 1387 | *WideIV->user_begin(), |
1399 | 1388 | m_Binary<Instruction::ICmp>( |
@@ -1424,7 +1413,6 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan, |
1424 | 1413 | static bool isConditionTrueViaVFAndUF(VPValue *Cond, VPlan &Plan, |
1425 | 1414 | ElementCount BestVF, unsigned BestUF, |
1426 | 1415 | ScalarEvolution &SE) { |
1427 | | - using namespace llvm::VPlanPatternMatch; |
1428 | 1416 | if (match(Cond, m_Binary<Instruction::Or>(m_VPValue(), m_VPValue()))) |
1429 | 1417 | return any_of(Cond->getDefiningRecipe()->operands(), [&Plan, BestVF, BestUF, |
1430 | 1418 | &SE](VPValue *C) { |
@@ -1464,7 +1452,6 @@ static bool simplifyBranchConditionForVFAndUF(VPlan &Plan, ElementCount BestVF, |
1464 | 1452 | auto *Term = &ExitingVPBB->back(); |
1465 | 1453 | VPValue *Cond; |
1466 | 1454 | ScalarEvolution &SE = *PSE.getSE(); |
1467 | | - using namespace llvm::VPlanPatternMatch; |
1468 | 1455 | if (match(Term, m_BranchOnCount(m_VPValue(), m_VPValue())) || |
1469 | 1456 | match(Term, m_BranchOnCond( |
1470 | 1457 | m_Not(m_ActiveLaneMask(m_VPValue(), m_VPValue()))))) { |
@@ -1847,7 +1834,6 @@ void VPlanTransforms::truncateToMinimalBitwidths( |
1847 | 1834 | if (auto *VPW = dyn_cast<VPRecipeWithIRFlags>(&R)) |
1848 | 1835 | VPW->dropPoisonGeneratingFlags(); |
1849 | 1836 |
|
1850 | | - using namespace llvm::VPlanPatternMatch; |
1851 | 1837 | if (OldResSizeInBits != NewResSizeInBits && |
1852 | 1838 | !match(&R, m_Binary<Instruction::ICmp>(m_VPValue(), m_VPValue()))) { |
1853 | 1839 | // Extend result to original width. |
@@ -1897,7 +1883,6 @@ void VPlanTransforms::truncateToMinimalBitwidths( |
1897 | 1883 | } |
1898 | 1884 |
|
1899 | 1885 | void VPlanTransforms::removeBranchOnConst(VPlan &Plan) { |
1900 | | - using namespace llvm::VPlanPatternMatch; |
1901 | 1886 | for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>( |
1902 | 1887 | vp_depth_first_shallow(Plan.getEntry()))) { |
1903 | 1888 | VPValue *Cond; |
@@ -2143,7 +2128,6 @@ static VPRecipeBase *optimizeMaskToEVL(VPValue *HeaderMask, |
2143 | 2128 | VPRecipeBase &CurRecipe, |
2144 | 2129 | VPTypeAnalysis &TypeInfo, |
2145 | 2130 | VPValue &AllOneMask, VPValue &EVL) { |
2146 | | - using namespace llvm::VPlanPatternMatch; |
2147 | 2131 | auto GetNewMask = [&](VPValue *OrigMask) -> VPValue * { |
2148 | 2132 | assert(OrigMask && "Unmasked recipe when folding tail"); |
2149 | 2133 | // HeaderMask will be handled using EVL. |
@@ -2223,7 +2207,6 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) { |
2223 | 2207 | for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>( |
2224 | 2208 | vp_depth_first_deep(Plan.getVectorLoopRegion()->getEntry()))) { |
2225 | 2209 | for (VPRecipeBase &R : *VPBB) { |
2226 | | - using namespace VPlanPatternMatch; |
2227 | 2210 | VPValue *V1, *V2; |
2228 | 2211 | if (!match(&R, |
2229 | 2212 | m_VPInstruction<VPInstruction::FirstOrderRecurrenceSplice>( |
@@ -2391,7 +2374,6 @@ bool VPlanTransforms::tryAddExplicitVectorLength( |
2391 | 2374 | } |
2392 | 2375 |
|
2393 | 2376 | void VPlanTransforms::canonicalizeEVLLoops(VPlan &Plan) { |
2394 | | - using namespace llvm::VPlanPatternMatch; |
2395 | 2377 | // Find EVL loop entries by locating VPEVLBasedIVPHIRecipe. |
2396 | 2378 | // There should be only one EVL PHI in the entire plan. |
2397 | 2379 | VPEVLBasedIVPHIRecipe *EVLPhi = nullptr; |
@@ -2480,7 +2462,6 @@ void VPlanTransforms::dropPoisonGeneratingRecipes( |
2480 | 2462 | // drop them directly. |
2481 | 2463 | if (auto *RecWithFlags = dyn_cast<VPRecipeWithIRFlags>(CurRec)) { |
2482 | 2464 | VPValue *A, *B; |
2483 | | - using namespace llvm::VPlanPatternMatch; |
2484 | 2465 | // Dropping disjoint from an OR may yield incorrect results, as some |
2485 | 2466 | // analysis may have converted it to an Add implicitly (e.g. SCEV used |
2486 | 2467 | // for dependence analysis). Instead, replace it with an equivalent Add. |
@@ -2774,8 +2755,6 @@ void VPlanTransforms::dissolveLoopRegions(VPlan &Plan) { |
2774 | 2755 |
|
2775 | 2756 | void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan, |
2776 | 2757 | Type &CanonicalIVTy) { |
2777 | | - using namespace llvm::VPlanPatternMatch; |
2778 | | - |
2779 | 2758 | VPTypeAnalysis TypeInfo(&CanonicalIVTy); |
2780 | 2759 | SmallVector<VPRecipeBase *> ToRemove; |
2781 | 2760 | for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>( |
@@ -2852,8 +2831,6 @@ void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan, |
2852 | 2831 | void VPlanTransforms::handleUncountableEarlyExit( |
2853 | 2832 | VPBasicBlock *EarlyExitingVPBB, VPBasicBlock *EarlyExitVPBB, VPlan &Plan, |
2854 | 2833 | VPBasicBlock *HeaderVPBB, VPBasicBlock *LatchVPBB, VFRange &Range) { |
2855 | | - using namespace llvm::VPlanPatternMatch; |
2856 | | - |
2857 | 2834 | VPBlockBase *MiddleVPBB = LatchVPBB->getSuccessors()[0]; |
2858 | 2835 | if (!EarlyExitVPBB->getSinglePredecessor() && |
2859 | 2836 | EarlyExitVPBB->getPredecessors()[1] == MiddleVPBB) { |
@@ -2947,8 +2924,6 @@ void VPlanTransforms::handleUncountableEarlyExit( |
2947 | 2924 | static VPExpressionRecipe * |
2948 | 2925 | tryToMatchAndCreateExtendedReduction(VPReductionRecipe *Red, VPCostContext &Ctx, |
2949 | 2926 | VFRange &Range) { |
2950 | | - using namespace VPlanPatternMatch; |
2951 | | - |
2952 | 2927 | Type *RedTy = Ctx.Types.inferScalarType(Red); |
2953 | 2928 | VPValue *VecOp = Red->getVecOp(); |
2954 | 2929 |
|
@@ -2994,8 +2969,6 @@ tryToMatchAndCreateExtendedReduction(VPReductionRecipe *Red, VPCostContext &Ctx, |
2994 | 2969 | static VPExpressionRecipe * |
2995 | 2970 | tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red, |
2996 | 2971 | VPCostContext &Ctx, VFRange &Range) { |
2997 | | - using namespace VPlanPatternMatch; |
2998 | | - |
2999 | 2972 | unsigned Opcode = RecurrenceDescriptor::getOpcode(Red->getRecurrenceKind()); |
3000 | 2973 | if (Opcode != Instruction::Add) |
3001 | 2974 | return nullptr; |
@@ -3256,7 +3229,6 @@ static bool isAlreadyNarrow(VPValue *VPV) { |
3256 | 3229 |
|
3257 | 3230 | void VPlanTransforms::narrowInterleaveGroups(VPlan &Plan, ElementCount VF, |
3258 | 3231 | unsigned VectorRegWidth) { |
3259 | | - using namespace llvm::VPlanPatternMatch; |
3260 | 3232 | VPRegionBlock *VectorLoop = Plan.getVectorLoopRegion(); |
3261 | 3233 | if (VF.isScalable() || !VectorLoop) |
3262 | 3234 | return; |
|
0 commit comments