[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Sep 1 12:38:39 PDT 2005



Changes in directory llvm/lib/Target/PowerPC:

PPC32ISelDAGToDAG.cpp updated: 1.68 -> 1.69
---
Log message:

Fix a bug where we were useing HA to get the high part, which seems like it 
could cause a miscompile.  Fixing this didn't fix the two programs that fail
though.  :(

This also changes the implementation to follow the pattern selector more
closely, causing us to select 0 to li instead of lis.


---
Diffs of the changes:  (+10 -11)

 PPC32ISelDAGToDAG.cpp |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)


Index: llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp
diff -u llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.68 llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.69
--- llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.68	Thu Sep  1 14:20:44 2005
+++ llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp	Thu Sep  1 14:38:28 2005
@@ -685,22 +685,21 @@
   case ISD::Constant: {
     assert(N->getValueType(0) == MVT::i32);
     unsigned v = (unsigned)cast<ConstantSDNode>(N)->getValue();
-    unsigned Hi = HA16(v);
-    unsigned Lo = Lo16(v);
 
     // NOTE: This doesn't use SelectNodeTo, because doing that will prevent 
     // folding shared immediates into other the second instruction that 
     // uses it.
-    if (Hi && Lo) {
-      SDOperand Top = CurDAG->getTargetNode(PPC::LIS, MVT::i32, 
-                                            getI32Imm(v >> 16));
-      return CurDAG->getTargetNode(PPC::ORI, MVT::i32, Top, 
-                                   getI32Imm(v & 0xFFFF));
-    } else if (Lo) {
+    if (isInt16(v))
       return CurDAG->getTargetNode(PPC::LI, MVT::i32, getI32Imm(v));
-    } else {
-      return CurDAG->getTargetNode(PPC::LIS, MVT::i32, getI32Imm(v >> 16));
-    }
+
+    unsigned Hi = Hi16(v);
+    unsigned Lo = Lo16(v);
+
+    if (!Lo)
+      return CurDAG->getTargetNode(PPC::LIS, MVT::i32, getI32Imm(Hi));
+      
+    SDOperand Top = CurDAG->getTargetNode(PPC::LIS, MVT::i32, getI32Imm(Hi));
+    return CurDAG->getTargetNode(PPC::ORI, MVT::i32, Top, getI32Imm(Lo));
   }
   case ISD::UNDEF:
     if (N->getValueType(0) == MVT::i32)






More information about the llvm-commits mailing list