@@ -1194,39 +1194,33 @@ using MDArrayRef = ArrayRef<std::pair<unsigned, MDNode *>>;
11941194
11951195// / Helper to manage IR metadata for recipes. It filters out metadata that
11961196// / cannot be proagated.
1197- class VPWithIRMetadata {
1197+ class VPIRMetadata {
11981198 SmallVector<std::pair<unsigned , MDNode *>> Metadata;
11991199
12001200protected:
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) {}
12071202
12081203public:
12091204 // / 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 ;
12131206
1207+ // / Return the IR metadata.
12141208 MDArrayRef getMetadata () const { return Metadata; }
12151209};
12161210
12171211// / VPWidenRecipe is a recipe for producing a widened instruction using the
12181212// / opcode and operands of the recipe. This recipe covers most of the
12191213// / traditional vectorization cases where each recipe transforms into a
12201214// / vectorized version of itself.
1221- class VPWidenRecipe : public VPRecipeWithIRFlags , public VPWithIRMetadata {
1215+ class VPWidenRecipe : public VPRecipeWithIRFlags , public VPIRMetadata {
12221216 unsigned Opcode;
12231217
12241218protected:
12251219 template <typename IterT>
12261220 VPWidenRecipe (unsigned VPDefOpcode, Instruction &I,
12271221 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()) {}
12301224
12311225public:
12321226 template <typename IterT>
@@ -1263,7 +1257,7 @@ class VPWidenRecipe : public VPRecipeWithIRFlags, public VPWithIRMetadata {
12631257};
12641258
12651259// / VPWidenCastRecipe is a recipe to create vector cast instructions.
1266- class VPWidenCastRecipe : public VPRecipeWithIRFlags , public VPWithIRMetadata {
1260+ class VPWidenCastRecipe : public VPRecipeWithIRFlags , public VPIRMetadata {
12671261 // / Cast instruction opcode.
12681262 Instruction::CastOps Opcode;
12691263
@@ -1274,13 +1268,13 @@ class VPWidenCastRecipe : public VPRecipeWithIRFlags, public VPWithIRMetadata {
12741268 VPWidenCastRecipe (Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy,
12751269 CastInst &UI, MDArrayRef Metadata)
12761270 : VPRecipeWithIRFlags(VPDef::VPWidenCastSC, Op, UI),
1277- VPWithIRMetadata (Metadata), Opcode(Opcode), ResultTy(ResultTy) {
1271+ VPIRMetadata (Metadata), Opcode(Opcode), ResultTy(ResultTy) {
12781272 assert (UI.getOpcode () == Opcode &&
12791273 " opcode of underlying cast doesn't match" );
12801274 }
12811275
12821276 VPWidenCastRecipe (Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy)
1283- : VPRecipeWithIRFlags(VPDef::VPWidenCastSC, Op), VPWithIRMetadata( ),
1277+ : VPRecipeWithIRFlags(VPDef::VPWidenCastSC, Op), VPIRMetadata({} ),
12841278 Opcode(Opcode), ResultTy(ResultTy) {}
12851279
12861280 ~VPWidenCastRecipe () override = default ;
@@ -1315,8 +1309,7 @@ class VPWidenCastRecipe : public VPRecipeWithIRFlags, public VPWithIRMetadata {
13151309};
13161310
13171311// / A recipe for widening vector intrinsics.
1318- class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags ,
1319- public VPWithIRMetadata {
1312+ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags , public VPIRMetadata {
13201313 // / ID of the vector intrinsic to widen.
13211314 Intrinsic::ID VectorIntrinsicID;
13221315
@@ -1337,7 +1330,7 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags,
13371330 ArrayRef<VPValue *> CallArguments, Type *Ty,
13381331 MDArrayRef Metadata, DebugLoc DL = {})
13391332 : VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments, CI),
1340- VPWithIRMetadata (Metadata), VectorIntrinsicID(VectorIntrinsicID),
1333+ VPIRMetadata (Metadata), VectorIntrinsicID(VectorIntrinsicID),
13411334 ResultTy(Ty), MayReadFromMemory(CI.mayReadFromMemory()),
13421335 MayWriteToMemory(CI.mayWriteToMemory()),
13431336 MayHaveSideEffects(CI.mayHaveSideEffects()) {}
@@ -1346,7 +1339,7 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags,
13461339 ArrayRef<VPValue *> CallArguments, Type *Ty,
13471340 MDArrayRef Metadata, DebugLoc DL = {})
13481341 : VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments, DL),
1349- VPWithIRMetadata (Metadata), VectorIntrinsicID(VectorIntrinsicID),
1342+ VPIRMetadata (Metadata), VectorIntrinsicID(VectorIntrinsicID),
13501343 ResultTy(Ty) {
13511344 LLVMContext &Ctx = Ty->getContext ();
13521345 AttributeSet Attrs = Intrinsic::getFnAttributes (Ctx, VectorIntrinsicID);
@@ -1403,7 +1396,7 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags,
14031396};
14041397
14051398// / A recipe for widening Call instructions using library calls.
1406- class VPWidenCallRecipe : public VPRecipeWithIRFlags , public VPWithIRMetadata {
1399+ class VPWidenCallRecipe : public VPRecipeWithIRFlags , public VPIRMetadata {
14071400 // / Variant stores a pointer to the chosen function. There is a 1:1 mapping
14081401 // / between a given VF and the chosen vectorized variant, so there will be a
14091402 // / different VPlan for each VF with a valid variant.
@@ -1415,7 +1408,7 @@ class VPWidenCallRecipe : public VPRecipeWithIRFlags, public VPWithIRMetadata {
14151408 DebugLoc DL = {})
14161409 : VPRecipeWithIRFlags(VPDef::VPWidenCallSC, CallArguments,
14171410 *cast<Instruction>(UV)),
1418- VPWithIRMetadata (Metadata), Variant(Variant) {
1411+ VPIRMetadata (Metadata), Variant(Variant) {
14191412 assert (
14201413 isa<Function>(getOperand (getNumOperands () - 1 )->getLiveInIRValue ()) &&
14211414 " last operand must be the called function" );
@@ -1502,13 +1495,12 @@ class VPHistogramRecipe : public VPRecipeBase {
15021495};
15031496
15041497// / A recipe for widening select instructions.
1505- struct VPWidenSelectRecipe : public VPRecipeWithIRFlags ,
1506- public VPWithIRMetadata {
1498+ struct VPWidenSelectRecipe : public VPRecipeWithIRFlags , public VPIRMetadata {
15071499 template <typename IterT>
15081500 VPWidenSelectRecipe (SelectInst &I, iterator_range<IterT> Operands,
15091501 MDArrayRef Metadata)
15101502 : VPRecipeWithIRFlags(VPDef::VPWidenSelectSC, Operands, I),
1511- VPWithIRMetadata (Metadata) {}
1503+ VPIRMetadata (Metadata) {}
15121504
15131505 ~VPWidenSelectRecipe () override = default ;
15141506
@@ -2636,7 +2628,7 @@ class VPPredInstPHIRecipe : public VPSingleDefRecipe {
26362628
26372629// / A common base class for widening memory operations. An optional mask can be
26382630// / provided as the last operand.
2639- class VPWidenMemoryRecipe : public VPRecipeBase , public VPWithIRMetadata {
2631+ class VPWidenMemoryRecipe : public VPRecipeBase , public VPIRMetadata {
26402632protected:
26412633 Instruction &Ingredient;
26422634
@@ -2661,8 +2653,8 @@ class VPWidenMemoryRecipe : public VPRecipeBase, public VPWithIRMetadata {
26612653 std::initializer_list<VPValue *> Operands,
26622654 bool Consecutive, bool Reverse, MDArrayRef Metadata,
26632655 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) {
26662658 assert ((Consecutive || !Reverse) && " Reverse implies consecutive" );
26672659 }
26682660
@@ -2731,7 +2723,6 @@ struct VPWidenLoadRecipe final : public VPWidenMemoryRecipe, public VPValue {
27312723 auto *Copy = new VPWidenLoadRecipe (cast<LoadInst>(Ingredient), getAddr (),
27322724 getMask (), Consecutive, Reverse,
27332725 getMetadata (), getDebugLoc ());
2734- Copy->addMetadata (getMetadata ());
27352726 return Copy;
27362727 }
27372728
@@ -2766,7 +2757,6 @@ struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue {
27662757 L.isReverse(), L.getMetadata(), L.getDebugLoc()),
27672758 VPValue (this , &getIngredient ()) {
27682759 setMask (Mask);
2769- addMetadata (L.getMetadata ());
27702760 }
27712761
27722762 VP_CLASSOF_IMPL (VPDef::VPWidenLoadEVLSC)
@@ -2812,7 +2802,6 @@ struct VPWidenStoreRecipe final : public VPWidenMemoryRecipe {
28122802 auto *Copy = new VPWidenStoreRecipe (
28132803 cast<StoreInst>(Ingredient), getAddr (), getStoredValue (), getMask (),
28142804 Consecutive, Reverse, getMetadata (), getDebugLoc ());
2815- Copy->addMetadata (getMetadata ());
28162805 return Copy;
28172806 }
28182807
@@ -2850,7 +2839,6 @@ struct VPWidenStoreEVLRecipe final : public VPWidenMemoryRecipe {
28502839 S.isConsecutive(), S.isReverse(), S.getMetadata(),
28512840 S.getDebugLoc()) {
28522841 setMask (Mask);
2853- addMetadata (S.getMetadata ());
28542842 }
28552843
28562844 VP_CLASSOF_IMPL (VPDef::VPWidenStoreEVLSC)
0 commit comments