diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-11-01 15:41:12 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-11-01 15:41:12 +0000 |
commit | c5fe3ce2ec8b44b2cbab6fe5dc50633492fbd80d (patch) | |
tree | 58d5d7f6194b3366743881f86b62d52cd832ffbf /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 29ca764492eaf5c44afde25dd7d17ca3dad8704e (diff) | |
download | bcm5719-llvm-c5fe3ce2ec8b44b2cbab6fe5dc50633492fbd80d.tar.gz bcm5719-llvm-c5fe3ce2ec8b44b2cbab6fe5dc50633492fbd80d.zip |
[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
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
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(), |