[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Evan Cheng evan.cheng at apple.com
Thu Apr 6 16:20:56 PDT 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

DAGCombiner.cpp updated: 1.144 -> 1.145
---
Log message:

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.


---
Diffs of the changes:  (+6 -3)

 DAGCombiner.cpp |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.144 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.145
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.144	Tue Apr  4 12:39:18 2006
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp	Thu Apr  6 18:20:43 2006
@@ -2673,16 +2673,19 @@
   
   // 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(),






More information about the llvm-commits mailing list