diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-09-27 14:26:20 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-09-27 14:26:20 +0000 |
commit | 66303bb9a5c72bbc0650d073f8c054d1f92d9337 (patch) | |
tree | bdc44bc7820dab0751e872123cc68a4f7abcd55c /llvm/lib/CodeGen | |
parent | 46aeb8c7c2e2e65b79c7b9e592dda9f2ff96a81c (diff) | |
download | bcm5719-llvm-66303bb9a5c72bbc0650d073f8c054d1f92d9337.tar.gz bcm5719-llvm-66303bb9a5c72bbc0650d073f8c054d1f92d9337.zip |
Sign-extend integer constants from original type size to 64 bits!
llvm-svn: 3958
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp b/llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp index 508c0b6e5e0..a8f14e20bca 100644 --- a/llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp +++ b/llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp @@ -373,11 +373,15 @@ ChooseRegOrImmed(Value* val, 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(), |