Skip to content

Commit 8bc0869

Browse files
committed
Reland "[RISCV][TTI] Enable masked interleave access for scalable vector (llvm#149981)"
The patch "[LV] Fix gap mask requirement for interleaved access (llvm#151105)" fixed the an assertion for the RISC-V arch string zvl1024b.
1 parent 86916ff commit 8bc0869

File tree

5 files changed

+187
-219
lines changed

5 files changed

+187
-219
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -979,10 +979,12 @@ InstructionCost RISCVTTIImpl::getInterleavedMemoryOpCost(
979979
Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
980980
bool UseMaskForCond, bool UseMaskForGaps) const {
981981

982-
// The interleaved memory access pass will lower interleaved memory ops (i.e
983-
// a load and store followed by a specific shuffle) to vlseg/vsseg
984-
// intrinsics.
985-
if (!UseMaskForCond && !UseMaskForGaps &&
982+
// The interleaved memory access pass will lower (de)interleave ops combined
983+
// with an adjacent appropriate memory to vlseg/vsseg intrinsics. vlseg/vsseg
984+
// only support masking per-iteration (i.e. condition), not per-segment (i.e.
985+
// gap).
986+
// TODO: Support masked interleaved access for fixed length vector.
987+
if ((isa<ScalableVectorType>(VecTy) || !UseMaskForCond) && !UseMaskForGaps &&
986988
Factor <= TLI->getMaxSupportedInterleaveFactor()) {
987989
auto *VTy = cast<VectorType>(VecTy);
988990
std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(VTy);

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ class RISCVTTIImpl final : public BasicTTIImplBase<RISCVTTIImpl> {
398398

399399
bool enableInterleavedAccessVectorization() const override { return true; }
400400

401+
bool enableMaskedInterleavedAccessVectorization() const override {
402+
return ST->hasVInstructions();
403+
}
404+
401405
unsigned getMinTripCountTailFoldingThreshold() const override;
402406

403407
enum RISCVRegisterClass { GPRRC, FPRRC, VRRC };

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,9 @@ class LoopVectorizationCostModel {
13781378
return;
13791379
// Override EVL styles if needed.
13801380
// FIXME: Investigate opportunity for fixed vector factor.
1381+
// FIXME: Support interleave accesses.
13811382
bool EVLIsLegal = UserIC <= 1 && IsScalableVF &&
1383+
!InterleaveInfo.hasGroups() &&
13821384
TTI.hasActiveVectorLength() && !EnableVPlanNativePath;
13831385
if (EVLIsLegal)
13841386
return;

0 commit comments

Comments
 (0)