From 500c4b68dc1cbb3532f6fcaf6bf6dafd24ca49e4 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Mon, 20 Dec 2021 23:43:23 -0800 Subject: [PATCH] [llvm] Construct SmallVector with iterator ranges (NFC) --- llvm/lib/Analysis/ConstantFolding.cpp | 2 +- llvm/lib/CodeGen/Analysis.cpp | 4 ++-- llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp | 3 +-- llvm/lib/IR/Operator.cpp | 2 +- llvm/lib/Target/X86/X86ISelLowering.cpp | 6 +++--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 2 +- llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp | 6 ++---- 7 files changed, 11 insertions(+), 14 deletions(-) diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index fcf4be4a538b..1d24535156e8 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -884,7 +884,7 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP, InnermostGEP = GEP; InBounds &= GEP->isInBounds(); - SmallVector NestedOps(GEP->op_begin() + 1, GEP->op_end()); + SmallVector NestedOps(llvm::drop_begin(GEP->operands())); // Do not try the incorporate the sub-GEP if some index is not a number. bool AllConstantInt = true; diff --git a/llvm/lib/CodeGen/Analysis.cpp b/llvm/lib/CodeGen/Analysis.cpp index 7d8a73e12d3a..7e68e5e22879 100644 --- a/llvm/lib/CodeGen/Analysis.cpp +++ b/llvm/lib/CodeGen/Analysis.cpp @@ -712,8 +712,8 @@ bool llvm::returnTypeIsEligibleForTailCall(const Function *F, // The manipulations performed when we're looking through an insertvalue or // an extractvalue would happen at the front of the RetPath list, so since // we have to copy it anyway it's more efficient to create a reversed copy. - SmallVector TmpRetPath(RetPath.rbegin(), RetPath.rend()); - SmallVector TmpCallPath(CallPath.rbegin(), CallPath.rend()); + SmallVector TmpRetPath(llvm::reverse(RetPath)); + SmallVector TmpCallPath(llvm::reverse(CallPath)); // Finally, we can check whether the value produced by the tail call at this // index is compatible with the value we return. diff --git a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp index 9e6f1a537de3..bab187f46535 100644 --- a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp @@ -47,7 +47,6 @@ void PseudoProbeHandler::emitPseudoProbe(uint64_t Guid, uint64_t Index, InlinedAt = InlinedAt->getInlinedAt(); } - SmallVector InlineStack(ReversedInlineStack.rbegin(), - ReversedInlineStack.rend()); + SmallVector InlineStack(llvm::reverse(ReversedInlineStack)); Asm->OutStreamer->emitPseudoProbe(Guid, Index, Type, Attr, InlineStack); } diff --git a/llvm/lib/IR/Operator.cpp b/llvm/lib/IR/Operator.cpp index 4ce1c1d0ddd1..08c1fc931e2e 100644 --- a/llvm/lib/IR/Operator.cpp +++ b/llvm/lib/IR/Operator.cpp @@ -90,7 +90,7 @@ bool GEPOperator::accumulateConstantOffset( assert(Offset.getBitWidth() == DL.getIndexSizeInBits(getPointerAddressSpace()) && "The offset bit width does not match DL specification."); - SmallVector Index(value_op_begin() + 1, value_op_end()); + SmallVector Index(llvm::drop_begin(operand_values())); return GEPOperator::accumulateConstantOffset(getSourceElementType(), Index, DL, Offset, ExternalAnalysis); } diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index b7183a29f3e0..e691b23f642e 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -26650,7 +26650,7 @@ SDValue X86TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, X86CC = X86::COND_E; break; } - SmallVector NewOps(Op->op_begin()+1, Op->op_end()); + SmallVector NewOps(llvm::drop_begin(Op->ops())); SDVTList VTs = DAG.getVTList(MVT::i32, MVT::v16i8, MVT::i32); SDValue PCMP = DAG.getNode(Opcode, dl, VTs, NewOps).getValue(2); SDValue SetCC = getSETCC(X86CC, PCMP, dl, DAG); @@ -26665,7 +26665,7 @@ SDValue X86TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, else Opcode = X86ISD::PCMPESTR; - SmallVector NewOps(Op->op_begin()+1, Op->op_end()); + SmallVector NewOps(llvm::drop_begin(Op->ops())); SDVTList VTs = DAG.getVTList(MVT::i32, MVT::v16i8, MVT::i32); return DAG.getNode(Opcode, dl, VTs, NewOps); } @@ -26678,7 +26678,7 @@ SDValue X86TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, else Opcode = X86ISD::PCMPESTR; - SmallVector NewOps(Op->op_begin()+1, Op->op_end()); + SmallVector NewOps(llvm::drop_begin(Op->ops())); SDVTList VTs = DAG.getVTList(MVT::i32, MVT::v16i8, MVT::i32); return DAG.getNode(Opcode, dl, VTs, NewOps).getValue(1); } diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index a9a2266e1196..798af48c2337 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -6011,7 +6011,7 @@ struct SCEVDbgValueBuilder { // See setFinalExpression: prepend our opcodes on the start of any old // expression opcodes. assert(!DI.hasArgList()); - llvm::SmallVector FinalExpr(Expr.begin() + 2, Expr.end()); + llvm::SmallVector FinalExpr(llvm::drop_begin(Expr, 2)); auto *NewExpr = DIExpression::prependOpcodes(OldExpr, FinalExpr, /*StackValue*/ true); DI.setExpression(NewExpr); diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp index 1e6c014392d1..d2daf558c2c5 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp @@ -157,8 +157,7 @@ bool VPlanTransforms::sinkScalarOperands(VPlan &Plan) { // TODO: add ".cloned" suffix to name of Clone's VPValue. Clone->insertBefore(SinkCandidate); - SmallVector Users(SinkCandidate->user_begin(), - SinkCandidate->user_end()); + SmallVector Users(SinkCandidate->users()); for (auto *U : Users) { auto *UI = cast(U); if (UI->getParent() == SinkTo) @@ -265,8 +264,7 @@ bool VPlanTransforms::mergeReplicateRegions(VPlan &Plan) { VPValue *PredInst1 = cast(&Phi1ToMove)->getOperand(0); VPValue *Phi1ToMoveV = Phi1ToMove.getVPSingleValue(); - SmallVector Users(Phi1ToMoveV->user_begin(), - Phi1ToMoveV->user_end()); + SmallVector Users(Phi1ToMoveV->users()); for (VPUser *U : Users) { auto *UI = dyn_cast(U); if (!UI || UI->getParent() != Then2)