Simplify code by using ConstantInt::getRawValue instead of checking to see
whether the constant is signed or unsigned, then casting
llvm-svn: 7252
diff --git a/llvm/lib/Target/Sparc/SparcInstrInfo.cpp b/llvm/lib/Target/Sparc/SparcInstrInfo.cpp
index 75bea0d..39d6dcc 100644
--- a/llvm/lib/Target/Sparc/SparcInstrInfo.cpp
+++ b/llvm/lib/Target/Sparc/SparcInstrInfo.cpp
@@ -43,10 +43,8 @@
if (isa<Constant>(V))
if (const ConstantBool *CB = dyn_cast<ConstantBool>(V))
return (int64_t)CB->getValue();
- else if (const ConstantSInt *CS = dyn_cast<ConstantSInt>(V))
- return (uint64_t)CS->getValue();
- else if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(V))
- return CU->getValue();
+ else if (const ConstantInt *CI = dyn_cast<ConstantInt>(V))
+ return CI->getRawValue();
isValidConstant = false;
return 0;
@@ -377,15 +375,11 @@
if (isa<ConstantPointerNull>(CV)) // can always use %g0
return false;
- if (const ConstantUInt* U = dyn_cast<ConstantUInt>(CV))
- /* 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()) > MaxConstantsTable[I->getOpcode()]);
+ if (const ConstantInt* CI = dyn_cast<ConstantInt>(CV))
+ return labs((int64_t)CI->getRawValue()) > MaxConstantsTable[I->getOpcode()];
if (isa<ConstantBool>(CV))
- return (1 > MaxConstantsTable[I->getOpcode()]);
+ return 1 > MaxConstantsTable[I->getOpcode()];
return true;
}