@@ -519,7 +519,6 @@ class VPSingleDefRecipe : public VPRecipeBase, public VPValue {
519519 case VPRecipeBase::VPReverseVectorPointerSC:
520520 case VPRecipeBase::VPWidenCallSC:
521521 case VPRecipeBase::VPWidenCanonicalIVSC:
522- case VPRecipeBase::VPWidenCastSC:
523522 case VPRecipeBase::VPWidenGEPSC:
524523 case VPRecipeBase::VPWidenIntrinsicSC:
525524 case VPRecipeBase::VPWidenSC:
@@ -598,13 +597,15 @@ class VPRecipeWithIRFlags : public VPSingleDefRecipe {
598597 DisjointFlagsTy (bool IsDisjoint) : IsDisjoint(IsDisjoint) {}
599598 };
600599
600+ struct NonNegFlagsTy {
601+ char NonNeg : 1 ;
602+ NonNegFlagsTy (bool IsNonNeg = false ) : NonNeg(IsNonNeg) {}
603+ };
604+
601605private:
602606 struct ExactFlagsTy {
603607 char IsExact : 1 ;
604608 };
605- struct NonNegFlagsTy {
606- char NonNeg : 1 ;
607- };
608609 struct FastMathFlagsTy {
609610 char AllowReassoc : 1 ;
610611 char NoNaNs : 1 ;
@@ -698,6 +699,12 @@ class VPRecipeWithIRFlags : public VPSingleDefRecipe {
698699 : VPSingleDefRecipe(SC, Operands, DL), OpType(OperationType::DisjointOp),
699700 DisjointFlags(DisjointFlags) {}
700701
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+
701708protected:
702709 template <typename IterT>
703710 VPRecipeWithIRFlags (const unsigned char SC, IterT Operands,
@@ -710,7 +717,6 @@ class VPRecipeWithIRFlags : public VPSingleDefRecipe {
710717 return R->getVPDefID () == VPRecipeBase::VPInstructionSC ||
711718 R->getVPDefID () == VPRecipeBase::VPWidenSC ||
712719 R->getVPDefID () == VPRecipeBase::VPWidenGEPSC ||
713- R->getVPDefID () == VPRecipeBase::VPWidenCastSC ||
714720 R->getVPDefID () == VPRecipeBase::VPWidenIntrinsicSC ||
715721 R->getVPDefID () == VPRecipeBase::VPReplicateSC ||
716722 R->getVPDefID () == VPRecipeBase::VPReverseVectorPointerSC ||
@@ -953,6 +959,12 @@ class VPInstruction : public VPRecipeWithIRFlags,
953959 VPInstruction (unsigned Opcode, std::initializer_list<VPValue *> Operands,
954960 FastMathFlags FMFs, DebugLoc DL = {}, const Twine &Name = " " );
955961
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+
956968 VP_CLASSOF_IMPL (VPDef::VPInstructionSC)
957969
958970 VPInstruction *clone() override {
@@ -1039,6 +1051,11 @@ class VPInstructionWithType : public VPInstruction {
10391051 Type *ResultTy, DebugLoc DL, const Twine &Name = " " )
10401052 : VPInstruction(Opcode, Operands, DL, Name), ResultTy(ResultTy) {}
10411053
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+
10421059 static inline bool classof (const VPRecipeBase *R) {
10431060 auto *VPI = dyn_cast<VPInstruction>(R);
10441061 return VPI && Instruction::isCast (VPI->getOpcode ());
@@ -1051,18 +1068,17 @@ class VPInstructionWithType : public VPInstruction {
10511068 VPInstruction *clone () override {
10521069 auto *New =
10531070 new VPInstructionWithType (getOpcode (), {getOperand (0 )}, getResultType (),
1054- getDebugLoc (), getName ());
1071+ {}, getDebugLoc (), getName ());
10551072 New->setUnderlyingValue (getUnderlyingValue ());
1073+ New->transferFlags (*this );
10561074 return New;
10571075 }
10581076
10591077 void execute (VPTransformState &State) override ;
10601078
10611079 // / Return the cost of this VPIRInstruction.
10621080 InstructionCost computeCost (ElementCount VF,
1063- VPCostContext &Ctx) const override {
1064- return 0 ;
1065- }
1081+ VPCostContext &Ctx) const override ;
10661082
10671083 Type *getResultType () const { return ResultTy; }
10681084
@@ -1180,58 +1196,6 @@ class VPWidenRecipe : public VPRecipeWithIRFlags {
11801196#endif
11811197};
11821198
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-
12351199// / A recipe for widening vector intrinsics.
12361200class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags {
12371201 // / ID of the vector intrinsic to widen.
0 commit comments