diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-11-14 17:24:49 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-11-14 17:24:49 +0000 |
commit | c81174515659e15f2907ec8ced09c6f775738dfa (patch) | |
tree | 87d673428f137a70351169aae1cc8f51e71b1d19 /lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp | |
parent | c9c6aa04454204000fae4120d3ce8455525a723f (diff) |
Don't need to load a NULL pointer constant from memory!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1305 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp')
-rw-r--r-- | lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp index cb3f9a1582..7fe3e60f7f 100644 --- a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp @@ -241,14 +241,22 @@ ChooseRegOrImmed(Value* val, return MachineOperand::MO_SignExtendedImmed; } - if (!CPV->getType()->isIntegral()) return opType; - + // Otherwise it needs to be an integer or a NULL pointer + if (! CPV->getType()->isIntegral() && + ! (CPV->getType()->isPointerType() && + CPV->isNullValue())) + return opType; + // Now get the constant value and check if it fits in the IMMED field. // Take advantage of the fact that the max unsigned value will rarely // fit into any IMMED field and ignore that case (i.e., cast smaller // unsigned constants to signed). // int64_t intValue; + if (CPV->getType()->isPointerType()) + { + intValue = 0; + } if (CPV->getType()->isSigned()) { intValue = ((ConstPoolSInt*)CPV)->getValue(); |