Unify all constant evaluations that depend on register size
in ConvertConstantToIntType.
llvm-svn: 7395
diff --git a/llvm/lib/Target/Sparc/SparcInstrSelection.cpp b/llvm/lib/Target/Sparc/SparcInstrSelection.cpp
index 6692550..64b9a7e 100644
--- a/llvm/lib/Target/Sparc/SparcInstrSelection.cpp
+++ b/llvm/lib/Target/Sparc/SparcInstrSelection.cpp
@@ -823,7 +823,8 @@
if (resultType->isInteger() || isa<PointerType>(resultType)) {
bool isValidConst;
- int64_t C = GetConstantValueAsSignedInt(constOp, isValidConst);
+ int64_t C = (int64_t) target.getInstrInfo().ConvertConstantToIntType(target,
+ constOp, constOp->getType(), isValidConst);
if (isValidConst) {
unsigned pow;
bool needNeg = false;
@@ -976,14 +977,15 @@
if (resultType->isInteger()) {
unsigned pow;
bool isValidConst;
- int64_t C = GetConstantValueAsSignedInt(constOp, isValidConst);
+ int64_t C = (int64_t) target.getInstrInfo().ConvertConstantToIntType(target,
+ constOp, constOp->getType(), isValidConst);
if (isValidConst) {
bool needNeg = false;
if (C < 0) {
needNeg = true;
C = -C;
}
-
+
if (C == 1) {
mvec.push_back(BuildMI(V9::ADDr, 3).addReg(LHS).addMReg(ZeroReg)
.addRegDef(destVal));
@@ -1085,7 +1087,9 @@
// compile time if the total size is a known constant.
if (isa<Constant>(numElementsVal)) {
bool isValid;
- int64_t numElem = GetConstantValueAsSignedInt(numElementsVal, isValid);
+ int64_t numElem = (int64_t) target.getInstrInfo().
+ ConvertConstantToIntType(target, numElementsVal,
+ numElementsVal->getType(), isValid);
assert(isValid && "Unexpectedly large array dimension in alloca!");
int64_t total = numElem * tsize;
if (int extra= total % target.getFrameInfo().getStackFrameSizeAlignment())
@@ -1634,7 +1638,8 @@
if ((constVal->getType()->isInteger()
|| isa<PointerType>(constVal->getType()))
- && GetConstantValueAsSignedInt(constVal, isValidConst) == 0
+ && target.getInstrInfo().ConvertConstantToIntType(target,
+ constVal, constVal->getType(), isValidConst) == 0
&& isValidConst)
{
// That constant is a zero after all...
@@ -2240,7 +2245,8 @@
if ((constVal->getType()->isInteger()
|| isa<PointerType>(constVal->getType()))
- && GetConstantValueAsSignedInt(constVal, isValidConst) == 0
+ && target.getInstrInfo().ConvertConstantToIntType(target,
+ constVal, constVal->getType(), isValidConst) == 0
&& isValidConst)
{
// That constant is an integer zero after all...