OSDN Git Service

better constant handling, should fix many remaining cases
authorAndrew Lenharth <andrewl@lenharth.org>
Wed, 2 Feb 2005 00:51:15 +0000 (00:51 +0000)
committerAndrew Lenharth <andrewl@lenharth.org>
Wed, 2 Feb 2005 00:51:15 +0000 (00:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19984 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Alpha/AlphaISelPattern.cpp

index dcd2407..e8de3c8 100644 (file)
@@ -1021,8 +1021,17 @@ unsigned ISel::SelectExpr(SDOperand N) {
 
   case ISD::Constant:
     {
-      long val = cast<ConstantSDNode>(N)->getValue();
-      BuildMI(BB, Alpha::LOAD_IMM, 1, Result).addImm(val);
+      unsigned long val = cast<ConstantSDNode>(N)->getValue();
+      if (val < 32000 && (long)val > -32000)
+       BuildMI(BB, Alpha::LOAD_IMM, 1, Result).addImm(val);
+      else
+       {
+         MachineConstantPool *CP = BB->getParent()->getConstantPool();
+         ConstantUInt *C = ConstantUInt::get(Type::getPrimitiveType(Type::ULongTyID) , val);
+         unsigned CPI = CP->getConstantPoolIndex(C);
+         AlphaLowering.restoreGP(BB);
+         BuildMI(BB, Alpha::LOAD, 1, Result).addConstantPoolIndex(CPI);
+       }
       return Result;
     }