@@ -282,10 +282,6 @@ struct VPTransformState {
282
282
// delegates the call to ILV below.
283
283
if (Data.PerPartOutput .count (Def)) {
284
284
auto *VecPart = Data.PerPartOutput [Def][Instance.Part ];
285
- if (!VecPart->getType ()->isVectorTy ()) {
286
- assert (Instance.Lane == 0 && " cannot get lane > 0 for scalar" );
287
- return VecPart;
288
- }
289
285
// TODO: Cache created scalar values.
290
286
return Builder.CreateExtractElement (VecPart,
291
287
Builder.getInt32 (Instance.Lane ));
@@ -302,7 +298,6 @@ struct VPTransformState {
302
298
}
303
299
Data.PerPartOutput [Def][Part] = V;
304
300
}
305
- void set (VPValue *Def, Value *IRDef, Value *V, unsigned Part);
306
301
307
302
// / Hold state information used when constructing the CFG of the output IR,
308
303
// / traversing the VPBasicBlocks and generating corresponding IR BasicBlocks.
@@ -689,20 +684,6 @@ class VPRecipeBase : public ilist_node_with_parent<VPRecipeBase, VPBasicBlock> {
689
684
// / Returns a pointer to a VPValue, if the recipe inherits from VPValue or
690
685
// / nullptr otherwise.
691
686
VPValue *toVPValue ();
692
- const VPValue *toVPValue () const ;
693
-
694
- // / Returns the underlying instruction, if the recipe is a VPValue or nullptr
695
- // / otherwise.
696
- Instruction *getUnderlyingInstr () {
697
- if (auto *VPV = toVPValue ())
698
- return cast_or_null<Instruction>(VPV->getUnderlyingValue ());
699
- return nullptr ;
700
- }
701
- const Instruction *getUnderlyingInstr () const {
702
- if (auto *VPV = toVPValue ())
703
- return cast_or_null<Instruction>(VPV->getUnderlyingValue ());
704
- return nullptr ;
705
- }
706
687
};
707
688
708
689
inline bool VPUser::classof (const VPRecipeBase *Recipe) {
@@ -744,6 +725,10 @@ class VPInstruction : public VPUser, public VPValue, public VPRecipeBase {
744
725
void generateInstruction (VPTransformState &State, unsigned Part);
745
726
746
727
protected:
728
+ Instruction *getUnderlyingInstr () {
729
+ return cast_or_null<Instruction>(getUnderlyingValue ());
730
+ }
731
+
747
732
void setUnderlyingInstr (Instruction *I) { setUnderlyingValue (I); }
748
733
749
734
public:
@@ -1222,9 +1207,8 @@ class VPPredInstPHIRecipe : public VPRecipeBase {
1222
1207
// / - For store: Address, stored value, optional mask
1223
1208
// / TODO: We currently execute only per-part unless a specific instance is
1224
1209
// / provided.
1225
- class VPWidenMemoryInstructionRecipe : public VPRecipeBase ,
1226
- public VPValue,
1227
- public VPUser {
1210
+ class VPWidenMemoryInstructionRecipe : public VPRecipeBase , public VPUser {
1211
+ Instruction &Instr;
1228
1212
1229
1213
void setMask (VPValue *Mask) {
1230
1214
if (!Mask)
@@ -1233,22 +1217,20 @@ class VPWidenMemoryInstructionRecipe : public VPRecipeBase,
1233
1217
}
1234
1218
1235
1219
bool isMasked () const {
1236
- return (isa<LoadInst>(getUnderlyingInstr () ) && getNumOperands () == 2 ) ||
1237
- (isa<StoreInst>(getUnderlyingInstr () ) && getNumOperands () == 3 );
1220
+ return (isa<LoadInst>(Instr ) && getNumOperands () == 2 ) ||
1221
+ (isa<StoreInst>(Instr ) && getNumOperands () == 3 );
1238
1222
}
1239
1223
1240
1224
public:
1241
1225
VPWidenMemoryInstructionRecipe (LoadInst &Load, VPValue *Addr, VPValue *Mask)
1242
- : VPRecipeBase(VPWidenMemoryInstructionSC),
1243
- VPValue (VPValue::VPMemoryInstructionSC, &Load), VPUser({Addr}) {
1226
+ : VPRecipeBase(VPWidenMemoryInstructionSC), VPUser({Addr}), Instr(Load) {
1244
1227
setMask (Mask);
1245
1228
}
1246
1229
1247
1230
VPWidenMemoryInstructionRecipe (StoreInst &Store, VPValue *Addr,
1248
1231
VPValue *StoredValue, VPValue *Mask)
1249
- : VPRecipeBase(VPWidenMemoryInstructionSC),
1250
- VPValue(VPValue::VPMemoryInstructionSC, &Store),
1251
- VPUser({Addr, StoredValue}) {
1232
+ : VPRecipeBase(VPWidenMemoryInstructionSC), VPUser({Addr, StoredValue}),
1233
+ Instr (Store) {
1252
1234
setMask (Mask);
1253
1235
}
1254
1236
@@ -1271,7 +1253,7 @@ class VPWidenMemoryInstructionRecipe : public VPRecipeBase,
1271
1253
1272
1254
// / Return the address accessed by this recipe.
1273
1255
VPValue *getStoredValue () const {
1274
- assert (isa<StoreInst>(getUnderlyingInstr () ) &&
1256
+ assert (isa<StoreInst>(Instr ) &&
1275
1257
" Stored value only available for store instructions" );
1276
1258
return getOperand (1 ); // Stored value is the 2nd, mandatory operand.
1277
1259
}
@@ -1637,10 +1619,6 @@ class VPlan {
1637
1619
// / VPlan.
1638
1620
Value2VPValueTy Value2VPValue;
1639
1621
1640
- // / Contains all VPValues that been allocated by addVPValue directly and need
1641
- // / to be free when the plan's destructor is called.
1642
- SmallVector<VPValue *, 16 > VPValuesToFree;
1643
-
1644
1622
// / Holds the VPLoopInfo analysis for this VPlan.
1645
1623
VPLoopInfo VPLInfo;
1646
1624
@@ -1656,8 +1634,8 @@ class VPlan {
1656
1634
~VPlan () {
1657
1635
if (Entry)
1658
1636
VPBlockBase::deleteCFG (Entry);
1659
- for (VPValue *VPV : VPValuesToFree )
1660
- delete VPV ;
1637
+ for (auto &MapEntry : Value2VPValue )
1638
+ delete MapEntry. second ;
1661
1639
if (BackedgeTakenCount)
1662
1640
delete BackedgeTakenCount;
1663
1641
for (VPValue *Def : VPExternalDefs)
@@ -1707,24 +1685,7 @@ class VPlan {
1707
1685
void addVPValue (Value *V) {
1708
1686
assert (V && " Trying to add a null Value to VPlan" );
1709
1687
assert (!Value2VPValue.count (V) && " Value already exists in VPlan" );
1710
- VPValue *VPV = new VPValue (V);
1711
- Value2VPValue[V] = VPV;
1712
- VPValuesToFree.push_back (VPV);
1713
- }
1714
-
1715
- void addVPValue (Value *V, VPValue *VPV) {
1716
- assert (V && " Trying to add a null Value to VPlan" );
1717
- assert (!Value2VPValue.count (V) && " Value already exists in VPlan" );
1718
- Value2VPValue[V] = VPV;
1719
- }
1720
-
1721
- void addOrReplaceVPValue (Value *V, VPValue *VPV) {
1722
- assert (V && " Trying to add a null Value to VPlan" );
1723
- auto I = Value2VPValue.find (V);
1724
- if (I == Value2VPValue.end ())
1725
- Value2VPValue[V] = VPV;
1726
- else
1727
- I->second = VPV;
1688
+ Value2VPValue[V] = new VPValue (V);
1728
1689
}
1729
1690
1730
1691
VPValue *getVPValue (Value *V) {
@@ -1740,8 +1701,6 @@ class VPlan {
1740
1701
return getVPValue (V);
1741
1702
}
1742
1703
1743
- void removeVPValueFor (Value *V) { Value2VPValue.erase (V); }
1744
-
1745
1704
// / Return the VPLoopInfo analysis for this VPlan.
1746
1705
VPLoopInfo &getVPLoopInfo () { return VPLInfo; }
1747
1706
const VPLoopInfo &getVPLoopInfo () const { return VPLInfo; }
@@ -1823,9 +1782,9 @@ class VPlanPrinter {
1823
1782
};
1824
1783
1825
1784
struct VPlanIngredient {
1826
- const Value *V;
1785
+ Value *V;
1827
1786
1828
- VPlanIngredient (const Value *V) : V(V) {}
1787
+ VPlanIngredient (Value *V) : V(V) {}
1829
1788
};
1830
1789
1831
1790
inline raw_ostream &operator <<(raw_ostream &OS, const VPlanIngredient &I) {
0 commit comments