diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 8cab6aaf1a2..d353dc241d1 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -15188,6 +15188,10 @@ SDValue DAGCombiner::visitCONCAT_VECTORS(SDNode *N) { if (!SclTy.isFloatingPoint() && !SclTy.isInteger()) return SDValue(); + // Bail out if the vector size is not a multiple of the scalar size. + if (VT.getSizeInBits() % SclTy.getSizeInBits()) + return SDValue(); + unsigned VNTNumElms = VT.getSizeInBits() / SclTy.getSizeInBits(); if (VNTNumElms < 2) return SDValue(); diff --git a/test/CodeGen/AMDGPU/concat_vectors.ll b/test/CodeGen/AMDGPU/concat_vectors.ll index 7394842d156..e8d98ba8935 100644 --- a/test/CodeGen/AMDGPU/concat_vectors.ll +++ b/test/CodeGen/AMDGPU/concat_vectors.ll @@ -294,3 +294,15 @@ bb: store <8 x float> %tmp2, <8 x float> addrspace(1)* %out, align 32 ret void } + +; FUNC-LABEL: {{^}}concat_vector_crash2: +; SI: s_endpgm +define amdgpu_kernel void @concat_vector_crash2(<8 x i8> addrspace(1)* %out, i32 addrspace(1)* %in) { + %tmp = load i32, i32 addrspace(1)* %in, align 1 + %tmp1 = trunc i32 %tmp to i24 + %tmp2 = bitcast i24 %tmp1 to <3 x i8> + %tmp3 = shufflevector <3 x i8> %tmp2, <3 x i8> undef, <8 x i32> + %tmp4 = shufflevector <8 x i8> %tmp3, <8 x i8> , <8 x i32> + store <8 x i8> %tmp4, <8 x i8> addrspace(1)* %out, align 8 + ret void +}