Skip to content

Commit d9b3a7b

Browse files
committed
Fix webasm test and address review
1 parent 18110d1 commit d9b3a7b

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,12 @@ InstructionCost
300300
VPPartialReductionRecipe::computeCost(ElementCount VF,
301301
VPCostContext &Ctx) const {
302302
std::optional<unsigned> Opcode;
303-
VPValue *Op = getOperand(0);
303+
VPValue *Op = getOperand(1);
304304
VPRecipeBase *OpR = Op->getDefiningRecipe();
305305

306-
// If the partial reduction is predicated, a select will be operand 0
306+
// If the partial reduction is predicated, a select will be operand 1
307307
using namespace llvm::VPlanPatternMatch;
308-
if (match(getOperand(1), m_Select(m_VPValue(), m_VPValue(Op), m_VPValue()))) {
308+
if (match(Op, m_Select(m_VPValue(), m_VPValue(Op), m_VPValue()))) {
309309
OpR = Op->getDefiningRecipe();
310310
}
311311

@@ -2907,10 +2907,8 @@ void VPExpressionRecipe::print(raw_ostream &O, const Twine &Indent,
29072907
switch (ExpressionType) {
29082908
case ExpressionTypes::ExtendedReduction: {
29092909
getOperand(1)->printAsOperand(O, SlotTracker);
2910-
O << " + ";
2911-
if (IsPartialReduction)
2912-
O << "partial.";
2913-
O << "reduce." << Instruction::getOpcodeName(Opcode) << " (";
2910+
O << " + " << (IsPartialReduction ? "partial." : "") << "reduce.";
2911+
O << Instruction::getOpcodeName(Opcode) << " (";
29142912
getOperand(0)->printAsOperand(O, SlotTracker);
29152913
Red->printFlags(O);
29162914

@@ -2926,11 +2924,8 @@ void VPExpressionRecipe::print(raw_ostream &O, const Twine &Indent,
29262924
}
29272925
case ExpressionTypes::ExtNegatedMulAccReduction: {
29282926
getOperand(getNumOperands() - 1)->printAsOperand(O, SlotTracker);
2929-
O << " + ";
2930-
if (IsPartialReduction)
2931-
O << "partial.";
2932-
O << "reduce."
2933-
<< Instruction::getOpcodeName(
2927+
O << " + " << (IsPartialReduction ? "partial." : "") << "reduce.";
2928+
O << Instruction::getOpcodeName(
29342929
RecurrenceDescriptor::getOpcode(Red->getRecurrenceKind()))
29352930
<< " (sub (0, mul";
29362931
auto *Mul = cast<VPWidenRecipe>(ExpressionRecipes[2]);
@@ -2954,11 +2949,8 @@ void VPExpressionRecipe::print(raw_ostream &O, const Twine &Indent,
29542949
case ExpressionTypes::MulAccReduction:
29552950
case ExpressionTypes::ExtMulAccReduction: {
29562951
getOperand(getNumOperands() - 1)->printAsOperand(O, SlotTracker);
2957-
O << " + ";
2958-
if (IsPartialReduction)
2959-
O << "partial.";
2960-
O << "reduce."
2961-
<< Instruction::getOpcodeName(
2952+
O << " + " << (IsPartialReduction ? "partial." : "") << "reduce.";
2953+
O << Instruction::getOpcodeName(
29622954
RecurrenceDescriptor::getOpcode(Red->getRecurrenceKind()))
29632955
<< " (";
29642956
O << "mul";

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3521,7 +3521,6 @@ tryToMatchAndCreateExtendedReduction(VPReductionRecipe *Red, VPCostContext &Ctx,
35213521
static VPExpressionRecipe *
35223522
tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
35233523
VPCostContext &Ctx, VFRange &Range) {
3524-
using namespace VPlanPatternMatch;
35253524
bool IsPartialReduction = isa<VPPartialReductionRecipe>(Red);
35263525

35273526
unsigned Opcode = RecurrenceDescriptor::getOpcode(Red->getRecurrenceKind());
@@ -3540,6 +3539,8 @@ tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
35403539
// The VF ranges have already been clamped for a partial reduction
35413540
// and its existence confirms that it's valid, so we don't need to
35423541
// perform any cost checks or more clamping.
3542+
// FIXME: Move partial reduction creation, costing and clamping
3543+
// here.
35433544
return true;
35443545
}
35453546

0 commit comments

Comments
 (0)