diff options
| author | Nadav Rotem <nadav.rotem@intel.com> | 2012-04-02 07:11:12 +0000 |
|---|---|---|
| committer | Nadav Rotem <nadav.rotem@intel.com> | 2012-04-02 07:11:12 +0000 |
| commit | 702f080767c5769af35cc8d885a5143240f51997 (patch) | |
| tree | b8452b8f368c9495540041541975a37013357809 /llvm/lib/CodeGen | |
| parent | dab9e35ad05afef53e15e57462a0b85943a64735 (diff) | |
| download | bcm5719-llvm-702f080767c5769af35cc8d885a5143240f51997.tar.gz bcm5719-llvm-702f080767c5769af35cc8d885a5143240f51997.zip | |
Optimizing swizzles of complex shuffles may generate additional complex shuffles.
Do not try to optimize swizzles of shuffles if the source shuffle has more than
a single user, except when the source shuffle is also a swizzle.
llvm-svn: 153864
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 5e88fcbb0e1..08946070b44 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -7792,6 +7792,14 @@ SDValue DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) { SmallVector<int, 8> NewMask; ShuffleVectorSDNode *OtherSV = cast<ShuffleVectorSDNode>(N0); + // If the source shuffle has more than one user then do not try to optimize + // it because it may generate a more complex shuffle node. However, if the + // source shuffle is also a swizzle (a single source shuffle), our + // transformation is still likely to reduce the number of shuffles and only + // generate a simple shuffle node. + if (N0.getOperand(1).getOpcode() != ISD::UNDEF && !N0.hasOneUse()) + return SDValue(); + EVT InVT = N0.getValueType(); int InNumElts = InVT.getVectorNumElements(); @@ -7808,7 +7816,7 @@ SDValue DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) { NewMask.push_back(Idx); } - + assert(NewMask.size() == VT.getVectorNumElements() && "Invalid mask size"); return DAG.getVectorShuffle(VT, N->getDebugLoc(), OtherSV->getOperand(0), OtherSV->getOperand(1), &NewMask[0]); } |

