@@ -519,7 +519,6 @@ class VPSingleDefRecipe : public VPRecipeBase, public VPValue {
519
519
case VPRecipeBase::VPReverseVectorPointerSC:
520
520
case VPRecipeBase::VPWidenCallSC:
521
521
case VPRecipeBase::VPWidenCanonicalIVSC:
522
- case VPRecipeBase::VPWidenCastSC:
523
522
case VPRecipeBase::VPWidenGEPSC:
524
523
case VPRecipeBase::VPWidenIntrinsicSC:
525
524
case VPRecipeBase::VPWidenSC:
@@ -598,13 +597,15 @@ class VPRecipeWithIRFlags : public VPSingleDefRecipe {
598
597
DisjointFlagsTy (bool IsDisjoint) : IsDisjoint(IsDisjoint) {}
599
598
};
600
599
600
+ struct NonNegFlagsTy {
601
+ char NonNeg : 1 ;
602
+ NonNegFlagsTy (bool IsNonNeg = false ) : NonNeg(IsNonNeg) {}
603
+ };
604
+
601
605
private:
602
606
struct ExactFlagsTy {
603
607
char IsExact : 1 ;
604
608
};
605
- struct NonNegFlagsTy {
606
- char NonNeg : 1 ;
607
- };
608
609
struct FastMathFlagsTy {
609
610
char AllowReassoc : 1 ;
610
611
char NoNaNs : 1 ;
@@ -698,6 +699,12 @@ class VPRecipeWithIRFlags : public VPSingleDefRecipe {
698
699
: VPSingleDefRecipe(SC, Operands, DL), OpType(OperationType::DisjointOp),
699
700
DisjointFlags(DisjointFlags) {}
700
701
702
+ template <typename IterT>
703
+ VPRecipeWithIRFlags (const unsigned char SC, IterT Operands,
704
+ NonNegFlagsTy NonNegFlags, DebugLoc DL = {})
705
+ : VPSingleDefRecipe(SC, Operands, DL), OpType(OperationType::NonNegOp),
706
+ NonNegFlags(NonNegFlags) {}
707
+
701
708
protected:
702
709
template <typename IterT>
703
710
VPRecipeWithIRFlags (const unsigned char SC, IterT Operands,
@@ -710,7 +717,6 @@ class VPRecipeWithIRFlags : public VPSingleDefRecipe {
710
717
return R->getVPDefID () == VPRecipeBase::VPInstructionSC ||
711
718
R->getVPDefID () == VPRecipeBase::VPWidenSC ||
712
719
R->getVPDefID () == VPRecipeBase::VPWidenGEPSC ||
713
- R->getVPDefID () == VPRecipeBase::VPWidenCastSC ||
714
720
R->getVPDefID () == VPRecipeBase::VPWidenIntrinsicSC ||
715
721
R->getVPDefID () == VPRecipeBase::VPReplicateSC ||
716
722
R->getVPDefID () == VPRecipeBase::VPReverseVectorPointerSC ||
@@ -953,6 +959,12 @@ class VPInstruction : public VPRecipeWithIRFlags,
953
959
VPInstruction (unsigned Opcode, std::initializer_list<VPValue *> Operands,
954
960
FastMathFlags FMFs, DebugLoc DL = {}, const Twine &Name = " " );
955
961
962
+ VPInstruction (unsigned Opcode, ArrayRef<VPValue *> Operands,
963
+ NonNegFlagsTy NonNegFlags, DebugLoc DL = {},
964
+ const Twine &Name = " " )
965
+ : VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands, NonNegFlags, DL),
966
+ Opcode(Opcode), Name(Name.str()) {}
967
+
956
968
VP_CLASSOF_IMPL (VPDef::VPInstructionSC)
957
969
958
970
VPInstruction *clone() override {
@@ -1039,6 +1051,11 @@ class VPInstructionWithType : public VPInstruction {
1039
1051
Type *ResultTy, DebugLoc DL, const Twine &Name = " " )
1040
1052
: VPInstruction(Opcode, Operands, DL, Name), ResultTy(ResultTy) {}
1041
1053
1054
+ VPInstructionWithType (unsigned Opcode, ArrayRef<VPValue *> Operands,
1055
+ Type *ResultTy, NonNegFlagsTy Flags, DebugLoc DL,
1056
+ const Twine &Name = " " )
1057
+ : VPInstruction(Opcode, Operands, Flags, DL, Name), ResultTy(ResultTy) {}
1058
+
1042
1059
static inline bool classof (const VPRecipeBase *R) {
1043
1060
auto *VPI = dyn_cast<VPInstruction>(R);
1044
1061
return VPI && Instruction::isCast (VPI->getOpcode ());
@@ -1051,18 +1068,17 @@ class VPInstructionWithType : public VPInstruction {
1051
1068
VPInstruction *clone () override {
1052
1069
auto *New =
1053
1070
new VPInstructionWithType (getOpcode (), {getOperand (0 )}, getResultType (),
1054
- getDebugLoc (), getName ());
1071
+ {}, getDebugLoc (), getName ());
1055
1072
New->setUnderlyingValue (getUnderlyingValue ());
1073
+ New->transferFlags (*this );
1056
1074
return New;
1057
1075
}
1058
1076
1059
1077
void execute (VPTransformState &State) override ;
1060
1078
1061
1079
// / Return the cost of this VPIRInstruction.
1062
1080
InstructionCost computeCost (ElementCount VF,
1063
- VPCostContext &Ctx) const override {
1064
- return 0 ;
1065
- }
1081
+ VPCostContext &Ctx) const override ;
1066
1082
1067
1083
Type *getResultType () const { return ResultTy; }
1068
1084
@@ -1180,58 +1196,6 @@ class VPWidenRecipe : public VPRecipeWithIRFlags {
1180
1196
#endif
1181
1197
};
1182
1198
1183
- // / VPWidenCastRecipe is a recipe to create vector cast instructions.
1184
- class VPWidenCastRecipe : public VPRecipeWithIRFlags {
1185
- // / Cast instruction opcode.
1186
- Instruction::CastOps Opcode;
1187
-
1188
- // / Result type for the cast.
1189
- Type *ResultTy;
1190
-
1191
- public:
1192
- VPWidenCastRecipe (Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy,
1193
- CastInst &UI)
1194
- : VPRecipeWithIRFlags(VPDef::VPWidenCastSC, Op, UI), Opcode(Opcode),
1195
- ResultTy (ResultTy) {
1196
- assert (UI.getOpcode () == Opcode &&
1197
- " opcode of underlying cast doesn't match" );
1198
- }
1199
-
1200
- VPWidenCastRecipe (Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy)
1201
- : VPRecipeWithIRFlags(VPDef::VPWidenCastSC, Op), Opcode(Opcode),
1202
- ResultTy(ResultTy) {}
1203
-
1204
- ~VPWidenCastRecipe () override = default ;
1205
-
1206
- VPWidenCastRecipe *clone () override {
1207
- if (auto *UV = getUnderlyingValue ())
1208
- return new VPWidenCastRecipe (Opcode, getOperand (0 ), ResultTy,
1209
- *cast<CastInst>(UV));
1210
-
1211
- return new VPWidenCastRecipe (Opcode, getOperand (0 ), ResultTy);
1212
- }
1213
-
1214
- VP_CLASSOF_IMPL (VPDef::VPWidenCastSC)
1215
-
1216
- // / Produce widened copies of the cast.
1217
- void execute(VPTransformState &State) override ;
1218
-
1219
- // / Return the cost of this VPWidenCastRecipe.
1220
- InstructionCost computeCost (ElementCount VF,
1221
- VPCostContext &Ctx) const override ;
1222
-
1223
- #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1224
- // / Print the recipe.
1225
- void print (raw_ostream &O, const Twine &Indent,
1226
- VPSlotTracker &SlotTracker) const override ;
1227
- #endif
1228
-
1229
- Instruction::CastOps getOpcode () const { return Opcode; }
1230
-
1231
- // / Returns the result type of the cast.
1232
- Type *getResultType () const { return ResultTy; }
1233
- };
1234
-
1235
1199
// / A recipe for widening vector intrinsics.
1236
1200
class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags {
1237
1201
// / ID of the vector intrinsic to widen.
0 commit comments