@@ -1190,6 +1190,8 @@ struct VPIRPhi : public VPIRInstruction {
1190
1190
#endif
1191
1191
};
1192
1192
1193
+ using MDArrayRef = ArrayRef<std::pair<unsigned , MDNode *>>;
1194
+
1193
1195
// / Helper to manage IR metadata for recipes. It filters out metadata that
1194
1196
// / cannot be propagated.
1195
1197
class VPIRMetadata {
@@ -1198,10 +1200,14 @@ class VPIRMetadata {
1198
1200
protected:
1199
1201
VPIRMetadata () {}
1200
1202
VPIRMetadata (Instruction &I) { getMetadataToPropagate (&I, Metadata); }
1203
+ VPIRMetadata (MDArrayRef Metadata) : Metadata(Metadata) {}
1201
1204
1202
1205
public:
1203
1206
// / Add all metadata to \p I.
1204
1207
void applyMetadata (Instruction &I) const ;
1208
+
1209
+ // / Return the IR metadata.
1210
+ MDArrayRef getMetadata () const { return Metadata; }
1205
1211
};
1206
1212
1207
1213
// / VPWidenRecipe is a recipe for producing a widened instruction using the
@@ -2459,7 +2465,7 @@ class VPReductionEVLRecipe : public VPReductionRecipe {
2459
2465
// / copies of the original scalar type, one per lane, instead of producing a
2460
2466
// / single copy of widened type for all lanes. If the instruction is known to be
2461
2467
// / uniform only one copy, per lane zero, will be generated.
2462
- class VPReplicateRecipe : public VPRecipeWithIRFlags {
2468
+ class VPReplicateRecipe : public VPRecipeWithIRFlags , public VPIRMetadata {
2463
2469
// / Indicator if only a single replica per lane is needed.
2464
2470
bool IsUniform;
2465
2471
@@ -2469,19 +2475,20 @@ class VPReplicateRecipe : public VPRecipeWithIRFlags {
2469
2475
public:
2470
2476
template <typename IterT>
2471
2477
VPReplicateRecipe (Instruction *I, iterator_range<IterT> Operands,
2472
- bool IsUniform, VPValue *Mask = nullptr )
2478
+ bool IsUniform, VPValue *Mask = nullptr ,
2479
+ ArrayRef<std::pair<unsigned , MDNode *>> Metadata = {})
2473
2480
: VPRecipeWithIRFlags(VPDef::VPReplicateSC, Operands, *I),
2474
- IsUniform (IsUniform), IsPredicated(Mask) {
2481
+ VPIRMetadata (Metadata), IsUniform(IsUniform), IsPredicated(Mask) {
2475
2482
if (Mask)
2476
2483
addOperand (Mask);
2477
2484
}
2478
2485
2479
2486
~VPReplicateRecipe () override = default ;
2480
2487
2481
2488
VPReplicateRecipe *clone () override {
2482
- auto *Copy =
2483
- new VPReplicateRecipe ( getUnderlyingInstr (), operands (), IsUniform,
2484
- isPredicated () ? getMask () : nullptr );
2489
+ auto *Copy = new VPReplicateRecipe (
2490
+ getUnderlyingInstr (), operands (), IsUniform,
2491
+ isPredicated () ? getMask () : nullptr , getMetadata () );
2485
2492
Copy->transferFlags (*this );
2486
2493
return Copy;
2487
2494
}
@@ -2641,8 +2648,9 @@ class VPWidenMemoryRecipe : public VPRecipeBase, public VPIRMetadata {
2641
2648
2642
2649
VPWidenMemoryRecipe (const char unsigned SC, Instruction &I,
2643
2650
std::initializer_list<VPValue *> Operands,
2644
- bool Consecutive, bool Reverse, DebugLoc DL)
2645
- : VPRecipeBase(SC, Operands, DL), VPIRMetadata(I), Ingredient(I),
2651
+ bool Consecutive, bool Reverse, MDArrayRef Metadata,
2652
+ DebugLoc DL)
2653
+ : VPRecipeBase(SC, Operands, DL), VPIRMetadata(Metadata), Ingredient(I),
2646
2654
Consecutive (Consecutive), Reverse(Reverse) {
2647
2655
assert ((Consecutive || !Reverse) && " Reverse implies consecutive" );
2648
2656
}
@@ -2700,16 +2708,17 @@ class VPWidenMemoryRecipe : public VPRecipeBase, public VPIRMetadata {
2700
2708
// / optional mask.
2701
2709
struct VPWidenLoadRecipe final : public VPWidenMemoryRecipe, public VPValue {
2702
2710
VPWidenLoadRecipe (LoadInst &Load, VPValue *Addr, VPValue *Mask,
2703
- bool Consecutive, bool Reverse, DebugLoc DL)
2711
+ bool Consecutive, bool Reverse, MDArrayRef Metadata,
2712
+ DebugLoc DL)
2704
2713
: VPWidenMemoryRecipe(VPDef::VPWidenLoadSC, Load, {Addr}, Consecutive,
2705
- Reverse, DL),
2714
+ Reverse, Metadata, DL),
2706
2715
VPValue (this , &Load) {
2707
2716
setMask (Mask);
2708
2717
}
2709
2718
2710
2719
VPWidenLoadRecipe *clone () override {
2711
2720
return new VPWidenLoadRecipe (cast<LoadInst>(Ingredient), getAddr (),
2712
- getMask (), Consecutive, Reverse,
2721
+ getMask (), Consecutive, Reverse, getMetadata (),
2713
2722
getDebugLoc ());
2714
2723
}
2715
2724
@@ -2741,7 +2750,7 @@ struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue {
2741
2750
VPWidenLoadEVLRecipe (VPWidenLoadRecipe &L, VPValue &EVL, VPValue *Mask)
2742
2751
: VPWidenMemoryRecipe(VPDef::VPWidenLoadEVLSC, L.getIngredient(),
2743
2752
{L.getAddr (), &EVL}, L.isConsecutive(),
2744
- L.isReverse(), L.getDebugLoc()),
2753
+ L.isReverse(), L.getMetadata(), L. getDebugLoc()),
2745
2754
VPValue (this , &getIngredient ()) {
2746
2755
setMask (Mask);
2747
2756
}
@@ -2778,16 +2787,17 @@ struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue {
2778
2787
// / to store to and an optional mask.
2779
2788
struct VPWidenStoreRecipe final : public VPWidenMemoryRecipe {
2780
2789
VPWidenStoreRecipe (StoreInst &Store, VPValue *Addr, VPValue *StoredVal,
2781
- VPValue *Mask, bool Consecutive, bool Reverse, DebugLoc DL)
2790
+ VPValue *Mask, bool Consecutive, bool Reverse,
2791
+ MDArrayRef Metadata, DebugLoc DL)
2782
2792
: VPWidenMemoryRecipe(VPDef::VPWidenStoreSC, Store, {Addr, StoredVal},
2783
- Consecutive, Reverse, DL) {
2793
+ Consecutive, Reverse, Metadata, DL) {
2784
2794
setMask (Mask);
2785
2795
}
2786
2796
2787
2797
VPWidenStoreRecipe *clone () override {
2788
2798
return new VPWidenStoreRecipe (cast<StoreInst>(Ingredient), getAddr (),
2789
2799
getStoredValue (), getMask (), Consecutive,
2790
- Reverse, getDebugLoc ());
2800
+ Reverse, getMetadata (), getDebugLoc ());
2791
2801
}
2792
2802
2793
2803
VP_CLASSOF_IMPL (VPDef::VPWidenStoreSC);
@@ -2821,7 +2831,8 @@ struct VPWidenStoreEVLRecipe final : public VPWidenMemoryRecipe {
2821
2831
VPWidenStoreEVLRecipe (VPWidenStoreRecipe &S, VPValue &EVL, VPValue *Mask)
2822
2832
: VPWidenMemoryRecipe(VPDef::VPWidenStoreEVLSC, S.getIngredient(),
2823
2833
{S.getAddr (), S.getStoredValue (), &EVL},
2824
- S.isConsecutive(), S.isReverse(), S.getDebugLoc()) {
2834
+ S.isConsecutive(), S.isReverse(), S.getMetadata(),
2835
+ S.getDebugLoc()) {
2825
2836
setMask (Mask);
2826
2837
}
2827
2838
0 commit comments