Skip to content

Commit e29c5f3

Browse files
authored
[RISCV][TTI] Add legality check of vector of address for gather/scatter. (#106481)
This patch add a legality check that checks if target machine support vector of address in `isLegalMaskedGatherScatter()`.
1 parent 7579787 commit e29c5f3

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ class RISCVTTIImpl : public BasicTTIImplBase<RISCVTTIImpl> {
252252
if (DataTypeVT.isFixedLengthVector() && !ST->useRVVForFixedLengthVectors())
253253
return false;
254254

255+
// We also need to check if the vector of address is valid.
256+
EVT PointerTypeVT = EVT(TLI->getPointerTy(DL));
257+
if (DataTypeVT.isScalableVector() &&
258+
!TLI->isLegalElementTypeForRVV(PointerTypeVT))
259+
return false;
260+
255261
EVT ElemType = DataTypeVT.getScalarType();
256262
if (!ST->enableUnalignedVectorMem() && Alignment < ElemType.getStoreSize())
257263
return false;

llvm/test/Analysis/CostModel/RISCV/scalable-gather.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+v,+f,+d,+zfh,+zvfh < %s | FileCheck %s --check-prefixes=CHECK,GENERIC
33
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+v,+f,+d,+zfh,+zvfh -riscv-v-vector-bits-max=256 < %s | FileCheck %s --check-prefixes=CHECK,MAX256
44
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 < %s | FileCheck %s --check-prefixes=CHECK,UNSUPPORTED
5+
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+zve32f,+zvl128b,+f,+d,+zfh,+zvfh < %s | FileCheck %s --check-prefixes=CHECK,UNSUPPORTED
56

67
define void @masked_gather_aligned() {
78
; GENERIC-LABEL: 'masked_gather_aligned'

llvm/test/Analysis/CostModel/RISCV/scalable-scatter.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+v,+f,+d,+zfh,+zvfh < %s | FileCheck %s --check-prefixes=CHECK,GENERIC
33
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+v,+f,+d,+zfh,+zvfh -riscv-v-vector-bits-max=256 < %s | FileCheck %s --check-prefixes=CHECK,MAX256
44
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 < %s | FileCheck %s --check-prefixes=CHECK,UNSUPPORTED
5+
; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=riscv64 -mattr=+zve32f,+zvl128b,+f,+d,+zfh,+zvfh < %s | FileCheck %s --check-prefixes=CHECK,UNSUPPORTED
56

67
define void @masked_scatter_aligned() {
78
; GENERIC-LABEL: 'masked_scatter_aligned'

0 commit comments

Comments
 (0)