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

Jim Laskey jlaskey at apple.com
Thu Aug 18 11:58:34 PDT 2005



Changes in directory llvm/lib/Target/PowerPC:

PPC32ISelPattern.cpp updated: 1.153 -> 1.154
---
Log message:

More optimal solution for loading constants.



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

 PPC32ISelPattern.cpp |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)


Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp
diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.153 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.154
--- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.153	Thu Aug 18 13:14:49 2005
+++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp	Thu Aug 18 13:58:23 2005
@@ -1719,16 +1719,18 @@
     assert(N.getValueType() == MVT::i32 &&
            "Only i32 constants are legal on this target!");
     unsigned v = (unsigned)cast<ConstantSDNode>(N)->getValue();
-    unsigned Hi = HA16(v);
-    unsigned Lo = Lo16(v);
-    if (Hi && Lo) {
-      Tmp1 = MakeIntReg();
-      BuildMI(BB, PPC::LIS, 1, Tmp1).addSImm(v >> 16);
-      BuildMI(BB, PPC::ORI, 2, Result).addReg(Tmp1).addImm(Lo);
-    } else if (Hi) {
-      BuildMI(BB, PPC::LIS, 1, Result).addSImm(v >> 16);
+    if (isInt16(v)) {
+      BuildMI(BB, PPC::LI, 1, Result).addSImm(Lo16(v));
     } else {
-      BuildMI(BB, PPC::LI, 1, Result).addSImm(Lo);
+      unsigned Hi = Hi16(v);
+      unsigned Lo = Lo16(v);
+      if (Lo) {
+        Tmp1 = MakeIntReg();
+        BuildMI(BB, PPC::LIS, 1, Tmp1).addSImm(Hi);
+        BuildMI(BB, PPC::ORI, 2, Result).addReg(Tmp1).addImm(Lo);
+      } else {
+        BuildMI(BB, PPC::LIS, 1, Result).addSImm(Hi);
+      }
     }
     return Result;
   }






More information about the llvm-commits mailing list