diff --git a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp index 8f35be8a07d..ff214500dbc 100644 --- a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp @@ -91,9 +91,10 @@ ChooseRegOrImmed(Value* val, // To use reg or immed, constant needs to be integer, bool, or a NULL pointer Constant *CPV = dyn_cast(val); - if (CPV == NULL || - (! CPV->getType()->isIntegral() && - ! (isa(CPV->getType()) && CPV->isNullValue()))) + if (CPV == NULL + || CPV->isConstantExpr() + || (! CPV->getType()->isIntegral() && + ! (isa(CPV->getType()) && CPV->isNullValue()))) return MachineOperand::MO_VirtualRegister; // Now get the constant value and check if it fits in the IMMED field. diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp index 8f35be8a07d..ff214500dbc 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp @@ -91,9 +91,10 @@ ChooseRegOrImmed(Value* val, // To use reg or immed, constant needs to be integer, bool, or a NULL pointer Constant *CPV = dyn_cast(val); - if (CPV == NULL || - (! CPV->getType()->isIntegral() && - ! (isa(CPV->getType()) && CPV->isNullValue()))) + if (CPV == NULL + || CPV->isConstantExpr() + || (! CPV->getType()->isIntegral() && + ! (isa(CPV->getType()) && CPV->isNullValue()))) return MachineOperand::MO_VirtualRegister; // Now get the constant value and check if it fits in the IMMED field.