Skip to content

Commit 17b9759

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:430729d71e4e582aa04b5d30796de14404fed56a into amd-gfx:cccd99d0cdce
Local branch amd-gfx cccd99d Merged main:e3ed9e30b7b7102daf37f9464efc06b3d2e1a160 into amd-gfx:15202b412774 Remote branch main 430729d [NFC][LLVM] Clean up TLI VECFUNC macros. (llvm#93178)
2 parents cccd99d + 430729d commit 17b9759

File tree

14 files changed

+419
-105
lines changed

14 files changed

+419
-105
lines changed

llvm/include/llvm/Analysis/VecFuncs.def

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
// This .def file also allows creating an array of vector functions supported in
1313
// the specified framework or library.
1414

15-
#if defined(TLI_DEFINE_MASSV_VECFUNCS_NAMES)
16-
#define TLI_DEFINE_MASSV_VECFUNCS
17-
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) VEC,
18-
#endif
19-
2015
#define FIXED(NL) ElementCount::getFixed(NL)
2116
#define SCALABLE(NL) ElementCount::getScalable(NL)
2217
#define NOMASK false
@@ -1276,14 +1271,3 @@ TLI_DEFINE_VECFUNC("cbrtf", "amd_vrs4_cbrtf", FIXED(4), NOMASK, "_ZGV_LLVM_N4v")
12761271
#undef FIXED
12771272

12781273
#undef TLI_DEFINE_VECFUNC
1279-
#undef TLI_DEFINE_ACCELERATE_VECFUNCS
1280-
#undef TLI_DEFINE_DARWIN_LIBSYSTEM_M_VECFUNCS
1281-
#undef TLI_DEFINE_LIBMVEC_X86_VECFUNCS
1282-
#undef TLI_DEFINE_MASSV_VECFUNCS
1283-
#undef TLI_DEFINE_SVML_VECFUNCS
1284-
#undef TLI_DEFINE_SLEEFGNUABI_VF2_VECFUNCS
1285-
#undef TLI_DEFINE_SLEEFGNUABI_VF4_VECFUNCS
1286-
#undef TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS
1287-
#undef TLI_DEFINE_MASSV_VECFUNCS_NAMES
1288-
#undef TLI_DEFINE_ARMPL_VECFUNCS
1289-
#undef TLI_DEFINE_AMDLIBM_VECFUNCS

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 499697
19+
#define LLVM_MAIN_REVISION 499704
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/Analysis/TargetLibraryInfo.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,59 +1204,69 @@ void TargetLibraryInfoImpl::addVectorizableFunctions(ArrayRef<VecDesc> Fns) {
12041204
static const VecDesc VecFuncs_Accelerate[] = {
12051205
#define TLI_DEFINE_ACCELERATE_VECFUNCS
12061206
#include "llvm/Analysis/VecFuncs.def"
1207+
#undef TLI_DEFINE_ACCELERATE_VECFUNCS
12071208
};
12081209

12091210
static const VecDesc VecFuncs_DarwinLibSystemM[] = {
12101211
#define TLI_DEFINE_DARWIN_LIBSYSTEM_M_VECFUNCS
12111212
#include "llvm/Analysis/VecFuncs.def"
1213+
#undef TLI_DEFINE_DARWIN_LIBSYSTEM_M_VECFUNCS
12121214
};
12131215

12141216
static const VecDesc VecFuncs_LIBMVEC_X86[] = {
12151217
#define TLI_DEFINE_LIBMVEC_X86_VECFUNCS
12161218
#include "llvm/Analysis/VecFuncs.def"
1219+
#undef TLI_DEFINE_LIBMVEC_X86_VECFUNCS
12171220
};
12181221

12191222
static const VecDesc VecFuncs_MASSV[] = {
12201223
#define TLI_DEFINE_MASSV_VECFUNCS
12211224
#include "llvm/Analysis/VecFuncs.def"
1225+
#undef TLI_DEFINE_MASSV_VECFUNCS
12221226
};
12231227

12241228
static const VecDesc VecFuncs_SVML[] = {
12251229
#define TLI_DEFINE_SVML_VECFUNCS
12261230
#include "llvm/Analysis/VecFuncs.def"
1231+
#undef TLI_DEFINE_SVML_VECFUNCS
12271232
};
12281233

12291234
static const VecDesc VecFuncs_SLEEFGNUABI_VF2[] = {
12301235
#define TLI_DEFINE_SLEEFGNUABI_VF2_VECFUNCS
12311236
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) \
12321237
{SCAL, VEC, VF, /* MASK = */ false, VABI_PREFIX},
12331238
#include "llvm/Analysis/VecFuncs.def"
1239+
#undef TLI_DEFINE_SLEEFGNUABI_VF2_VECFUNCS
12341240
};
12351241
static const VecDesc VecFuncs_SLEEFGNUABI_VF4[] = {
12361242
#define TLI_DEFINE_SLEEFGNUABI_VF4_VECFUNCS
12371243
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) \
12381244
{SCAL, VEC, VF, /* MASK = */ false, VABI_PREFIX},
12391245
#include "llvm/Analysis/VecFuncs.def"
1246+
#undef TLI_DEFINE_SLEEFGNUABI_VF4_VECFUNCS
12401247
};
12411248
static const VecDesc VecFuncs_SLEEFGNUABI_VFScalable[] = {
12421249
#define TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS
12431250
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \
12441251
{SCAL, VEC, VF, MASK, VABI_PREFIX},
12451252
#include "llvm/Analysis/VecFuncs.def"
1253+
#undef TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS
12461254
};
12471255

