diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -806,6 +806,16 @@ // Mask is optional and therefore the last operand. return isMasked() ? getOperand(getNumOperands() - 1) : nullptr; } + +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) + /// Print the operands to \p O. + void printOperands(raw_ostream &O, VPSlotTracker &SlotTracker) const; +#endif + + const_operand_range operands_without_mask() const { + auto End = isMasked() ? op_end() - 1 : op_end(); + return const_operand_range(op_begin(), End); + } }; // Helper macro to define common classof implementations for recipes. diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp --- a/llvm/lib/Transforms/Vectorize/VPlan.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp @@ -1148,12 +1148,6 @@ else OS << "vp<%" << Tracker.getSlot(this) << ">"; } - -void VPUser::printOperands(raw_ostream &O, VPSlotTracker &SlotTracker) const { - interleaveComma(operands(), O, [&O, &SlotTracker](VPValue *Op) { - Op->printAsOperand(O, SlotTracker); - }); -} #endif void VPInterleavedAccessInfo::visitRegion(VPRegionBlock *Region, diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp --- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp @@ -227,6 +227,20 @@ insertBefore(BB, I); } +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) +void VPRecipeBase::printOperands(raw_ostream &O, + VPSlotTracker &SlotTracker) const { + interleaveComma(operands_without_mask(), O, [&O, &SlotTracker](VPValue *Op) { + Op->printAsOperand(O, SlotTracker); + }); + if (isMasked()) { + O << " (mask "; + getMask()->printAsOperand(O, SlotTracker); + O << ")"; + } +} +#endif + FastMathFlags VPRecipeWithIRFlags::getFastMathFlags() const { assert(OpType == OperationType::FPMathOp && "recipe doesn't have fast math flags"); diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h --- a/llvm/lib/Transforms/Vectorize/VPlanValue.h +++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h @@ -215,11 +215,6 @@ VPUserID ID; protected: -#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) - /// Print the operands to \p O. - void printOperands(raw_ostream &O, VPSlotTracker &SlotTracker) const; -#endif - VPUser(ArrayRef Operands, VPUserID ID) : ID(ID) { for (VPValue *Operand : Operands) addOperand(Operand); diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/sve-tail-folding-forced.ll b/llvm/test/Transforms/LoopVectorize/AArch64/sve-tail-folding-forced.ll --- a/llvm/test/Transforms/LoopVectorize/AArch64/sve-tail-folding-forced.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/sve-tail-folding-forced.ll @@ -28,7 +28,7 @@ ; VPLANS-NEXT: ACTIVE-LANE-MASK-PHI vp<[[LANEMASK_PHI:%[0-9]+]]> = phi vp<[[LANEMASK_ENTRY]]>, vp<[[LANEMASK_LOOP:%[0-9]+]]> ; VPLANS-NEXT: vp<[[STEP:%[0-9]+]]> = SCALAR-STEPS vp<[[INDV]]>, ir<1> ; VPLANS-NEXT: CLONE ir<%gep> = getelementptr ir<%ptr>, vp<[[STEP]]> -; VPLANS-NEXT: WIDEN store ir<%gep>, ir<%val>, vp<[[LANEMASK_PHI]]> +; VPLANS-NEXT: WIDEN store ir<%gep>, ir<%val> (mask vp<[[LANEMASK_PHI]]>) ; VPLANS-NEXT: EMIT vp<[[INC:%[0-9]+]]> = VF * Part + vp<[[INDV]]> ; VPLANS-NEXT: EMIT vp<[[LANEMASK_LOOP]]> = active lane mask vp<[[INC]]>, vp<[[NEWTC]]> ; VPLANS-NEXT: EMIT vp<[[INDV_UPDATE:%[0-9]+]]> = VF * UF + vp<[[INDV]]>