diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -6711,6 +6711,8 @@ "Dest and insert subvector source types must match!"); assert(VT.isVector() && N2VT.isVector() && "Insert subvector VTs must be vectors!"); + assert(VT.getVectorElementType() == N2VT.getVectorElementType() && + "Insert subvector VTs must have the same element type!"); assert((VT.isScalableVector() || N2VT.isFixedLengthVector()) && "Cannot insert a scalable vector into a fixed length vector!"); assert((VT.isScalableVector() != N2VT.isScalableVector() || diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -23619,10 +23619,10 @@ Val = DAG.getNode(IsSigned ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND, DL, VT.changeTypeToInteger(), Val); - Val = convertToScalableVector(DAG, ContainerSrcVT, Val); - Val = getSVESafeBitCast(ContainerDstVT.changeTypeToInteger(), Val, DAG); - // Safe to use a larger than specified operand since we just unpacked the - // data, hence the upper bits are zero. + // Safe to use a larger than specified operand because by promoting the + // value nothing has changed from an arithmetic point of view. + Val = + convertToScalableVector(DAG, ContainerDstVT.changeTypeToInteger(), Val); Val = DAG.getNode(Opcode, DL, ContainerDstVT, Pg, Val, DAG.getUNDEF(ContainerDstVT)); return convertFromScalableVector(DAG, VT, Val); @@ -23665,7 +23665,7 @@ Val = DAG.getNode(ISD::BITCAST, DL, SrcVT.changeTypeToInteger(), Val); Val = DAG.getNode(ISD::ANY_EXTEND, DL, VT, Val); - Val = convertToScalableVector(DAG, ContainerSrcVT, Val); + Val = convertToScalableVector(DAG, ContainerDstVT, Val); Val = getSVESafeBitCast(CvtVT, Val, DAG); Val = DAG.getNode(Opcode, DL, ContainerDstVT, Pg, Val, DAG.getUNDEF(ContainerDstVT)); diff --git a/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-int-to-fp.ll b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-int-to-fp.ll --- a/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-int-to-fp.ll +++ b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-int-to-fp.ll @@ -182,8 +182,8 @@ ; CHECK-NEXT: uunpklo z3.d, z0.s ; CHECK-NEXT: ext z0.b, z0.b, z0.b, #8 ; CHECK-NEXT: uunpklo z0.d, z0.s -; CHECK-NEXT: ucvtf z3.d, p0/m, z3.d ; CHECK-NEXT: ext z1.b, z1.b, z1.b, #8 +; CHECK-NEXT: ucvtf z3.d, p0/m, z3.d ; CHECK-NEXT: ucvtf z0.d, p0/m, z0.d ; CHECK-NEXT: ucvtf z2.d, p0/m, z2.d ; CHECK-NEXT: uunpklo z1.d, z1.s @@ -758,8 +758,8 @@ ; CHECK-NEXT: sunpklo z3.d, z0.s ; CHECK-NEXT: ext z0.b, z0.b, z0.b, #8 ; CHECK-NEXT: sunpklo z0.d, z0.s -; CHECK-NEXT: scvtf z3.d, p0/m, z3.d ; CHECK-NEXT: ext z1.b, z1.b, z1.b, #8 +; CHECK-NEXT: scvtf z3.d, p0/m, z3.d ; CHECK-NEXT: scvtf z0.d, p0/m, z0.d ; CHECK-NEXT: scvtf z2.d, p0/m, z2.d ; CHECK-NEXT: sunpklo z1.d, z1.s