[llvm] [LV] Check early for supported interleave factors with scalable types [nfc] (PR #111592)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 8 14:35:16 PDT 2024
https://github.com/preames created https://github.com/llvm/llvm-project/pull/111592
Previously, the cost model was returning an invalid cost. This simply moves the check from one place to another. This is mostly to make the cost modeling code a bit easier to follow.
>From 65146023ec33a37001e32524fdb8bda57a268b96 Mon Sep 17 00:00:00 2001
From: Philip Reames <preames at rivosinc.com>
Date: Tue, 8 Oct 2024 14:32:38 -0700
Subject: [PATCH] [LV] Check early for supported interleave factors with
scalable types [nfc]
Previously, the cost model was returning an invalid cost. This simply
moves the check from one place to another. This is mostly to make the
cost modeling code a bit easier to follow.
---
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp | 2 --
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 8 +++++++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index a61461681f79ed..34110b0f46107f 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -675,8 +675,6 @@ InstructionCost RISCVTTIImpl::getInterleavedMemoryOpCost(
unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
bool UseMaskForCond, bool UseMaskForGaps) {
- if (isa<ScalableVectorType>(VecTy) && Factor != 2)
- return InstructionCost::getInvalid();
// The interleaved memory access pass will lower interleaved memory ops (i.e
// a load and store followed by a specific shuffle) to vlseg/vsseg
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 001c8987667df8..5427365aced175 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3406,6 +3406,7 @@ bool LoopVectorizationCostModel::interleavedAccessCanBeWidened(
"Decision should not be set yet.");
auto *Group = getInterleavedAccessGroup(I);
assert(Group && "Must have a group.");
+ unsigned InterleaveFactor = Group->getFactor();
// If the instruction's allocated size doesn't equal it's type size, it
// requires padding and will be scalarized.
@@ -3414,9 +3415,14 @@ bool LoopVectorizationCostModel::interleavedAccessCanBeWidened(
if (hasIrregularType(ScalarTy, DL))
return false;
+ // We currently only know how to emit interleave/deinterleave with
+ // Factor=2 for scalable vectors. This is purely an implementation
+ // limit.
+ if (VF.isScalable() && InterleaveFactor != 2)
+ return false;
+
// If the group involves a non-integral pointer, we may not be able to
// losslessly cast all values to a common type.
- unsigned InterleaveFactor = Group->getFactor();
bool ScalarNI = DL.isNonIntegralPointerType(ScalarTy);
for (unsigned Idx = 0; Idx < InterleaveFactor; Idx++) {
Instruction *Member = Group->getMember(Idx);
More information about the llvm-commits
mailing list