diff --git a/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/lib/Target/RISCV/RISCVTargetTransformInfo.cpp index ab80b18d12c..f1c6d5630c8 100644 --- a/lib/Target/RISCV/RISCVTargetTransformInfo.cpp +++ b/lib/Target/RISCV/RISCVTargetTransformInfo.cpp @@ -148,11 +148,6 @@ unsigned RISCVTTIImpl::getGatherScatterOpCost( return BaseT::getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask, Alignment, CostKind, I); - // FIXME: Only supporting fixed vectors for now. - if (!isa(DataTy) || ST->getMinRVVVectorSizeInBits() == 0) - return BaseT::getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask, - Alignment, CostKind, I); - if ((Opcode == Instruction::Load && !isLegalMaskedGather(DataTy, Align(Alignment))) || (Opcode == Instruction::Store && @@ -160,6 +155,11 @@ unsigned RISCVTTIImpl::getGatherScatterOpCost( return BaseT::getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask, Alignment, CostKind, I); + // FIXME: Only supporting fixed vectors for now. + if (!isa(DataTy)) + return BaseT::getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask, + Alignment, CostKind, I); + auto *VTy = cast(DataTy); unsigned NumLoads = VTy->getNumElements(); unsigned MemOpCost = diff --git a/test/Analysis/CostModel/RISCV/fixed-vector-gather.ll b/test/Analysis/CostModel/RISCV/fixed-vector-gather.ll index a456c95313c..5de1f3eb97d 100644 --- a/test/Analysis/CostModel/RISCV/fixed-vector-gather.ll +++ b/test/Analysis/CostModel/RISCV/fixed-vector-gather.ll @@ -1,5 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py ; RUN: opt -cost-model -analyze -mtriple=riscv64 -mattr=+experimental-v,+f,+d,+experimental-zfh -riscv-v-vector-bits-min=128 -riscv-v-fixed-length-vector-lmul-max=1 < %s 2>%t | FileCheck %s +; Sanity check that we don't crash querying costs when vectors are not enabled. +; RUN: opt -cost-model -analyze -mtriple=riscv64 define i32 @masked_gather() { ; CHECK-LABEL: 'masked_gather' diff --git a/test/Analysis/CostModel/RISCV/fixed-vector-scatter.ll b/test/Analysis/CostModel/RISCV/fixed-vector-scatter.ll index 23f0fbd24af..90323e26e8f 100644 --- a/test/Analysis/CostModel/RISCV/fixed-vector-scatter.ll +++ b/test/Analysis/CostModel/RISCV/fixed-vector-scatter.ll @@ -1,5 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py ; RUN: opt -cost-model -analyze -mtriple=riscv64 -mattr=+experimental-v,+f,+d,+experimental-zfh -riscv-v-vector-bits-min=128 -riscv-v-fixed-length-vector-lmul-max=1 < %s 2>%t | FileCheck %s +; Sanity check that we don't crash querying costs when vectors are not enabled. +; RUN: opt -cost-model -analyze -mtriple=riscv64 define i32 @masked_scatter() { ; CHECK-LABEL: 'masked_scatter'