diff options
author | Evan Cheng <evan.cheng@apple.com> | 2006-04-06 23:20:43 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2006-04-06 23:20:43 +0000 |
commit | c04766a22832bd044bf3e1c3740415165b9400d6 (patch) | |
tree | 55af51dd3d3980e2ed284e147c4bff6ec895ebf3 /lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 3e2c745d0d75e31e5744376b954f752bfe30fbac (diff) |
1. If both vector operands of a vector_shuffle are undef, turn it into an undef.
2. A shuffle mask element can also be an undef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27472 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index a5925ad69c..d1dbd9ae09 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -2673,16 +2673,19 @@ SDOperand DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) { // If the LHS and the RHS are the same node, turn the RHS into an undef. if (N->getOperand(0) == N->getOperand(1)) { + if (N->getOperand(0).getOpcode() == ISD::UNDEF) + return DAG.getNode(ISD::UNDEF, N->getValueType(0)); // Check the SHUFFLE mask, mapping any inputs from the 2nd operand into the // first operand. std::vector<SDOperand> MappedOps; for (unsigned i = 0, e = ShufMask.getNumOperands(); i != e; ++i) { - if (cast<ConstantSDNode>(ShufMask.getOperand(i))->getValue() >= NumElts) { + if (ShufMask.getOperand(i).getOpcode() == ISD::UNDEF || + cast<ConstantSDNode>(ShufMask.getOperand(i))->getValue() < NumElts) { + MappedOps.push_back(ShufMask.getOperand(i)); + } else { unsigned NewIdx = cast<ConstantSDNode>(ShufMask.getOperand(i))->getValue() - NumElts; MappedOps.push_back(DAG.getConstant(NewIdx, MVT::i32)); - } else { - MappedOps.push_back(ShufMask.getOperand(i)); } } ShufMask = DAG.getNode(ISD::BUILD_VECTOR, ShufMask.getValueType(), |