diff options
author | Zhou Sheng <zhousheng00@gmail.com> | 2007-04-07 17:12:38 +0000 |
---|---|---|
committer | Zhou Sheng <zhousheng00@gmail.com> | 2007-04-07 17:12:38 +0000 |
commit | 8342836d70e94361a88d431a68a6da0ae0a9e219 (patch) | |
tree | 3a00b066d8da1eadb7a4ced89fac25fceb0804cc /lib/Analysis/ScalarEvolution.cpp | |
parent | a3b12ddade4e3a0a737f2c38308588c7442441a8 (diff) |
Eliminate unnecessary zext/trunc stuffs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35737 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 3597b3551c..d9256c91aa 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -1147,7 +1147,7 @@ namespace { SCEVHandle ComputeIterationCount(const Loop *L); /// ComputeLoadConstantCompareIterationCount - Given an exit condition of - /// 'setcc load X, cst', try to se if we can compute the trip count. + /// 'setcc load X, cst', try to see if we can compute the trip count. SCEVHandle ComputeLoadConstantCompareIterationCount(LoadInst *LI, Constant *RHS, const Loop *L, @@ -1342,21 +1342,19 @@ static APInt GetConstantFactor(SCEVHandle S) { } if (SCEVTruncateExpr *T = dyn_cast<SCEVTruncateExpr>(S)) { - APInt Mask(cast<IntegerType>(T->getType())->getMask()); - APInt GCF(GetConstantFactor(T->getOperand())); - Mask.zextOrTrunc(GCF.getBitWidth()); - return GCF & Mask; + return GetConstantFactor(T->getOperand()).trunc( + cast<IntegerType>(T->getType())->getBitWidth()); } if (SCEVZeroExtendExpr *E = dyn_cast<SCEVZeroExtendExpr>(S)) - return GetConstantFactor(E->getOperand()); + return GetConstantFactor(E->getOperand()).zext( + cast<IntegerType>(E->getType())->getBitWidth()); if (SCEVAddExpr *A = dyn_cast<SCEVAddExpr>(S)) { // The result is the min of all operands. - APInt Res = GetConstantFactor(A->getOperand(0)); + APInt Res(GetConstantFactor(A->getOperand(0))); for (unsigned i = 1, e = A->getNumOperands(); i != e && Res.ugt(APInt(Res.getBitWidth(),1)); ++i) { APInt Tmp(GetConstantFactor(A->getOperand(i))); - Tmp.zextOrTrunc(Res.getBitWidth()); Res = APIntOps::umin(Res, Tmp); } return Res; @@ -1364,10 +1362,9 @@ static APInt GetConstantFactor(SCEVHandle S) { if (SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(S)) { // The result is the product of all the operands. - APInt Res = GetConstantFactor(M->getOperand(0)); + APInt Res(GetConstantFactor(M->getOperand(0))); for (unsigned i = 1, e = M->getNumOperands(); i != e; ++i) { APInt Tmp(GetConstantFactor(M->getOperand(i))); - Tmp.zextOrTrunc(Res.getBitWidth()); Res *= Tmp; } return Res; @@ -1377,11 +1374,10 @@ static APInt GetConstantFactor(SCEVHandle S) { // For now, we just handle linear expressions. if (A->getNumOperands() == 2) { // We want the GCD between the start and the stride value. - APInt Start = GetConstantFactor(A->getOperand(0)); + APInt Start(GetConstantFactor(A->getOperand(0))); if (Start == 1) - return APInt(A->getBitWidth(),1); - APInt Stride = GetConstantFactor(A->getOperand(1)); - Start.zextOrTrunc(Stride.getBitWidth()); + return Start; + APInt Stride(GetConstantFactor(A->getOperand(1))); return APIntOps::GreatestCommonDivisor(Start, Stride); } } |