From 091c5c9a187f656a62f28b6c43d25bfb25c9107e Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Mon, 9 Nov 2020 12:10:03 +0000 Subject: [PATCH] [VPlan] Add printOperands helper to VPUser (NFC). Factor out the code for printing operands of a VPUser so it can be re-used when printing other recipes. --- llvm/lib/Transforms/Vectorize/VPlan.cpp | 18 +++++++++++------- llvm/lib/Transforms/Vectorize/VPlanValue.h | 4 ++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp index 95f9b14..4a3ad0e 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp @@ -915,13 +915,7 @@ void VPWidenMemoryInstructionRecipe::print(raw_ostream &O, const Twine &Indent, O << "\"WIDEN " << Instruction::getOpcodeName(getUnderlyingInstr()->getOpcode()) << " "; - bool First = true; - for (VPValue *Op : operands()) { - if (!First) - O << ", "; - Op->printAsOperand(O, SlotTracker); - First = false; - } + printOperands(O, SlotTracker); } void VPWidenCanonicalIVRecipe::execute(VPTransformState &State) { @@ -988,6 +982,16 @@ void VPValue::printAsOperand(raw_ostream &OS, VPSlotTracker &Tracker) const { OS << "vp<%" << Tracker.getSlot(this) << ">"; } +void VPUser::printOperands(raw_ostream &O, VPSlotTracker &SlotTracker) const { + bool First = true; + for (VPValue *Op : operands()) { + if (!First) + O << ", "; + Op->printAsOperand(O, SlotTracker); + First = false; + } +} + void VPInterleavedAccessInfo::visitRegion(VPRegionBlock *Region, Old2NewTy &Old2New, InterleavedAccessInfo &IAI) { diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h index ba92285..f18b6f9 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanValue.h +++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h @@ -157,6 +157,10 @@ raw_ostream &operator<<(raw_ostream &OS, const VPValue &V); class VPUser { SmallVector Operands; +protected: + /// Print the operands to \p O. + void printOperands(raw_ostream &O, VPSlotTracker &SlotTracker) const; + public: VPUser() {} VPUser(ArrayRef Operands) { -- 2.7.4