Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -20266,7 +20266,15 @@ // Replace a SCALAR_TO_VECTOR(EXTRACT_VECTOR_ELT(V,C0)) pattern // with a VECTOR_SHUFFLE and possible truncate. - if (InVal.getOpcode() == ISD::EXTRACT_VECTOR_ELT) { + + // We currently only perform this optimisation for fixed length vectors as + // the code assumes we know the vector length. In theory, we could do + // something similar using SPLAT_VECTORs for scalable vector types when + // extracting from an index less than the minimum number of elements. + // However, since we don't know if this is even profitable or not it seems + // better to bail out for now. + if (InVal.getOpcode() == ISD::EXTRACT_VECTOR_ELT && + InVal->getOperand(0).getValueType().isFixedLengthVector()) { SDValue InVec = InVal->getOperand(0); SDValue EltNo = InVal->getOperand(1); auto InVecT = InVec.getValueType(); Index: llvm/test/CodeGen/AArch64/sve-fp.ll =================================================================== --- llvm/test/CodeGen/AArch64/sve-fp.ll +++ llvm/test/CodeGen/AArch64/sve-fp.ll @@ -123,6 +123,19 @@ ret %res } +%complex = type { { double, double } } + +define void @scalar_to_vector(%complex* %outval, %pred, %in1, %in2) { +; CHECK-LABEL: foo1: + %realp = getelementptr inbounds %complex, %complex* %outval, i64 0, i32 0, i32 0 + %imagp = getelementptr inbounds %complex, %complex* %outval, i64 0, i32 0, i32 1 + %1 = call double @llvm.aarch64.sve.faddv.nxv2f64( %pred, %in1) + %2 = call double @llvm.aarch64.sve.faddv.nxv2f64( %pred, %in2) + store double %1, double* %realp, align 8 + store double %2, double* %imagp, align 8 + ret void +} + declare @llvm.aarch64.sve.frecps.x.nxv8f16(, ) declare @llvm.aarch64.sve.frecps.x.nxv4f32( , ) declare @llvm.aarch64.sve.frecps.x.nxv2f64(, ) @@ -130,3 +143,6 @@ declare @llvm.aarch64.sve.frsqrts.x.nxv8f16(, ) declare @llvm.aarch64.sve.frsqrts.x.nxv4f32(, ) declare @llvm.aarch64.sve.frsqrts.x.nxv2f64(, ) + +; Function Attrs: nounwind readnone +declare double @llvm.aarch64.sve.faddv.nxv2f64(, ) #2