summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r--llvm/lib/Analysis/ScalarEvolutionExpander.cpp33
1 files changed, 2 insertions, 31 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
index ef9557132fc..59f19a002ec 100644
--- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -1063,34 +1063,6 @@ static bool canBeCheaplyTransformed(ScalarEvolution &SE,
return false;
}
-static bool IsIncrementNSW(ScalarEvolution &SE, const SCEVAddRecExpr *AR) {
- if (!isa<IntegerType>(AR->getType()))
- return false;
-
- unsigned BitWidth = cast<IntegerType>(AR->getType())->getBitWidth();
- Type *WideTy = IntegerType::get(AR->getType()->getContext(), BitWidth * 2);
- const SCEV *Step = AR->getStepRecurrence(SE);
- const SCEV *OpAfterExtend = SE.getAddExpr(SE.getSignExtendExpr(Step, WideTy),
- SE.getSignExtendExpr(AR, WideTy));
- const SCEV *ExtendAfterOp =
- SE.getSignExtendExpr(SE.getAddExpr(AR, Step), WideTy);
- return ExtendAfterOp == OpAfterExtend;
-}
-
-static bool IsIncrementNUW(ScalarEvolution &SE, const SCEVAddRecExpr *AR) {
- if (!isa<IntegerType>(AR->getType()))
- return false;
-
- unsigned BitWidth = cast<IntegerType>(AR->getType())->getBitWidth();
- Type *WideTy = IntegerType::get(AR->getType()->getContext(), BitWidth * 2);
- const SCEV *Step = AR->getStepRecurrence(SE);
- const SCEV *OpAfterExtend = SE.getAddExpr(SE.getZeroExtendExpr(Step, WideTy),
- SE.getZeroExtendExpr(AR, WideTy));
- const SCEV *ExtendAfterOp =
- SE.getZeroExtendExpr(SE.getAddExpr(AR, Step), WideTy);
- return ExtendAfterOp == OpAfterExtend;
-}
-
/// getAddRecExprPHILiterally - Helper for expandAddRecExprLiterally. Expand
/// the base addrec, which is the addrec without any non-loop-dominating
/// values, and return the PHI.
@@ -1241,11 +1213,10 @@ SCEVExpander::getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized,
IVIncInsertPos : Pred->getTerminator();
Builder.SetInsertPoint(InsertPos);
Value *IncV = expandIVInc(PN, StepV, L, ExpandTy, IntTy, useSubtract);
-
if (isa<OverflowingBinaryOperator>(IncV)) {
- if (IsIncrementNUW(SE, Normalized))
+ if (Normalized->getNoWrapFlags(SCEV::FlagNUW))
cast<BinaryOperator>(IncV)->setHasNoUnsignedWrap();
- if (IsIncrementNSW(SE, Normalized))
+ if (Normalized->getNoWrapFlags(SCEV::FlagNSW))
cast<BinaryOperator>(IncV)->setHasNoSignedWrap();
}
PN->addIncoming(IncV, Pred);
OpenPOWER on IntegriCloud