[llvm-commits] [llvm] r60865 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Mon P Wang wangmp at apple.com
Wed Dec 10 16:26:24 PST 2008


Author: wangmp
Date: Wed Dec 10 18:26:16 2008
New Revision: 60865

URL: http://llvm.org/viewvc/llvm-project?rev=60865&view=rev
Log:
Make fix for r60829 less conservative to allow the proper optimization for
vec_extract-sse4.ll.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=60865&r1=60864&r2=60865&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed Dec 10 18:26:16 2008
@@ -4884,14 +4884,16 @@
   if (isa<ConstantSDNode>(EltNo)) {
     unsigned Elt = cast<ConstantSDNode>(EltNo)->getZExtValue();
     bool NewLoad = false;
+    bool BCNumEltsChanged = false;
     MVT VT = InVec.getValueType();
     MVT EVT = VT.getVectorElementType();
     MVT LVT = EVT;
     if (InVec.getOpcode() == ISD::BIT_CONVERT) {
       MVT BCVT = InVec.getOperand(0).getValueType();
-      if (!BCVT.isVector() || EVT.bitsGT(BCVT.getVectorElementType()) ||
-          VT.getVectorNumElements() != BCVT.getVectorNumElements())
+      if (!BCVT.isVector() || EVT.bitsGT(BCVT.getVectorElementType()))
         return SDValue();
+      if (VT.getVectorNumElements() != BCVT.getVectorNumElements())
+        BCNumEltsChanged = true;
       InVec = InVec.getOperand(0);
       EVT = BCVT.getVectorElementType();
       NewLoad = true;
@@ -4908,6 +4910,11 @@
       // (vextract (vector_shuffle (load $addr), v2, <1, u, u, u>), 1)
       // =>
       // (load $addr+1*size)
+      
+      // If the bit convert changed the number of elements, it is unsafe
+      // to examine the mask.
+      if (BCNumEltsChanged)
+        return SDValue();
       unsigned Idx = cast<ConstantSDNode>(InVec.getOperand(2).
                                           getOperand(Elt))->getZExtValue();
       unsigned NumElems = InVec.getOperand(2).getNumOperands();





More information about the llvm-commits mailing list