[llvm-commits] CVS: llvm/lib/Analysis/ScalarEvolution.cpp
Reid Spencer
reid at x10sys.com
Wed Oct 25 23:16:28 PDT 2006
Changes in directory llvm/lib/Analysis:
ScalarEvolution.cpp updated: 1.54 -> 1.55
---
Log message:
For PR950: http://llvm.org/PR950 :
Make necessary changes to support DIV -> [SUF]Div. This changes llvm to
have three division instructions: signed, unsigned, floating point. The
bytecode and assembler are bacwards compatible, however.
---
Diffs of the changes: (+14 -15)
ScalarEvolution.cpp | 29 ++++++++++++++---------------
1 files changed, 14 insertions(+), 15 deletions(-)
Index: llvm/lib/Analysis/ScalarEvolution.cpp
diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.54 llvm/lib/Analysis/ScalarEvolution.cpp:1.55
--- llvm/lib/Analysis/ScalarEvolution.cpp:1.54 Fri Oct 20 02:07:24 2006
+++ llvm/lib/Analysis/ScalarEvolution.cpp Thu Oct 26 01:15:43 2006
@@ -989,9 +989,9 @@
SCEVHandle SCEVSDivExpr::get(const SCEVHandle &LHS, const SCEVHandle &RHS) {
if (SCEVConstant *RHSC = dyn_cast<SCEVConstant>(RHS)) {
if (RHSC->getValue()->equalsInt(1))
- return LHS; // X /s 1 --> x
+ return LHS; // X sdiv 1 --> x
if (RHSC->getValue()->isAllOnesValue())
- return SCEV::getNegativeSCEV(LHS); // X /s -1 --> -x
+ return SCEV::getNegativeSCEV(LHS); // X sdiv -1 --> -x
if (SCEVConstant *LHSC = dyn_cast<SCEVConstant>(LHS)) {
Constant *LHSCV = LHSC->getValue();
@@ -1001,7 +1001,7 @@
LHSCV->getType()->getSignedVersion());
if (RHSCV->getType()->isUnsigned())
RHSCV = ConstantExpr::getCast(RHSCV, LHSCV->getType());
- return SCEVUnknown::get(ConstantExpr::getDiv(LHSCV, RHSCV));
+ return SCEVUnknown::get(ConstantExpr::getSDiv(LHSCV, RHSCV));
}
}
@@ -1384,10 +1384,9 @@
case Instruction::Mul:
return SCEVMulExpr::get(getSCEV(I->getOperand(0)),
getSCEV(I->getOperand(1)));
- case Instruction::Div:
- if (V->getType()->isInteger() && V->getType()->isSigned())
- return SCEVSDivExpr::get(getSCEV(I->getOperand(0)),
- getSCEV(I->getOperand(1)));
+ case Instruction::SDiv:
+ return SCEVSDivExpr::get(getSCEV(I->getOperand(0)),
+ getSCEV(I->getOperand(1)));
break;
case Instruction::Sub:
@@ -2058,16 +2057,16 @@
return std::make_pair(CNC, CNC);
}
- Constant *Two = ConstantInt::get(L->getValue()->getType(), 2);
+ Constant *C = L->getValue();
+ Constant *Two = ConstantInt::get(C->getType(), 2);
// Convert from chrec coefficients to polynomial coefficients AX^2+BX+C
- Constant *C = L->getValue();
// The B coefficient is M-N/2
Constant *B = ConstantExpr::getSub(M->getValue(),
- ConstantExpr::getDiv(N->getValue(),
+ ConstantExpr::getSDiv(N->getValue(),
Two));
// The A coefficient is N/2
- Constant *A = ConstantExpr::getDiv(N->getValue(), Two);
+ Constant *A = ConstantExpr::getSDiv(N->getValue(), Two);
// Compute the B^2-4ac term.
Constant *SqrtTerm =
@@ -2102,9 +2101,9 @@
SqrtTerm = ConstantExpr::getCast(SqrtTerm, SignedTy);
Constant *Solution1 =
- ConstantExpr::getDiv(ConstantExpr::getAdd(NegB, SqrtTerm), TwoA);
+ ConstantExpr::getSDiv(ConstantExpr::getAdd(NegB, SqrtTerm), TwoA);
Constant *Solution2 =
- ConstantExpr::getDiv(ConstantExpr::getSub(NegB, SqrtTerm), TwoA);
+ ConstantExpr::getSDiv(ConstantExpr::getSub(NegB, SqrtTerm), TwoA);
return std::make_pair(SCEVUnknown::get(Solution1),
SCEVUnknown::get(Solution2));
}
@@ -2150,7 +2149,7 @@
Constant *StartNegC = ConstantExpr::getNeg(StartCC);
Constant *Rem = ConstantExpr::getRem(StartNegC, StepC->getValue());
if (Rem->isNullValue()) {
- Constant *Result =ConstantExpr::getDiv(StartNegC,StepC->getValue());
+ Constant *Result =ConstantExpr::getSDiv(StartNegC,StepC->getValue());
return SCEVUnknown::get(Result);
}
}
@@ -2352,7 +2351,7 @@
Constant *ExitValue = Upper;
if (A != One) {
ExitValue = ConstantExpr::getSub(ConstantExpr::getAdd(Upper, A), One);
- ExitValue = ConstantExpr::getDiv(ExitValue, A);
+ ExitValue = ConstantExpr::getSDiv(ExitValue, A);
}
assert(isa<ConstantInt>(ExitValue) &&
"Constant folding of integers not implemented?");
More information about the llvm-commits
mailing list