assert(ExtractIndex % NumElems == 0 &&
"Extract index is not a multiple of the vector length.");
EVT SrcVT = Extract->getOperand(0).getValueType();
+
+ // Bail out if this is not a proper multiple width extraction.
unsigned NumSrcElems = SrcVT.getVectorNumElements();
- unsigned NarrowingRatio = NumSrcElems / NumElems;
+ if (NumSrcElems % NumElems != 0)
+ return SDValue();
// Bail out if the target does not support a narrower version of the binop.
+ unsigned NarrowingRatio = NumSrcElems / NumElems;
unsigned BOpcode = BinOp.getOpcode();
unsigned WideNumElts = WideBVT.getVectorNumElements();
EVT NarrowBVT = EVT::getVectorVT(*DAG.getContext(), WideBVT.getScalarType(),
ret <4 x i32> %sub
}
+; When extracting from a vector binop, the source width should be a multiple of the destination width.
+; https://bugs.llvm.org/show_bug.cgi?id=39511
+
+define <3 x float> @PR39511(<4 x float> %t0, <3 x float>* %b) {
+; SSE-LABEL: PR39511:
+; SSE: # %bb.0:
+; SSE-NEXT: addps {{.*}}(%rip), %xmm0
+; SSE-NEXT: retq
+;
+; AVX-LABEL: PR39511:
+; AVX: # %bb.0:
+; AVX-NEXT: vaddps {{.*}}(%rip), %xmm0, %xmm0
+; AVX-NEXT: retq
+ %add = fadd <4 x float> %t0, <float 1.0, float 2.0, float 3.0, float 4.0>
+ %ext = shufflevector <4 x float> %add, <4 x float> undef, <3 x i32> <i32 0, i32 1, i32 2>
+ ret <3 x float> %ext
+}
+