Don't need to load a NULL pointer constant from memory!

llvm-svn: 1305
This commit is contained in:
Vikram S. Adve 2001-11-14 17:24:49 +00:00
parent ea1a93b95d
commit c1b534043f
1 changed files with 10 additions and 2 deletions

View File

@ -241,7 +241,11 @@ 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
@ -249,6 +253,10 @@ ChooseRegOrImmed(Value* val,
// unsigned constants to signed).
//
int64_t intValue;
if (CPV->getType()->isPointerType())
{
intValue = 0;
}
if (CPV->getType()->isSigned())
{
intValue = ((ConstPoolSInt*)CPV)->getValue();