Skip to content

Commit fa6660d

Browse files
committed
Fix webasm test and address review
1 parent f9d4b8b commit fa6660d

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
@@ -301,11 +301,11 @@ InstructionCost
301301
VPPartialReductionRecipe::computeCost(ElementCount VF,
302302
VPCostContext &Ctx) const {
303303
std::optional<unsigned> Opcode;
304-
VPValue *Op = getOperand(0);
304+
VPValue *Op = getOperand(1);
305305
VPRecipeBase *OpR = Op->getDefiningRecipe();
306306

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

@@ -2914,10 +2914,8 @@ void VPExpressionRecipe::print(raw_ostream &O, const Twine &Indent,
29142914
switch (ExpressionType) {
29152915
case ExpressionTypes::ExtendedReduction: {
29162916
getOperand(1)->printAsOperand(O, SlotTracker);
2917-
O << " + ";
2918-
if (IsPartialReduction)
2919-
O << "partial.";
2920-
O << "reduce." << Instruction::getOpcodeName(Opcode) << " (";
2917+
O << " + " << (IsPartialReduction ? "partial." : "") << "reduce.";
2918+
O << Instruction::getOpcodeName(Opcode) << " (";
29212919
getOperand(0)->printAsOperand(O, SlotTracker);
29222920
Red->printFlags(O);
29232921

@@ -2933,11 +2931,8 @@ void VPExpressionRecipe::print(raw_ostream &O, const Twine &Indent,
29332931
}
29342932
case ExpressionTypes::ExtNegatedMulAccReduction: {
29352933
getOperand(getNumOperands() - 1)->printAsOperand(O, SlotTracker);
2936-
O << " + ";
2937-
if (IsPartialReduction)
2938-
O << "partial.";
2939-
O << "reduce."
2940-
<< Instruction::getOpcodeName(
2934+
O << " + " << (IsPartialReduction ? "partial." : "") << "reduce.";
2935+
O << Instruction::getOpcodeName(
29412936
RecurrenceDescriptor::getOpcode(Red->getRecurrenceKind()))
29422937
<< " (sub (0, mul";
29432938
auto *Mul = cast<VPWidenRecipe>(ExpressionRecipes[2]);
@@ -2961,11 +2956,8 @@ void VPExpressionRecipe::print(raw_ostream &O, const Twine &Indent,
29612956
case ExpressionTypes::MulAccReduction:
29622957
case ExpressionTypes::ExtMulAccReduction: {
29632958
getOperand(getNumOperands() - 1)->printAsOperand(O, SlotTracker);
2964-
O << " + ";
2965-
if (IsPartialReduction)
2966-
O << "partial.";
2967-
O << "reduce."
2968-
<< Instruction::getOpcodeName(
2959+
O << " + " << (IsPartialReduction ? "partial." : "") << "reduce.";
2960+
O << Instruction::getOpcodeName(
29692961
RecurrenceDescriptor::getOpcode(Red->getRecurrenceKind()))
29702962
<< " (";
29712963
O << "mul";

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3515,7 +3515,6 @@ tryToMatchAndCreateExtendedReduction(VPReductionRecipe *Red, VPCostContext &Ctx,
35153515
static VPExpressionRecipe *
35163516
tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
35173517
VPCostContext &Ctx, VFRange &Range) {
3518-
using namespace VPlanPatternMatch;
35193518
bool IsPartialReduction = isa<VPPartialReductionRecipe>(Red);
35203519

35213520
unsigned Opcode = RecurrenceDescriptor::getOpcode(Red->getRecurrenceKind());
@@ -3534,6 +3533,8 @@ tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
35343533
// The VF ranges have already been clamped for a partial reduction
35353534
// and its existence confirms that it's valid, so we don't need to
35363535
// perform any cost checks or more clamping.
3536+
// FIXME: Move partial reduction creation, costing and clamping
3537+
// here.
35373538
return true;
35383539
}
35393540

0 commit comments

Comments
 (0)