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

Vikram Adve vadve at cs.uiuc.edu
Fri Sep 27 09:27:00 PDT 2002


Changes in directory llvm/lib/CodeGen/InstrSelection:

InstrSelectionSupport.cpp updated: 1.32 -> 1.33

---
Log message:

Sign-extend integer constants from original type size to 64 bits!


---
Diffs of the changes:

Index: llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp
diff -u llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.32 llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.33
--- llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.32	Tue Sep 17 12:23:09 2002
+++ llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp	Fri Sep 27 09:26:20 2002
@@ -373,11 +373,15 @@
   else if (CPV->getType()->isSigned())
     intValue = cast<ConstantSInt>(CPV)->getValue();
   else
-    {
-      assert(CPV->getType()->isUnsigned() && "Not pointer, bool, or integer?");
-      uint64_t V = cast<ConstantUInt>(CPV)->getValue();
-      if (V >= INT64_MAX) return MachineOperand::MO_VirtualRegister;
-      intValue = (int64_t) V;
+    { // get the int value and sign-extend if original was less than 64 bits
+      intValue = (int64_t) cast<ConstantUInt>(CPV)->getValue();
+      switch(CPV->getType()->getPrimitiveID())
+        {
+        case Type::UByteTyID:  intValue = (int64_t) (int8_t) intValue; break;
+        case Type::UShortTyID: intValue = (int64_t) (short)  intValue; break;
+        case Type::UIntTyID:   intValue = (int64_t) (int)    intValue; break;
+        default: break;
+        }
     }
 
   return ChooseRegOrImmed(intValue, CPV->getType()->isSigned(),





More information about the llvm-commits mailing list