Skip to content

Commit 4b77adf

Browse files
committed
Put VPDT as pointer into State
1 parent 518f669 commit 4b77adf

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ VPTransformState::VPTransformState(const TargetTransformInfo *TTI,
225225
DominatorTree *DT, IRBuilderBase &Builder,
226226
InnerLoopVectorizer *ILV, VPlan *Plan)
227227
: TTI(TTI), VF(VF), CFG(DT), LI(LI), Builder(Builder), ILV(ILV), Plan(Plan),
228-
LVer(nullptr), TypeAnalysis(Plan->getCanonicalIV()->getScalarType()) {}
228+
LVer(nullptr), TypeAnalysis(Plan->getCanonicalIV()->getScalarType()),
229+
VPDT(new VPDominatorTree(*Plan)) {}
230+
231+
VPTransformState::~VPTransformState() { delete VPDT; }
229232

230233
Value *VPTransformState::get(VPValue *Def, const VPLane &Lane) {
231234
if (Def->isLiveIn())
@@ -268,11 +271,10 @@ Value *VPTransformState::get(VPValue *Def, bool NeedsScalar) {
268271
return Data.VPV2Vector[Def];
269272

270273
auto GetBroadcastInstrs = [this, Def](Value *V) {
271-
VPDominatorTree VPDT(*Plan);
272274
bool SafeToHoist =
273275
!Def->hasDefiningRecipe() ||
274-
VPDT.properlyDominates(Def->getDefiningRecipe()->getParent(),
275-
Plan->getVectorPreheader());
276+
VPDT->properlyDominates(Def->getDefiningRecipe()->getParent(),
277+
Plan->getVectorPreheader());
276278

277279
if (VF.isScalar())
278280
return V;

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class VPlanSlp;
6767
class Value;
6868
class LoopVectorizationCostModel;
6969
class LoopVersioning;
70+
class VPDominatorTree;
7071

7172
struct VPCostContext;
7273

@@ -237,6 +238,7 @@ struct VPTransformState {
237238
VPTransformState(const TargetTransformInfo *TTI, ElementCount VF, unsigned UF,
238239
LoopInfo *LI, DominatorTree *DT, IRBuilderBase &Builder,
239240
InnerLoopVectorizer *ILV, VPlan *Plan);
241+
~VPTransformState();
240242
/// Target Transform Info.
241243
const TargetTransformInfo *TTI;
242244

@@ -389,6 +391,9 @@ struct VPTransformState {
389391

390392
/// VPlan-based type analysis.
391393
VPTypeAnalysis TypeAnalysis;
394+
395+
/// VPlan-based dominator tree.
396+
VPDominatorTree *VPDT = nullptr;
392397
};
393398

394399
/// VPBlockBase is the building block of the Hierarchical Control-Flow Graph.

0 commit comments

Comments
 (0)