@@ -1194,39 +1194,33 @@ using MDArrayRef = ArrayRef<std::pair<unsigned, MDNode *>>;
1194
1194
1195
1195
// / Helper to manage IR metadata for recipes. It filters out metadata that
1196
1196
// / cannot be proagated.
1197
- class VPWithIRMetadata {
1197
+ class VPIRMetadata {
1198
1198
SmallVector<std::pair<unsigned , MDNode *>> Metadata;
1199
1199
1200
1200
protected:
1201
- VPWithIRMetadata () {}
1202
- VPWithIRMetadata (MDArrayRef Metadata) : Metadata(Metadata) {}
1203
-
1204
- void addMetadata (MDArrayRef Metadata) {
1205
- append_range (this ->Metadata , Metadata);
1206
- }
1201
+ VPIRMetadata (MDArrayRef Metadata) : Metadata(Metadata) {}
1207
1202
1208
1203
public:
1209
1204
// / Add all metadata to \p V if it is an instruction.
1210
- void setMetadata (Value *V) const ;
1211
-
1212
- void addMetadata (unsigned Kind, MDNode *N) { Metadata.emplace_back (Kind, N); }
1205
+ void applyMetadata (Value *V) const ;
1213
1206
1207
+ // / Return the IR metadata.
1214
1208
MDArrayRef getMetadata () const { return Metadata; }
1215
1209
};
1216
1210
1217
1211
// / VPWidenRecipe is a recipe for producing a widened instruction using the
1218
1212
// / opcode and operands of the recipe. This recipe covers most of the
1219
1213
// / traditional vectorization cases where each recipe transforms into a
1220
1214
// / vectorized version of itself.
1221
- class VPWidenRecipe : public VPRecipeWithIRFlags , public VPWithIRMetadata {
1215
+ class VPWidenRecipe : public VPRecipeWithIRFlags , public VPIRMetadata {
1222
1216
unsigned Opcode;
1223
1217
1224
1218
protected:
1225
1219
template <typename IterT>
1226
1220
VPWidenRecipe (unsigned VPDefOpcode, Instruction &I,
1227
1221
iterator_range<IterT> Operands, MDArrayRef Metadata)
1228
- : VPRecipeWithIRFlags(VPDefOpcode, Operands, I),
1229
- VPWithIRMetadata (Metadata), Opcode(I.getOpcode()) {}
1222
+ : VPRecipeWithIRFlags(VPDefOpcode, Operands, I), VPIRMetadata(Metadata),
1223
+ Opcode (I.getOpcode()) {}
1230
1224
1231
1225
public:
1232
1226
template <typename IterT>
@@ -1263,7 +1257,7 @@ class VPWidenRecipe : public VPRecipeWithIRFlags, public VPWithIRMetadata {
1263
1257
};
1264
1258
1265
1259
// / VPWidenCastRecipe is a recipe to create vector cast instructions.
1266
- class VPWidenCastRecipe : public VPRecipeWithIRFlags , public VPWithIRMetadata {
1260
+ class VPWidenCastRecipe : public VPRecipeWithIRFlags , public VPIRMetadata {
1267
1261
// / Cast instruction opcode.
1268
1262
Instruction::CastOps Opcode;
1269
1263
@@ -1274,13 +1268,13 @@ class VPWidenCastRecipe : public VPRecipeWithIRFlags, public VPWithIRMetadata {
1274
1268
VPWidenCastRecipe (Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy,
1275
1269
CastInst &UI, MDArrayRef Metadata)
1276
1270
: VPRecipeWithIRFlags(VPDef::VPWidenCastSC, Op, UI),
1277
- VPWithIRMetadata (Metadata), Opcode(Opcode), ResultTy(ResultTy) {
1271
+ VPIRMetadata (Metadata), Opcode(Opcode), ResultTy(ResultTy) {
1278
1272
assert (UI.getOpcode () == Opcode &&
1279
1273
" opcode of underlying cast doesn't match" );
1280
1274
}
1281
1275
1282
1276
VPWidenCastRecipe (Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy)
1283
- : VPRecipeWithIRFlags(VPDef::VPWidenCastSC, Op), VPWithIRMetadata( ),
1277
+ : VPRecipeWithIRFlags(VPDef::VPWidenCastSC, Op), VPIRMetadata({} ),
1284
1278
Opcode(Opcode), ResultTy(ResultTy) {}
1285
1279
1286
1280
~VPWidenCastRecipe () override = default ;
@@ -1315,8 +1309,7 @@ class VPWidenCastRecipe : public VPRecipeWithIRFlags, public VPWithIRMetadata {
1315
1309
};
1316
1310
1317
1311
// / A recipe for widening vector intrinsics.
1318
- class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags ,
1319
- public VPWithIRMetadata {
1312
+ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags , public VPIRMetadata {
1320
1313
// / ID of the vector intrinsic to widen.
1321
1314
Intrinsic::ID VectorIntrinsicID;
1322
1315
@@ -1337,7 +1330,7 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags,
1337
1330
ArrayRef<VPValue *> CallArguments, Type *Ty,
1338
1331
MDArrayRef Metadata, DebugLoc DL = {})
1339
1332
: VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments, CI),
1340
- VPWithIRMetadata (Metadata), VectorIntrinsicID(VectorIntrinsicID),
1333
+ VPIRMetadata (Metadata), VectorIntrinsicID(VectorIntrinsicID),
1341
1334
ResultTy(Ty), MayReadFromMemory(CI.mayReadFromMemory()),
1342
1335
MayWriteToMemory(CI.mayWriteToMemory()),
1343
1336
MayHaveSideEffects(CI.mayHaveSideEffects()) {}
@@ -1346,7 +1339,7 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags,
1346
1339
ArrayRef<VPValue *> CallArguments, Type *Ty,
1347
1340
MDArrayRef Metadata, DebugLoc DL = {})
1348
1341
: VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments, DL),
1349
- VPWithIRMetadata (Metadata), VectorIntrinsicID(VectorIntrinsicID),
1342
+ VPIRMetadata (Metadata), VectorIntrinsicID(VectorIntrinsicID),
1350
1343
ResultTy(Ty) {
1351
1344
LLVMContext &Ctx = Ty->getContext ();
1352
1345
AttributeSet Attrs = Intrinsic::getFnAttributes (Ctx, VectorIntrinsicID);
@@ -1403,7 +1396,7 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags,
1403
1396
};
1404
1397
1405
1398
// / A recipe for widening Call instructions using library calls.
1406
- class VPWidenCallRecipe : public VPRecipeWithIRFlags , public VPWithIRMetadata {
1399
+ class VPWidenCallRecipe : public VPRecipeWithIRFlags , public VPIRMetadata {
1407
1400
// / Variant stores a pointer to the chosen function. There is a 1:1 mapping
1408
1401
// / between a given VF and the chosen vectorized variant, so there will be a
1409
1402
// / different VPlan for each VF with a valid variant.
@@ -1415,7 +1408,7 @@ class VPWidenCallRecipe : public VPRecipeWithIRFlags, public VPWithIRMetadata {
1415
1408
DebugLoc DL = {})
1416
1409
: VPRecipeWithIRFlags(VPDef::VPWidenCallSC, CallArguments,
1417
1410
*cast<Instruction>(UV)),
1418
- VPWithIRMetadata (Metadata), Variant(Variant) {
1411
+ VPIRMetadata (Metadata), Variant(Variant) {
1419
1412
assert (
1420
1413
isa<Function>(getOperand (getNumOperands () - 1 )->getLiveInIRValue ()) &&
1421
1414
" last operand must be the called function" );
@@ -1502,13 +1495,12 @@ class VPHistogramRecipe : public VPRecipeBase {
1502
1495
};
1503
1496
1504
1497
// / A recipe for widening select instructions.
1505
- struct VPWidenSelectRecipe : public VPRecipeWithIRFlags ,
1506
- public VPWithIRMetadata {
1498
+ struct VPWidenSelectRecipe : public VPRecipeWithIRFlags , public VPIRMetadata {
1507
1499
template <typename IterT>
1508
1500
VPWidenSelectRecipe (SelectInst &I, iterator_range<IterT> Operands,
1509
1501
MDArrayRef Metadata)
1510
1502
: VPRecipeWithIRFlags(VPDef::VPWidenSelectSC, Operands, I),
1511
- VPWithIRMetadata (Metadata) {}
1503
+ VPIRMetadata (Metadata) {}
1512
1504
1513
1505
~VPWidenSelectRecipe () override = default ;
1514
1506
@@ -2636,7 +2628,7 @@ class VPPredInstPHIRecipe : public VPSingleDefRecipe {
2636
2628
2637
2629
// / A common base class for widening memory operations. An optional mask can be
2638
2630
// / provided as the last operand.
2639
- class VPWidenMemoryRecipe : public VPRecipeBase , public VPWithIRMetadata {
2631
+ class VPWidenMemoryRecipe : public VPRecipeBase , public VPIRMetadata {
2640
2632
protected:
2641
2633
Instruction &Ingredient;
2642
2634
@@ -2661,8 +2653,8 @@ class VPWidenMemoryRecipe : public VPRecipeBase, public VPWithIRMetadata {
2661
2653
std::initializer_list<VPValue *> Operands,
2662
2654
bool Consecutive, bool Reverse, MDArrayRef Metadata,
2663
2655
DebugLoc DL)
2664
- : VPRecipeBase(SC, Operands, DL), VPWithIRMetadata (Metadata),
2665
- Ingredient (I), Consecutive(Consecutive), Reverse(Reverse) {
2656
+ : VPRecipeBase(SC, Operands, DL), VPIRMetadata (Metadata), Ingredient(I ),
2657
+ Consecutive (Consecutive), Reverse(Reverse) {
2666
2658
assert ((Consecutive || !Reverse) && " Reverse implies consecutive" );
2667
2659
}
2668
2660
@@ -2731,7 +2723,6 @@ struct VPWidenLoadRecipe final : public VPWidenMemoryRecipe, public VPValue {
2731
2723
auto *Copy = new VPWidenLoadRecipe (cast<LoadInst>(Ingredient), getAddr (),
2732
2724
getMask (), Consecutive, Reverse,
2733
2725
getMetadata (), getDebugLoc ());
2734
- Copy->addMetadata (getMetadata ());
2735
2726
return Copy;
2736
2727
}
2737
2728
@@ -2766,7 +2757,6 @@ struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue {
2766
2757
L.isReverse(), L.getMetadata(), L.getDebugLoc()),
2767
2758
VPValue (this , &getIngredient ()) {
2768
2759
setMask (Mask);
2769
- addMetadata (L.getMetadata ());
2770
2760
}
2771
2761
2772
2762
VP_CLASSOF_IMPL (VPDef::VPWidenLoadEVLSC)
@@ -2812,7 +2802,6 @@ struct VPWidenStoreRecipe final : public VPWidenMemoryRecipe {
2812
2802
auto *Copy = new VPWidenStoreRecipe (
2813
2803
cast<StoreInst>(Ingredient), getAddr (), getStoredValue (), getMask (),
2814
2804
Consecutive, Reverse, getMetadata (), getDebugLoc ());
2815
- Copy->addMetadata (getMetadata ());
2816
2805
return Copy;
2817
2806
}
2818
2807
@@ -2850,7 +2839,6 @@ struct VPWidenStoreEVLRecipe final : public VPWidenMemoryRecipe {
2850
2839
S.isConsecutive(), S.isReverse(), S.getMetadata(),
2851
2840
S.getDebugLoc()) {
2852
2841
setMask (Mask);
2853
- addMetadata (S.getMetadata ());
2854
2842
}
2855
2843
2856
2844
VP_CLASSOF_IMPL (VPDef::VPWidenStoreEVLSC)
0 commit comments