Skip to content

Commit d2a5a43

Browse files
committed
!fixup, Update after merge, using std::array.
After 6dba5f6, we can pass nullopt that prevent wrong cost from the extended reduction. Also remove the ArrayRef since the elements will be used after free.
1 parent 3e2acad commit d2a5a43

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,9 +2417,14 @@ VPExtendedReductionRecipe::computeCost(ElementCount VF,
24172417
auto *SrcVecTy =
24182418
cast<VectorType>(toVectorTy(Ctx.Types.inferScalarType(getVecOp()), VF));
24192419

2420+
if (RedTy->isFloatingPointTy())
2421+
return Ctx.TTI.getExtendedReductionCost(Opcode, isZExt(), RedTy, SrcVecTy,
2422+
getFastMathFlags(), Ctx.CostKind);
2423+
2424+
// Cannot get correct cost when quering TTI with FMFs not contains `reassoc`
2425+
// for non-FP reductions.
24202426
return Ctx.TTI.getExtendedReductionCost(Opcode, isZExt(), RedTy, SrcVecTy,
2421-
RdxDesc.getFastMathFlags(),
2422-
Ctx.CostKind);
2427+
std::nullopt, Ctx.CostKind);
24232428
}
24242429

24252430
InstructionCost

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,7 @@ expandVPMulAccumulateReduction(VPMulAccumulateReductionRecipe *MulAcc) {
21462146
}
21472147

21482148
// Generate VPWidenRecipe.
2149-
ArrayRef<VPValue *> MulOps = {Op0, Op1};
2149+
std::array<VPValue *, 2> MulOps = {Op0, Op1};
21502150
auto *Mul = new VPWidenRecipe(
21512151
Instruction::Mul, make_range(MulOps.begin(), MulOps.end()),
21522152
MulAcc->hasNoUnsignedWrap(), MulAcc->hasNoSignedWrap(),

0 commit comments

Comments
 (0)