diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp --- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp @@ -207,8 +207,7 @@ // FIXME: Only supporting fixed vectors for now. if (!isa(DataTy)) - return BaseT::getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask, - Alignment, CostKind, I); + return InstructionCost::getInvalid(); auto *VTy = cast(DataTy); unsigned NumLoads = VTy->getNumElements(); diff --git a/llvm/test/Transforms/LoopVectorize/RISCV/masked_gather_scatter.ll b/llvm/test/Transforms/LoopVectorize/RISCV/masked_gather_scatter.ll --- a/llvm/test/Transforms/LoopVectorize/RISCV/masked_gather_scatter.ll +++ b/llvm/test/Transforms/LoopVectorize/RISCV/masked_gather_scatter.ll @@ -2,6 +2,10 @@ ; RUN: opt < %s -loop-vectorize -mtriple=riscv32 -mattr=+v,+d -riscv-v-vector-bits-min=256 -S | FileCheck %s -check-prefixes=RV32 ; RUN: opt < %s -loop-vectorize -mtriple=riscv64 -mattr=+v,+d -riscv-v-vector-bits-min=256 -S | FileCheck %s -check-prefixes=RV64 +; Check that we don't crash when scalable-vectorization=on. +; RUN: opt < %s -loop-vectorize -mtriple=riscv32 -mattr=+v,+d -scalable-vectorization=on -S +; RUN: opt < %s -loop-vectorize -mtriple=riscv64 -mattr=+v,+d -scalable-vectorization=on -S + ; The source code: ; ;void foo4(double *A, double *B, int *trigger) {