Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp =================================================================== --- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -12375,6 +12375,9 @@ SelectionDAG &DAG = DCI.DAG; EVT VT = N->getValueType(0); + if (VT.isScalableVector()) + return SDValue(); + unsigned LoadIdx = IsLaneOp ? 1 : 0; SDNode *LD = N->getOperand(LoadIdx).getNode(); // If it is not LOAD, can not do such combine. Index: llvm/test/CodeGen/AArch64/sve-ld-post-inc.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/AArch64/sve-ld-post-inc.ll @@ -0,0 +1,25 @@ +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s + +; These tests are here to ensure we don't get a selection error caused +; by performPostLD1Combine, which should bail out if the return +; type is a scalable vector + +define @test_post_ld1_insert(i32* %a, i32** %ptr, i64 %inc) { +; CHECK-LABEL: test_post_ld1_insert: + %load = load i32, i32* %a + %ins = insertelement undef, i32 %load, i32 0 + %gep = getelementptr i32, i32* %a, i64 %inc + store i32* %gep, i32** %ptr + ret %ins +} + +define @test_post_ld1_dup(double* %a, double** %ptr, i64 %inc) { +; CHECK-LABEL: test_post_ld1_dup: + %load = load double, double* %a + %dup = call @llvm.aarch64.sve.dup.x.nxv2f64(double %load) + %gep = getelementptr double, double* %a, i64 %inc + store double* %gep, double** %ptr + ret %dup +} + +declare @llvm.aarch64.sve.dup.x.nxv2f64(double)