@@ -145,8 +145,8 @@ class VPBlockBase {
145
145
}
146
146
147
147
protected:
148
- VPBlockBase (const unsigned char SC, const std::string &N)
149
- : SubclassID(SC), Name(N) {}
148
+ VPBlockBase (const unsigned char SC, const std::string &N, VPlan *ParentPlan )
149
+ : SubclassID(SC), Name(N), Plan(ParentPlan) {}
150
150
151
151
public:
152
152
// / An enumeration for keeping track of the concrete subclass of VPBlockBase
@@ -959,6 +959,8 @@ class VPInstruction : public VPRecipeWithIRFlags,
959
959
VPInstruction *clone() override {
960
960
SmallVector<VPValue *, 2 > Operands (operands ());
961
961
auto *New = new VPInstruction (Opcode, Operands, getDebugLoc (), Name);
962
+ if (getUnderlyingValue ())
963
+ New->setUnderlyingValue (getUnderlyingInstr ());
962
964
New->transferFlags (*this );
963
965
return New;
964
966
}
@@ -1932,7 +1934,11 @@ class VPWidenPHIRecipe : public VPSingleDefRecipe {
1932
1934
}
1933
1935
1934
1936
VPWidenPHIRecipe *clone () override {
1935
- llvm_unreachable (" cloning not implemented yet" );
1937
+ auto *C = new VPWidenPHIRecipe (cast<PHINode>(getUnderlyingValue ()),
1938
+ getOperand (0 ), getDebugLoc (), Name);
1939
+ for (VPValue *Op : make_range (std::next (op_begin ()), op_end ()))
1940
+ C->addOperand (Op);
1941
+ return C;
1936
1942
}
1937
1943
1938
1944
~VPWidenPHIRecipe () override = default ;
@@ -3140,8 +3146,9 @@ class VPBasicBlock : public VPBlockBase {
3140
3146
friend class VPlan ;
3141
3147
3142
3148
// / Use VPlan::createVPBasicBlock to create VPBasicBlocks.
3143
- VPBasicBlock (const Twine &Name = " " , VPRecipeBase *Recipe = nullptr )
3144
- : VPBlockBase(VPBasicBlockSC, Name.str()) {
3149
+ VPBasicBlock (VPlan *ParentPlan, const Twine &Name = " " ,
3150
+ VPRecipeBase *Recipe = nullptr )
3151
+ : VPBlockBase(VPBasicBlockSC, Name.str(), ParentPlan) {
3145
3152
if (Recipe)
3146
3153
appendRecipe (Recipe);
3147
3154
}
@@ -3153,8 +3160,9 @@ class VPBasicBlock : public VPBlockBase {
3153
3160
// / The VPRecipes held in the order of output instructions to generate.
3154
3161
RecipeListTy Recipes;
3155
3162
3156
- VPBasicBlock (const unsigned char BlockSC, const Twine &Name = " " )
3157
- : VPBlockBase(BlockSC, Name.str()) {}
3163
+ VPBasicBlock (const unsigned char BlockSC, VPlan *ParentPlan,
3164
+ const Twine &Name = " " )
3165
+ : VPBlockBase(BlockSC, Name.str(), ParentPlan) {}
3158
3166
3159
3167
public:
3160
3168
~VPBasicBlock () override {
@@ -3292,8 +3300,8 @@ class VPIRBasicBlock : public VPBasicBlock {
3292
3300
BasicBlock *IRBB;
3293
3301
3294
3302
// / Use VPlan::createVPIRBasicBlock to create VPIRBasicBlocks.
3295
- VPIRBasicBlock (BasicBlock *IRBB)
3296
- : VPBasicBlock(VPIRBasicBlockSC,
3303
+ VPIRBasicBlock (BasicBlock *IRBB, VPlan *ParentPlan )
3304
+ : VPBasicBlock(VPIRBasicBlockSC, ParentPlan,
3297
3305
(Twine(" ir-bb<" ) + IRBB->getName () + Twine(" >" )).str()),
3298
3306
IRBB(IRBB) {}
3299
3307
@@ -3336,18 +3344,19 @@ class VPRegionBlock : public VPBlockBase {
3336
3344
bool IsReplicator;
3337
3345
3338
3346
// / Use VPlan::createVPRegionBlock to create VPRegionBlocks.
3339
- VPRegionBlock (VPBlockBase *Entry, VPBlockBase *Exiting,
3347
+ VPRegionBlock (VPBlockBase *Entry, VPBlockBase *Exiting, VPlan *ParentPlan,
3340
3348
const std::string &Name = " " , bool IsReplicator = false )
3341
- : VPBlockBase(VPRegionBlockSC, Name), Entry(Entry ), Exiting(Exiting ),
3342
- IsReplicator (IsReplicator) {
3349
+ : VPBlockBase(VPRegionBlockSC, Name, ParentPlan ), Entry(Entry ),
3350
+ Exiting (Exiting), IsReplicator(IsReplicator) {
3343
3351
assert (Entry->getPredecessors ().empty () && " Entry block has predecessors." );
3344
3352
assert (Exiting->getSuccessors ().empty () && " Exit block has successors." );
3345
3353
Entry->setParent (this );
3346
3354
Exiting->setParent (this );
3347
3355
}
3348
- VPRegionBlock (const std::string &Name = " " , bool IsReplicator = false )
3349
- : VPBlockBase(VPRegionBlockSC, Name), Entry(nullptr ), Exiting(nullptr ),
3350
- IsReplicator(IsReplicator) {}
3356
+ VPRegionBlock (VPlan *ParentPlan, const std::string &Name = " " ,
3357
+ bool IsReplicator = false )
3358
+ : VPBlockBase(VPRegionBlockSC, Name, ParentPlan), Entry(nullptr ),
3359
+ Exiting(nullptr ), IsReplicator(IsReplicator) {}
3351
3360
3352
3361
public:
3353
3362
~VPRegionBlock () override {}
@@ -3740,7 +3749,7 @@ class VPlan {
3740
3749
// / VPlan is destroyed.
3741
3750
VPBasicBlock *createVPBasicBlock (const Twine &Name,
3742
3751
VPRecipeBase *Recipe = nullptr ) {
3743
- auto *VPB = new VPBasicBlock (Name, Recipe);
3752
+ auto *VPB = new VPBasicBlock (this , Name, Recipe);
3744
3753
CreatedBlocks.push_back (VPB);
3745
3754
return VPB;
3746
3755
}
@@ -3751,7 +3760,7 @@ class VPlan {
3751
3760
VPRegionBlock *createVPRegionBlock (VPBlockBase *Entry, VPBlockBase *Exiting,
3752
3761
const std::string &Name = " " ,
3753
3762
bool IsReplicator = false ) {
3754
- auto *VPB = new VPRegionBlock (Entry, Exiting, Name, IsReplicator);
3763
+ auto *VPB = new VPRegionBlock (Entry, Exiting, this , Name, IsReplicator);
3755
3764
CreatedBlocks.push_back (VPB);
3756
3765
return VPB;
3757
3766
}
@@ -3762,7 +3771,7 @@ class VPlan {
3762
3771
// / destroyed.
3763
3772
VPRegionBlock *createVPRegionBlock (const std::string &Name = " " ,
3764
3773
bool IsReplicator = false ) {
3765
- auto *VPB = new VPRegionBlock (Name, IsReplicator);
3774
+ auto *VPB = new VPRegionBlock (this , Name, IsReplicator);
3766
3775
CreatedBlocks.push_back (VPB);
3767
3776
return VPB;
3768
3777
}
0 commit comments