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

Chris Lattner lattner at cs.uiuc.edu
Sat May 6 16:05:53 PDT 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAG.cpp updated: 1.303 -> 1.304
---
Log message:

constant fold sign_extend_inreg


---
Diffs of the changes:  (+9 -1)

 SelectionDAG.cpp |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.303 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.304
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.303	Thu Apr 27 00:01:07 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp	Sat May  6 18:05:41 2006
@@ -1335,6 +1335,14 @@
   ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1.Val);
   ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N2.Val);
   if (N1C) {
+    if (Opcode == ISD::SIGN_EXTEND_INREG) {
+      int64_t Val = N1C->getValue();
+      unsigned FromBits = MVT::getSizeInBits(cast<VTSDNode>(N2)->getVT());
+      Val <<= 64-FromBits;
+      Val >>= 64-FromBits;
+      return getConstant(Val, VT);
+    }
+    
     if (N2C) {
       uint64_t C1 = N1C->getValue(), C2 = N2C->getValue();
       switch (Opcode) {
@@ -1441,7 +1449,7 @@
     }
   }
   
-  // Fold a bunch of operators that 
+  // Fold a bunch of operators when the RHS is undef. 
   if (N2.getOpcode() == ISD::UNDEF) {
     switch (Opcode) {
     case ISD::ADD:






More information about the llvm-commits mailing list