summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-04-06 23:20:43 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-04-06 23:20:43 +0000
commit613996c55e3010f0723cfa1d8716d74b858f6ba5 (patch)
tree19b2bab5476e71d6872fb37dbeee64a07aa582d5 /llvm/lib/CodeGen
parent1596a1b276f23f17fd5bc0ca7ea45484a75c85f1 (diff)
downloadbcm5719-llvm-613996c55e3010f0723cfa1d8716d74b858f6ba5.tar.gz
bcm5719-llvm-613996c55e3010f0723cfa1d8716d74b858f6ba5.zip
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. llvm-svn: 27472
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index a5925ad69c6..d1dbd9ae09f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/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(),
OpenPOWER on IntegriCloud