[llvm-branch-commits] [llvm-branch] r95081 - in /llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG: DAGCombiner.cpp SelectionDAG.cpp

Bill Wendling isanbard at gmail.com
Tue Feb 2 03:08:10 PST 2010


Author: void
Date: Tue Feb  2 05:08:10 2010
New Revision: 95081

URL: http://llvm.org/viewvc/llvm-project?rev=95081&view=rev
Log:
$ svn merge -c 94990 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r94990 into '.':
U    lib/CodeGen/SelectionDAG/SelectionDAG.cpp
U    lib/CodeGen/SelectionDAG/DAGCombiner.cpp


Modified:
    llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Modified: llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=95081&r1=95080&r2=95081&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Feb  2 05:08:10 2010
@@ -5415,12 +5415,19 @@
   SDValue InVec = N->getOperand(0);
 
  if (InVec.getOpcode() == ISD::SCALAR_TO_VECTOR) {
-   // If the operand is wider than the vector element type then it is implicitly
-   // truncated.  Make that explicit here.
+   // Check if the result type doesn't match the inserted element type. A
+   // SCALAR_TO_VECTOR may truncate the inserted element and the
+   // EXTRACT_VECTOR_ELT may widen the extracted vector.
    EVT EltVT = InVec.getValueType().getVectorElementType();
    SDValue InOp = InVec.getOperand(0);
-   if (InOp.getValueType() != EltVT)
-     return DAG.getNode(ISD::TRUNCATE, InVec.getDebugLoc(), EltVT, InOp);
+   EVT NVT = N->getValueType(0);
+   if (InOp.getValueType() != NVT) {
+     assert(InOp.getValueType().isInteger() && NVT.isInteger());
+     if (NVT.getSizeInBits() > InOp.getValueType().getSizeInBits())
+       return DAG.getNode(ISD::SIGN_EXTEND, InVec.getDebugLoc(), NVT, InOp);
+     else
+       return DAG.getNode(ISD::TRUNCATE, InVec.getDebugLoc(), NVT, InOp);
+   }
    return InOp;
  }
 

Modified: llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=95081&r1=95080&r2=95081&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Feb  2 05:08:10 2010
@@ -2728,7 +2728,7 @@
     // operations are lowered to scalars.
     if (N1.getOpcode() == ISD::INSERT_VECTOR_ELT) {
       // If the indices are the same, return the inserted element.
-      if (N1.getOperand(2) == N2)
+      if (N1.getOperand(2) == N2 && VT == N1.getOperand(1).getValueType())
         return N1.getOperand(1);
       // If the indices are known different, extract the element from
       // the original vector.





More information about the llvm-branch-commits mailing list