@@ -1747,6 +1747,21 @@ class TargetTransformInfo {
17471747 bool hasActiveVectorLength (unsigned Opcode, Type *DataType,
17481748 Align Alignment) const ;
17491749
1750+ // / Return true if sinking I's operands to the same basic block as I is
1751+ // / profitable, e.g. because the operands can be folded into a target
1752+ // / instruction during instruction selection. After calling the function
1753+ // / \p Ops contains the Uses to sink ordered by dominance (dominating users
1754+ // / come first).
1755+ bool isProfitableToSinkOperands (Instruction *I,
1756+ SmallVectorImpl<Use *> &Ops) const ;
1757+
1758+ // / Return true if it's significantly cheaper to shift a vector by a uniform
1759+ // / scalar than by an amount which will vary across each lane. On x86 before
1760+ // / AVX2 for example, there is a "psllw" instruction for the former case, but
1761+ // / no simple instruction for a general "a << b" operation on vectors.
1762+ // / This should also apply to lowering for vector funnel shifts (rotates).
1763+ bool isVectorShiftByScalarCheap (Type *Ty) const ;
1764+
17501765 struct VPLegalization {
17511766 enum VPTransform {
17521767 // keep the predicating parameter
@@ -2187,6 +2202,11 @@ class TargetTransformInfo::Concept {
21872202 virtual bool supportsScalableVectors () const = 0;
21882203 virtual bool hasActiveVectorLength (unsigned Opcode, Type *DataType,
21892204 Align Alignment) const = 0;
2205+ virtual bool
2206+ isProfitableToSinkOperands (Instruction *I,
2207+ SmallVectorImpl<Use *> &OpsToSink) const = 0 ;
2208+
2209+ virtual bool isVectorShiftByScalarCheap (Type *Ty) const = 0;
21902210 virtual VPLegalization
21912211 getVPLegalizationStrategy (const VPIntrinsic &PI) const = 0 ;
21922212 virtual bool hasArmWideBranch (bool Thumb) const = 0;
@@ -2963,6 +2983,15 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
29632983 return Impl.hasActiveVectorLength (Opcode, DataType, Alignment);
29642984 }
29652985
2986+ bool isProfitableToSinkOperands (Instruction *I,
2987+ SmallVectorImpl<Use *> &Ops) const override {
2988+ return Impl.isProfitableToSinkOperands (I, Ops);
2989+ };
2990+
2991+ bool isVectorShiftByScalarCheap (Type *Ty) const override {
2992+ return Impl.isVectorShiftByScalarCheap (Ty);
2993+ }
2994+
29662995 VPLegalization
29672996 getVPLegalizationStrategy (const VPIntrinsic &PI) const override {
29682997 return Impl.getVPLegalizationStrategy (PI);
0 commit comments