diff options
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/IndVarSimplify.cpp | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index ddb5b27..df11e92 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -1612,29 +1612,10 @@ LinearFunctionTestReplace(Loop *L, << " IVCount:\t" << *IVCount << "\n"); IRBuilder<> Builder(BI); - - unsigned CmpIndVarSize = SE->getTypeSizeInBits(CmpIndVar->getType()); - unsigned ExitCntSize = SE->getTypeSizeInBits(ExitCnt->getType()); - if (CmpIndVarSize > ExitCntSize) { - const SCEVAddRecExpr *AR = cast<SCEVAddRecExpr>(SE->getSCEV(IndVar)); - const SCEV *ARStart = AR->getStart(); - const SCEV *ARStep = AR->getStepRecurrence(*SE); - if (isa<SCEVConstant>(ARStart) && isa<SCEVConstant>(IVCount)) { - const APInt &Start = cast<SCEVConstant>(ARStart)->getValue()->getValue(); - const APInt &Count = cast<SCEVConstant>(IVCount)->getValue()->getValue(); - - APInt NewLimit; - if (cast<SCEVConstant>(ARStep)->getValue()->isNegative()) - NewLimit = Start - Count.zext(CmpIndVarSize); - else - NewLimit = Start + Count.zext(CmpIndVarSize); - ExitCnt = ConstantInt::get(CmpIndVar->getType(), NewLimit); - - DEBUG(dbgs() << " Widen RHS:\t" << *ExitCnt << "\n"); - } else { - CmpIndVar = Builder.CreateTrunc(CmpIndVar, ExitCnt->getType(), - "lftr.wideiv"); - } + if (SE->getTypeSizeInBits(CmpIndVar->getType()) + > SE->getTypeSizeInBits(ExitCnt->getType())) { + CmpIndVar = Builder.CreateTrunc(CmpIndVar, ExitCnt->getType(), + "lftr.wideiv"); } Value *Cond = Builder.CreateICmp(P, CmpIndVar, ExitCnt, "exitcond"); |