diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 53a900b3c5f8a..fab949beeacac 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -8749,7 +8749,7 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I, Plan.getOrAddLiveIn(ConstantInt::get(I->getType(), 1u, false)); auto *SafeRHS = Builder.createSelect(Mask, Ops[1], One, I->getDebugLoc()); Ops[1] = SafeRHS; - return new VPWidenRecipe(*I, make_range(Ops.begin(), Ops.end())); + return new VPWidenRecipe(*I, Ops); } [[fallthrough]]; } @@ -8795,7 +8795,7 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I, // For other binops, the legacy cost model only checks the second operand. NewOps[1] = GetConstantViaSCEV(NewOps[1]); } - return new VPWidenRecipe(*I, make_range(NewOps.begin(), NewOps.end())); + return new VPWidenRecipe(*I, NewOps); } case Instruction::ExtractValue: { SmallVector NewOps(Operands); @@ -8804,7 +8804,7 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I, assert(EVI->getNumIndices() == 1 && "Expected one extractvalue index"); unsigned Idx = EVI->getIndices()[0]; NewOps.push_back(Plan.getOrAddLiveIn(ConstantInt::get(I32Ty, Idx, false))); - return new VPWidenRecipe(*I, make_range(NewOps.begin(), NewOps.end())); + return new VPWidenRecipe(*I, NewOps); } }; } @@ -8828,9 +8828,7 @@ VPRecipeBuilder::tryToWidenHistogram(const HistogramInfo *HI, if (Legal->isMaskRequired(HI->Store)) HGramOps.push_back(getBlockInMask(HI->Store->getParent())); - return new VPHistogramRecipe(Opcode, - make_range(HGramOps.begin(), HGramOps.end()), - HI->Store->getDebugLoc()); + return new VPHistogramRecipe(Opcode, HGramOps, HI->Store->getDebugLoc()); } VPReplicateRecipe * @@ -8891,8 +8889,7 @@ VPRecipeBuilder::handleReplication(Instruction *I, ArrayRef Operands, assert((Range.Start.isScalar() || !IsUniform || !IsPredicated || (Range.Start.isScalable() && isa(I))) && "Should not predicate a uniform recipe"); - auto *Recipe = new VPReplicateRecipe( - I, make_range(Operands.begin(), Operands.end()), IsUniform, BlockInMask); + auto *Recipe = new VPReplicateRecipe(I, Operands, IsUniform, BlockInMask); return Recipe; } @@ -9081,12 +9078,10 @@ VPRecipeBase *VPRecipeBuilder::tryToCreateWidenRecipe( return nullptr; if (auto *GEP = dyn_cast(Instr)) - return new VPWidenGEPRecipe(GEP, - make_range(Operands.begin(), Operands.end())); + return new VPWidenGEPRecipe(GEP, Operands); if (auto *SI = dyn_cast(Instr)) { - return new VPWidenSelectRecipe( - *SI, make_range(Operands.begin(), Operands.end())); + return new VPWidenSelectRecipe(*SI, Operands); } if (auto *CI = dyn_cast(Instr)) { @@ -9117,7 +9112,7 @@ VPRecipeBuilder::tryToCreatePartialReduction(Instruction *Reduction, SmallVector Ops; Ops.push_back(Plan.getOrAddLiveIn(Zero)); Ops.push_back(BinOp); - BinOp = new VPWidenRecipe(*Reduction, make_range(Ops.begin(), Ops.end())); + BinOp = new VPWidenRecipe(*Reduction, Ops); Builder.insert(BinOp->getDefiningRecipe()); ReductionOpcode = Instruction::Add; } diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h index 067a723a3aa4d..de840763b5ca9 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -386,10 +386,6 @@ class VPRecipeBase : public ilist_node_with_parent, DebugLoc DL = {}) : VPDef(SC), VPUser(Operands), DL(DL) {} - template - VPRecipeBase(const unsigned char SC, iterator_range Operands, - DebugLoc DL = {}) - : VPDef(SC), VPUser(Operands), DL(DL) {} virtual ~VPRecipeBase() = default; /// Clone the current recipe. @@ -504,17 +500,12 @@ class VPRecipeBase : public ilist_node_with_parent, /// Note that VPRecipeBase must be inherited from before VPValue. class VPSingleDefRecipe : public VPRecipeBase, public VPValue { public: - template - VPSingleDefRecipe(const unsigned char SC, IterT Operands, DebugLoc DL = {}) - : VPRecipeBase(SC, Operands, DL), VPValue(this) {} - VPSingleDefRecipe(const unsigned char SC, ArrayRef Operands, DebugLoc DL = {}) : VPRecipeBase(SC, Operands, DL), VPValue(this) {} - template - VPSingleDefRecipe(const unsigned char SC, IterT Operands, Value *UV, - DebugLoc DL = {}) + VPSingleDefRecipe(const unsigned char SC, ArrayRef Operands, + Value *UV, DebugLoc DL = {}) : VPRecipeBase(SC, Operands, DL), VPValue(this, UV) {} static inline bool classof(const VPRecipeBase *R) { @@ -648,15 +639,15 @@ class VPRecipeWithIRFlags : public VPSingleDefRecipe { } public: - template - VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, DebugLoc DL = {}) + VPRecipeWithIRFlags(const unsigned char SC, ArrayRef Operands, + DebugLoc DL = {}) : VPSingleDefRecipe(SC, Operands, DL) { OpType = OperationType::Other; AllFlags = 0; } - template - VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, Instruction &I) + VPRecipeWithIRFlags(const unsigned char SC, ArrayRef Operands, + Instruction &I) : VPSingleDefRecipe(SC, Operands, &I, I.getDebugLoc()) { if (auto *Op = dyn_cast(&I)) { OpType = OperationType::Cmp; @@ -685,33 +676,28 @@ class VPRecipeWithIRFlags : public VPSingleDefRecipe { } } - template - VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, + VPRecipeWithIRFlags(const unsigned char SC, ArrayRef Operands, CmpInst::Predicate Pred, DebugLoc DL = {}) : VPSingleDefRecipe(SC, Operands, DL), OpType(OperationType::Cmp), CmpPredicate(Pred) {} - template - VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, + VPRecipeWithIRFlags(const unsigned char SC, ArrayRef Operands, WrapFlagsTy WrapFlags, DebugLoc DL = {}) : VPSingleDefRecipe(SC, Operands, DL), OpType(OperationType::OverflowingBinOp), WrapFlags(WrapFlags) {} - template - VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, + VPRecipeWithIRFlags(const unsigned char SC, ArrayRef Operands, FastMathFlags FMFs, DebugLoc DL = {}) : VPSingleDefRecipe(SC, Operands, DL), OpType(OperationType::FPMathOp), FMFs(FMFs) {} - template - VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, + VPRecipeWithIRFlags(const unsigned char SC, ArrayRef Operands, DisjointFlagsTy DisjointFlags, DebugLoc DL = {}) : VPSingleDefRecipe(SC, Operands, DL), OpType(OperationType::DisjointOp), DisjointFlags(DisjointFlags) {} protected: - template - VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, + VPRecipeWithIRFlags(const unsigned char SC, ArrayRef Operands, GEPNoWrapFlags GEPFlags, DebugLoc DL = {}) : VPSingleDefRecipe(SC, Operands, DL), OpType(OperationType::GEPOp), GEPFlags(GEPFlags) {} @@ -1225,15 +1211,13 @@ class VPWidenRecipe : public VPRecipeWithIRFlags, public VPIRMetadata { unsigned Opcode; protected: - template VPWidenRecipe(unsigned VPDefOpcode, Instruction &I, - iterator_range Operands) + ArrayRef Operands) : VPRecipeWithIRFlags(VPDefOpcode, Operands, I), VPIRMetadata(I), Opcode(I.getOpcode()) {} public: - template - VPWidenRecipe(Instruction &I, iterator_range Operands) + VPWidenRecipe(Instruction &I, ArrayRef Operands) : VPWidenRecipe(VPDef::VPWidenSC, I, Operands) {} ~VPWidenRecipe() override = default; @@ -1466,8 +1450,7 @@ class VPHistogramRecipe : public VPRecipeBase { unsigned Opcode; public: - template - VPHistogramRecipe(unsigned Opcode, iterator_range Operands, + VPHistogramRecipe(unsigned Opcode, ArrayRef Operands, DebugLoc DL = {}) : VPRecipeBase(VPDef::VPHistogramSC, Operands, DL), Opcode(Opcode) {} @@ -1503,8 +1486,7 @@ class VPHistogramRecipe : public VPRecipeBase { /// A recipe for widening select instructions. struct VPWidenSelectRecipe : public VPRecipeWithIRFlags, public VPIRMetadata { - template - VPWidenSelectRecipe(SelectInst &I, iterator_range Operands) + VPWidenSelectRecipe(SelectInst &I, ArrayRef Operands) : VPRecipeWithIRFlags(VPDef::VPWidenSelectSC, Operands, I), VPIRMetadata(I) {} @@ -1563,8 +1545,7 @@ class VPWidenGEPRecipe : public VPRecipeWithIRFlags { } public: - template - VPWidenGEPRecipe(GetElementPtrInst *GEP, iterator_range Operands) + VPWidenGEPRecipe(GetElementPtrInst *GEP, ArrayRef Operands) : VPRecipeWithIRFlags(VPDef::VPWidenGEPSC, Operands, *GEP) { SmallVector> Metadata; (void)Metadata; @@ -2486,8 +2467,7 @@ class VPReplicateRecipe : public VPRecipeWithIRFlags { bool IsPredicated; public: - template - VPReplicateRecipe(Instruction *I, iterator_range Operands, + VPReplicateRecipe(Instruction *I, ArrayRef Operands, bool IsUniform, VPValue *Mask = nullptr) : VPRecipeWithIRFlags(VPDef::VPReplicateSC, Operands, *I), IsUniform(IsUniform), IsPredicated(Mask) {