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 | c1b534043f800da29cc3457ce2c1895a249b273e (patch) | |
tree | c0c317e07b6d30005c6bfa2e4a8c835acba73de9 | |
parent | ea1a93b95d30ce138420b6a740bb8d1bd274470c (diff) | |
download | bcm5719-llvm-c1b534043f800da29cc3457ce2c1895a249b273e.tar.gz bcm5719-llvm-c1b534043f800da29cc3457ce2c1895a249b273e.zip |
Don't need to load a NULL pointer constant from memory!
llvm-svn: 1305
-rw-r--r-- | llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp b/llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp index cb3f9a15822..7fe3e60f7fc 100644 --- a/llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp +++ b/llvm/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(); |