From 2a7049abe0ad0ff5c92386fad3cbc90f65cb6788 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sun, 23 Aug 2015 15:22:14 +0000 Subject: [DAGCombiner] Fold CONCAT_VECTORS of bitcasted EXTRACT_SUBVECTOR Minor generalization of D12125 - peek through any bitcast to the original vector that we're extracting from. llvm-svn: 245814 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp') diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index ab3a6631d33..607c3bf2336 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -2285,7 +2285,7 @@ SDValue DAGCombiner::visitUDIV(SDNode *N) { } } } - + // fold (udiv x, c) -> alternate bool MinSize = DAG.getMachineFunction().getFunction()->optForMinSize(); if (N1C && !TLI.isIntDivCheap(N->getValueType(0), MinSize)) @@ -12270,12 +12270,21 @@ static SDValue combineConcatVectorOfExtracts(SDNode *N, SelectionDAG &DAG) { // What vector are we extracting the subvector from and at what index? SDValue ExtVec = Op.getOperand(0); + + // We want the EVT of the original extraction to correctly scale the + // extraction index. + EVT ExtVT = ExtVec.getValueType(); + + // Peek through any bitcast. + while (ExtVec.getOpcode() == ISD::BITCAST) + ExtVec = ExtVec.getOperand(0); + + // UNDEF nodes convert to UNDEF shuffle mask values. if (ExtVec.getOpcode() == ISD::UNDEF) { Mask.append((unsigned)NumOpElts, -1); continue; } - EVT ExtVT = ExtVec.getValueType(); if (!isa(Op.getOperand(1))) return SDValue(); int ExtIdx = cast(Op.getOperand(1))->getZExtValue(); -- cgit v1.2.3