diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp index 044805a3541c8..08c4fa98962b3 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp @@ -5394,7 +5394,8 @@ SDValue DAGTypeLegalizer::GenWidenVectorLoads(SmallVectorImpl &LdChain, TypeSize WidthDiff = WidenWidth - LdWidth; // Allow wider loads if they are sufficiently aligned to avoid memory faults // and if the original load is simple. - unsigned LdAlign = (!LD->isSimple()) ? 0 : LD->getAlignment(); + unsigned LdAlign = + (!LD->isSimple() || LdVT.isScalableVector()) ? 0 : LD->getAlignment(); // Find the vector type that can load from. EVT NewVT = FindMemType(DAG, TLI, LdWidth.getKnownMinSize(), WidenVT, LdAlign, diff --git a/llvm/test/CodeGen/RISCV/rvv/legalize-load-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/legalize-load-sdnode.ll new file mode 100644 index 0000000000000..7676b2977d9b3 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/legalize-load-sdnode.ll @@ -0,0 +1,16 @@ +; RUN: not --crash llc -mtriple=riscv32 -mattr=+m,+experimental-v,+experimental-zfh,+f,+d -verify-machineinstrs < %s +; RUN: not --crash llc -mtriple=riscv64 -mattr=+m,+experimental-v,+experimental-zfh,+f,+d -verify-machineinstrs < %s + +; Check that we are able to legalize scalable-vector loads that require widening. + +; FIXME: LLVM can't yet widen scalable-vector loads. + +define @load_nxv3i8(* %ptr) { + %v = load , * %ptr + ret %v +} + +define @load_nxv5f16(* %ptr) { + %v = load , * %ptr + ret %v +} diff --git a/llvm/test/CodeGen/RISCV/rvv/legalize-store-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/legalize-store-sdnode.ll new file mode 100644 index 0000000000000..2c52e1bff9c72 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/legalize-store-sdnode.ll @@ -0,0 +1,16 @@ +; RUN: not --crash llc -mtriple=riscv32 -mattr=+m,+experimental-v,+experimental-zfh,+f,+d -verify-machineinstrs < %s +; RUN: not --crash llc -mtriple=riscv64 -mattr=+m,+experimental-v,+experimental-zfh,+f,+d -verify-machineinstrs < %s + +; Check that we are able to legalize scalable-vector stores that require widening. + +; FIXME: LLVM can't yet widen scalable-vector stores. + +define void @store_nxv3i8( %val, * %ptr) { + store %val, * %ptr + ret void +} + +define void @store_nxv7f64( %val, * %ptr) { + store %val, * %ptr + ret void +}