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

Chris Lattner lattner at cs.uiuc.edu
Tue Apr 12 19:58:29 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAG.cpp updated: 1.77 -> 1.78
---
Log message:

add back the optimization that Nate added for shl X, (zext_inreg y)


---
Diffs of the changes:  (+23 -2)

 SelectionDAG.cpp |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.77 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.78
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.77	Tue Apr 12 21:47:57 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp	Tue Apr 12 21:58:13 2005
@@ -943,8 +943,18 @@
   case ISD::SHL:
   case ISD::SRL:
   case ISD::SRA:
-    if (N2.getOpcode() == ISD::SIGN_EXTEND_INREG)
+    if (N2.getOpcode() == ISD::SIGN_EXTEND_INREG &&
+        cast<MVTSDNode>(N2)->getExtraValueType() != MVT::i1)
       return getNode(Opcode, VT, N1, N2.getOperand(0));
+    else if (N2.getOpcode() == ISD::AND)
+      if (ConstantSDNode *AndRHS = dyn_cast<ConstantSDNode>(N2.getOperand(1))) {
+        // If the and is only masking out bits that cannot effect the shift,
+        // eliminate the and.
+        unsigned NumBits = MVT::getSizeInBits(VT);
+        if ((AndRHS->getValue() & (NumBits-1)) == NumBits-1)
+          return getNode(Opcode, VT, N1, N2.getOperand(0));
+      }
+             
     break;
   }
 
@@ -1040,8 +1050,19 @@
   case ISD::SRA_PARTS:
   case ISD::SRL_PARTS:
   case ISD::SHL_PARTS:
-    if (N3.getOpcode() == ISD::SIGN_EXTEND_INREG)
+    if (N3.getOpcode() == ISD::SIGN_EXTEND_INREG &&
+        cast<MVTSDNode>(N3)->getExtraValueType() != MVT::i1)
       return getNode(Opcode, VT, N1, N2, N3.getOperand(0));
+    else if (N3.getOpcode() == ISD::AND)
+      if (ConstantSDNode *AndRHS = dyn_cast<ConstantSDNode>(N3.getOperand(1))) {
+        // If the and is only masking out bits that cannot effect the shift,
+        // eliminate the and.
+        unsigned NumBits = MVT::getSizeInBits(VT)*2;
+        if ((AndRHS->getValue() & (NumBits-1)) == NumBits-1)
+          return getNode(Opcode, VT, N1, N2, N3.getOperand(0));
+      }
+
+
     break;
   }
 






More information about the llvm-commits mailing list