[llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrInfo.cpp
Vikram Adve
vadve at cs.uiuc.edu
Sat Oct 12 19:05:01 PDT 2002
Changes in directory llvm/lib/Target/Sparc:
SparcInstrInfo.cpp updated: 1.28 -> 1.29
---
Log message:
Make sure to handle small negative values hiding as large unsigned longs --
this is a common case created by the front-end.
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/SparcInstrInfo.cpp
diff -u llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.28 llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.29
--- llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.28 Fri Sep 27 09:29:45 2002
+++ llvm/lib/Target/Sparc/SparcInstrInfo.cpp Sat Oct 12 19:04:26 2002
@@ -266,7 +266,7 @@
// Entry == 0 ==> no immediate constant field exists at all.
// Entry > 0 ==> abs(immediate constant) <= Entry
//
-vector<unsigned int> MaxConstantsTable(Instruction::NumOtherOps);
+vector<int> MaxConstantsTable(Instruction::NumOtherOps);
static int
MaxConstantForInstr(unsigned llvmOpCode)
@@ -343,13 +343,14 @@
return false;
if (const ConstantUInt* U = dyn_cast<ConstantUInt>(CV))
- return (U->getValue() > MaxConstantsTable[I->getOpcode()]);
+ /* Large unsigned longs may really just be small negative signed longs */
+ return (labs((int64_t) U->getValue()) > MaxConstantsTable[I->getOpcode()]);
if (const ConstantSInt* S = dyn_cast<ConstantSInt>(CV))
- return (labs(S->getValue()) > (int) MaxConstantsTable[I->getOpcode()]);
+ return (labs(S->getValue()) > MaxConstantsTable[I->getOpcode()]);
if (isa<ConstantBool>(CV))
- return (1U > MaxConstantsTable[I->getOpcode()]);
+ return (1 > MaxConstantsTable[I->getOpcode()]);
return true;
}
@@ -380,6 +381,11 @@
//
const Type* valType = val->getType();
+ // Unfortunate special case: a ConstantPointerRef is just a
+ // reference to GlobalValue.
+ if (isa<ConstantPointerRef>(val))
+ val = cast<ConstantPointerRef>(val)->getValue();
+
if (isa<GlobalValue>(val))
{
TmpInstruction* tmpReg =
More information about the llvm-commits
mailing list