@@ -882,11 +882,39 @@ template <unsigned PartOpIdx> class VPUnrollPartAccessor {
882
882
unsigned getUnrollPart (VPUser &U) const ;
883
883
};
884
884
885
+ // / Helper to manage IR metadata for recipes. It filters out metadata that
886
+ // / cannot be propagated.
887
+ class VPIRMetadata {
888
+ SmallVector<std::pair<unsigned , MDNode *>> Metadata;
889
+
890
+ public:
891
+ VPIRMetadata () {}
892
+
893
+ // / Adds metatadata that can be preserved from the original instruction
894
+ // / \p I.
895
+ VPIRMetadata (Instruction &I) { getMetadataToPropagate (&I, Metadata); }
896
+
897
+ // / Adds metatadata that can be preserved from the original instruction
898
+ // / \p I and noalias metadata guaranteed by runtime checks using \p LVer.
899
+ VPIRMetadata (Instruction &I, LoopVersioning *LVer);
900
+
901
+ // / Copy constructor for cloning.
902
+ VPIRMetadata (const VPIRMetadata &Other) : Metadata(Other.Metadata) {}
903
+
904
+ // / Add all metadata to \p I.
905
+ void applyMetadata (Instruction &I) const ;
906
+
907
+ void addMetadata (unsigned Kind, MDNode *Node) {
908
+ Metadata.emplace_back (Kind, Node);
909
+ }
910
+ };
911
+
885
912
// / This is a concrete Recipe that models a single VPlan-level instruction.
886
913
// / While as any Recipe it may generate a sequence of IR instructions when
887
914
// / executed, these instructions would always form a single-def expression as
888
915
// / the VPInstruction is also a single def-use vertex.
889
916
class VPInstruction : public VPRecipeWithIRFlags ,
917
+ public VPIRMetadata,
890
918
public VPUnrollPartAccessor<1 > {
891
919
friend class VPlanSlp ;
892
920
@@ -976,7 +1004,7 @@ class VPInstruction : public VPRecipeWithIRFlags,
976
1004
VPInstruction (unsigned Opcode, ArrayRef<VPValue *> Operands, DebugLoc DL = {},
977
1005
const Twine &Name = " " )
978
1006
: VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands, DL),
979
- Opcode (Opcode), Name(Name.str()) {}
1007
+ VPIRMetadata (), Opcode(Opcode), Name(Name.str()) {}
980
1008
981
1009
VPInstruction (unsigned Opcode, ArrayRef<VPValue *> Operands,
982
1010
const VPIRFlags &Flags, DebugLoc DL = {},
@@ -1268,29 +1296,6 @@ struct VPIRPhi : public VPIRInstruction, public VPPhiAccessors {
1268
1296
const VPRecipeBase *getAsRecipe () const override { return this ; }
1269
1297
};
1270
1298
1271
- // / Helper to manage IR metadata for recipes. It filters out metadata that
1272
- // / cannot be propagated.
1273
- class VPIRMetadata {
1274
- SmallVector<std::pair<unsigned , MDNode *>> Metadata;
1275
-
1276
- public:
1277
- VPIRMetadata () {}
1278
-
1279
- // / Adds metatadata that can be preserved from the original instruction
1280
- // / \p I.
1281
- VPIRMetadata (Instruction &I) { getMetadataToPropagate (&I, Metadata); }
1282
-
1283
- // / Adds metatadata that can be preserved from the original instruction
1284
- // / \p I and noalias metadata guaranteed by runtime checks using \p LVer.
1285
- VPIRMetadata (Instruction &I, LoopVersioning *LVer);
1286
-
1287
- // / Copy constructor for cloning.
1288
- VPIRMetadata (const VPIRMetadata &Other) : Metadata(Other.Metadata) {}
1289
-
1290
- // / Add all metadata to \p I.
1291
- void applyMetadata (Instruction &I) const ;
1292
- };
1293
-
1294
1299
// / VPWidenRecipe is a recipe for producing a widened instruction using the
1295
1300
// / opcode and operands of the recipe. This recipe covers most of the
1296
1301
// / traditional vectorization cases where each recipe transforms into a
0 commit comments