From c5fe3ce2ec8b44b2cbab6fe5dc50633492fbd80d Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Thu, 1 Nov 2018 15:41:12 +0000 Subject: [DAGCombiner] make sure we have a whole-number extract before trying to narrow a vector op (PR39511) The test causes a crash because we were trying to extract v4f32 to v3f32, and the narrowing factor was then 4/3 = 1 producing a bogus narrow type. This should fix: https://bugs.llvm.org/show_bug.cgi?id=39511 llvm-svn: 345842 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen') diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index e6ea4898717..d0c898f2e97 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -16708,10 +16708,14 @@ static SDValue narrowExtractedVectorBinOp(SDNode *Extract, SelectionDAG &DAG) { 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(), -- cgit v1.2.3