Skip to content

Commit 8be3fc0

Browse files
SamTebbs33llvmbot
authored andcommitted
[AArch64] Disallow vscale x 1 partial reductions (llvm#125252)
We don't want to allow partial reductions resulting in a vscale x 1 type as we can't lower it in the backend. (cherry picked from commit c7995a6)
1 parent d185bd9 commit 8be3fc0

File tree

2 files changed

+198
-88
lines changed

2 files changed

+198
-88
lines changed

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4682,13 +4682,24 @@ InstructionCost AArch64TTIImpl::getPartialReductionCost(
46824682
EVT InputEVT = EVT::getEVT(InputTypeA);
46834683
EVT AccumEVT = EVT::getEVT(AccumType);
46844684

4685-
if (VF.isScalable() && !ST->isSVEorStreamingSVEAvailable())
4686-
return Invalid;
4685+
unsigned VFMinValue = VF.getKnownMinValue();
4686+
4687+
if (VF.isScalable()) {
4688+
if (!ST->isSVEorStreamingSVEAvailable())
4689+
return Invalid;
4690+
4691+
// Don't accept a partial reduction if the scaled accumulator is vscale x 1,
4692+
// since we can't lower that type.
4693+
unsigned Scale =
4694+
AccumEVT.getScalarSizeInBits() / InputEVT.getScalarSizeInBits();
4695+
if (VFMinValue == Scale)
4696+
return Invalid;
4697+
}
46874698
if (VF.isFixed() && (!ST->isNeonAvailable() || !ST->hasDotProd()))
46884699
return Invalid;
46894700

46904701
if (InputEVT == MVT::i8) {
4691-
switch (VF.getKnownMinValue()) {
4702+
switch (VFMinValue) {
46924703
default:
46934704
return Invalid;
46944705
case 8:
@@ -4707,7 +4718,7 @@ InstructionCost AArch64TTIImpl::getPartialReductionCost(
47074718
} else if (InputEVT == MVT::i16) {
47084719
// FIXME: Allow i32 accumulator but increase cost, as we would extend
47094720
// it to i64.
4710-
if (VF.getKnownMinValue() != 8 || AccumEVT != MVT::i64)
4721+
if (VFMinValue != 8 || AccumEVT != MVT::i64)
47114722
return Invalid;
47124723
} else
47134724
return Invalid;

0 commit comments

Comments
 (0)