12481256
static const VecDesc VecFuncs_ArmPL[] = {
12491257
#define TLI_DEFINE_ARMPL_VECFUNCS
12501258
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \
12511259
{SCAL, VEC, VF, MASK, VABI_PREFIX},
12521260
#include "llvm/Analysis/VecFuncs.def"
1261+
#undef TLI_DEFINE_ARMPL_VECFUNCS
12531262
};
12541263

12551264
const VecDesc VecFuncs_AMDLIBM[] = {
12561265
#define TLI_DEFINE_AMDLIBM_VECFUNCS
12571266
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \
12581267
{SCAL, VEC, VF, MASK, VABI_PREFIX},
12591268
#include "llvm/Analysis/VecFuncs.def"
1269+
#undef TLI_DEFINE_AMDLIBM_VECFUNCS
12601270
};
12611271

12621272
void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(

llvm/lib/Target/PowerPC/PPCLowerMASSVEntries.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ using namespace llvm;
2929
namespace {
3030

3131
static StringRef MASSVFuncs[] = {
32-
#define TLI_DEFINE_MASSV_VECFUNCS_NAMES
32+
#define TLI_DEFINE_MASSV_VECFUNCS
33+
#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) VEC,
3334
#include "llvm/Analysis/VecFuncs.def"
35+
#undef TLI_DEFINE_MASSV_VECFUNCS
3436
};
3537

3638
class PPCLowerMASSVEntries : public ModulePass {

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7533,8 +7533,9 @@ LoopVectorizationPlanner::executePlan(
75337533
LLVM_DEBUG(BestVPlan.dump());
75347534

75357535
// Perform the actual loop transformation.
7536-
VPTransformState State(BestVF, BestUF, LI, DT, ILV.Builder, &ILV, &BestVPlan,
7537-
OrigLoop->getHeader()->getContext());
7536+
VPTransformState State(BestVF, BestUF, LI,
7537+
EnableVPlanNativePath ? nullptr : DT, ILV.Builder,
7538+
&ILV, &BestVPlan, OrigLoop->getHeader()->getContext());
75387539

75397540
// 0. Generate SCEV-dependent code into the preheader, including TripCount,
75407541
// before making any changes to the CFG.
@@ -10402,6 +10403,7 @@ PreservedAnalyses LoopVectorizePass::run(Function &F,
1040210403
PA.preserve<DominatorTreeAnalysis>();
1040310404
PA.preserve<ScalarEvolutionAnalysis>();
1040410405
}
10406+
1040510407
PA.preserve<LoopAnalysis>();
1040610408

1040710409
if (Result.MadeCFGChange) {

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 13 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "llvm/ADT/SmallVector.h"
2626
#include "llvm/ADT/StringExtras.h"
2727
#include "llvm/ADT/Twine.h"
28+
#include "llvm/Analysis/DomTreeUpdater.h"
2829
#include "llvm/Analysis/LoopInfo.h"
2930
#include "llvm/IR/BasicBlock.h"
3031
#include "llvm/IR/CFG.h"
@@ -218,7 +219,7 @@ VPTransformState::VPTransformState(ElementCount VF, unsigned UF, LoopInfo *LI,
218219
DominatorTree *DT, IRBuilderBase &Builder,
219220
InnerLoopVectorizer *ILV, VPlan *Plan,
220221
LLVMContext &Ctx)
221-
: VF(VF), UF(UF), LI(LI), DT(DT), Builder(Builder), ILV(ILV), Plan(Plan),
222+
: VF(VF), UF(UF), CFG(DT), LI(LI), Builder(Builder), ILV(ILV), Plan(Plan),
222223
LVer(nullptr),
223224
TypeAnalysis(Plan->getCanonicalIV()->getScalarType(), Ctx) {}
224225

@@ -436,6 +437,7 @@ VPBasicBlock::createEmptyBasicBlock(VPTransformState::CFGState &CFG) {
436437
"Trying to reset an existing successor block.");
437438
TermBr->setSuccessor(idx, NewBB);
438439
}
440+
CFG.DTU.applyUpdates({{DominatorTree::Insert, PredBB, NewBB}});
439441
}
440442
return NewBB;
441443
}
@@ -467,6 +469,7 @@ void VPBasicBlock::execute(VPTransformState *State) {
467469
// The Exit block of a loop is always set to be successor 0 of the Exiting
468470
// block.
469471
cast<BranchInst>(ExitingBB->getTerminator())->setSuccessor(0, NewBB);
472+
State->CFG.DTU.applyUpdates({{DominatorTree::Insert, ExitingBB, NewBB}});
470473
} else if (PrevVPBB && /* A */
471474
!((SingleHPred = getSingleHierarchicalPredecessor()) &&
472475
SingleHPred->getExitingBasicBlock() == PrevVPBB &&
@@ -829,6 +832,11 @@ void VPlan::execute(VPTransformState *State) {
829832
BasicBlock *VectorPreHeader = State->CFG.PrevBB;
830833
State->Builder.SetInsertPoint(VectorPreHeader->getTerminator());
831834

835+
// Disconnect VectorPreHeader from ExitBB in both the CFG and DT.
836+
cast<BranchInst>(VectorPreHeader->getTerminator())->setSuccessor(0, nullptr);
837+
State->CFG.DTU.applyUpdates(
838+
{{DominatorTree::Delete, VectorPreHeader, State->CFG.ExitBB}});
839+
832840
// Generate code in the loop pre-header and body.
833841
for (VPBlockBase *Block : vp_depth_first_shallow(Entry))
834842
Block->execute(State);
@@ -891,13 +899,10 @@ void VPlan::execute(VPTransformState *State) {
891899
}
892900
}
893901

894-
// We do not attempt to preserve DT for outer loop vectorization currently.
895-
if (!EnableVPlanNativePath) {
896-
BasicBlock *VectorHeaderBB = State->CFG.VPBB2IRBB[Header];
897-
State->DT->addNewBlock(VectorHeaderBB, VectorPreHeader);
898-
updateDominatorTree(State->DT, VectorHeaderBB, VectorLatchBB,
899-
State->CFG.ExitBB);
900-
}
902+
State->CFG.DTU.flush();
903+
// DT is currently updated for non-native path only.
904+
assert(EnableVPlanNativePath || State->CFG.DTU.getDomTree().verify(
905+
DominatorTree::VerificationLevel::Fast));
901906
}
902907

903908
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
@@ -995,44 +1000,6 @@ void VPlan::addLiveOut(PHINode *PN, VPValue *V) {
9951000
LiveOuts.insert({PN, new VPLiveOut(PN, V)});
9961001
}
9971002

998-
void VPlan::updateDominatorTree(DominatorTree *DT, BasicBlock *LoopHeaderBB,
999-
BasicBlock *LoopLatchBB,
1000-
BasicBlock *LoopExitBB) {
1001-
// The vector body may be more than a single basic-block by this point.
1002-
// Update the dominator tree information inside the vector body by propagating
1003-
// it from header to latch, expecting only triangular control-flow, if any.
1004-
BasicBlock *PostDomSucc = nullptr;
1005-
for (auto *BB = LoopHeaderBB; BB != LoopLatchBB; BB = PostDomSucc) {
1006-
// Get the list of successors of this block.
1007-
std::vector<BasicBlock *> Succs(succ_begin(BB), succ_end(BB));
1008-
assert(Succs.size() <= 2 &&
1009-
"Basic block in vector loop has more than 2 successors.");
1010-
PostDomSucc = Succs[0];
1011-
if (Succs.size() == 1) {
1012-
assert(PostDomSucc->getSinglePredecessor() &&
1013-
"PostDom successor has more than one predecessor.");
1014-
DT->addNewBlock(PostDomSucc, BB);
1015-
continue;
1016-
}
1017-
BasicBlock *InterimSucc = Succs[1];
1018-
if (PostDomSucc->getSingleSuccessor() == InterimSucc) {
1019-
PostDomSucc = Succs[1];
1020-
InterimSucc = Succs[0];
1021-
}
1022-
assert(InterimSucc->getSingleSuccessor() == PostDomSucc &&
1023-
"One successor of a basic block does not lead to the other.");
1024-
assert(InterimSucc->getSinglePredecessor() &&
1025-
"Interim successor has more than one predecessor.");
1026-
assert(PostDomSucc->hasNPredecessors(2) &&
1027-
"PostDom successor has more than two predecessors.");
1028-
DT->addNewBlock(InterimSucc, BB);
1029-
DT->addNewBlock(PostDomSucc, BB);
1030-
}
1031-
// Latch block is a new dominator for the loop exit.
1032-
DT->changeImmediateDominator(LoopExitBB, LoopLatchBB);
1033-
assert(DT->verify(DominatorTree::VerificationLevel::Fast));
1034-
}
1035-
10361003
static void remapOperands(VPBlockBase *Entry, VPBlockBase *NewEntry,
10371004
DenseMap<VPValue *, VPValue *> &Old2NewVPValues) {
10381005
// Update the operands of all cloned recipes starting at NewEntry. This

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "llvm/ADT/Twine.h"
3636
#include "llvm/ADT/ilist.h"
3737
#include "llvm/ADT/ilist_node.h"
38+
#include "llvm/Analysis/DomTreeUpdater.h"
3839
#include "llvm/Analysis/IVDescriptors.h"
3940
#include "llvm/Analysis/LoopInfo.h"
4041
#include "llvm/Analysis/VectorUtils.h"
@@ -372,7 +373,11 @@ struct VPTransformState {
372373
/// of replication, maps the BasicBlock of the last replica created.
373374
SmallDenseMap<VPBasicBlock *, BasicBlock *> VPBB2IRBB;
374375

375-
CFGState() = default;
376+
/// Updater for the DominatorTree.
377+
DomTreeUpdater DTU;
378+
379+
CFGState(DominatorTree *DT)
380+
: DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy) {}
376381

377382
/// Returns the BasicBlock* mapped to the pre-header of the loop region
378383
/// containing \p R.
@@ -382,9 +387,6 @@ struct VPTransformState {
382387
/// Hold a pointer to LoopInfo to register new basic blocks in the loop.
383388
LoopInfo *LI;
384389

385-
/// Hold a pointer to Dominator Tree to register new basic blocks in the loop.
386-
DominatorTree *DT;
387-
388390
/// Hold a reference to the IRBuilder used to generate output IR code.
389391
IRBuilderBase &Builder;
390392

@@ -3289,13 +3291,6 @@ class VPlan {
32893291
/// Clone the current VPlan, update all VPValues of the new VPlan and cloned
32903292
/// recipes to refer to the clones, and return it.
32913293
VPlan *duplicate();
3292-
3293-
private:
3294-
/// Add to the given dominator tree the header block and every new basic block
3295-
/// that was created between it and the latch block, inclusive.
3296-
static void updateDominatorTree(DominatorTree *DT, BasicBlock *LoopHeaderBB,
3297-
BasicBlock *LoopLatchBB,
3298-
BasicBlock *LoopExitBB);
32993294
};
33003295

33013296
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

0 commit comments

Comments
 (0)