summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp11
-rw-r--r--polly/lib/Support/SCEVValidator.cpp2
-rw-r--r--polly/test/ScopInfo/NonAffine/non-affine-loop-condition-dependent-access_2.ll2
3 files changed, 10 insertions, 5 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 59bf345cd6f..2caab15adfa 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -214,6 +214,8 @@ __isl_give isl_pw_aff *
SCEVAffinator::visitAddRecExpr(const SCEVAddRecExpr *Expr) {
assert(Expr->isAffine() && "Only affine AddRecurrences allowed");
+ auto Flags = Expr->getNoWrapFlags();
+
// Directly generate isl_pw_aff for Expr if 'start' is zero.
if (Expr->getStart()->isZero()) {
assert(S->getRegion().contains(Expr->getLoop()) &&
@@ -236,10 +238,13 @@ SCEVAffinator::visitAddRecExpr(const SCEVAddRecExpr *Expr) {
// Translate AddRecExpr from '{start, +, inc}' into 'start + {0, +, inc}'
// if 'start' is not zero.
+ // TODO: Using the original SCEV no-wrap flags is not always safe, however
+ // as our code generation is reordering the expression anyway it doesn't
+ // really matter.
ScalarEvolution &SE = *S->getSE();
- const SCEV *ZeroStartExpr = SE.getAddRecExpr(
- SE.getConstant(Expr->getStart()->getType(), 0),
- Expr->getStepRecurrence(SE), Expr->getLoop(), SCEV::FlagAnyWrap);
+ const SCEV *ZeroStartExpr =
+ SE.getAddRecExpr(SE.getConstant(Expr->getStart()->getType(), 0),
+ Expr->getStepRecurrence(SE), Expr->getLoop(), Flags);
isl_pw_aff *ZeroStartResult = visit(ZeroStartExpr);
isl_pw_aff *Start = visit(Expr->getStart());
diff --git a/polly/lib/Support/SCEVValidator.cpp b/polly/lib/Support/SCEVValidator.cpp
index 1cfbd66d852..80c2249769a 100644
--- a/polly/lib/Support/SCEVValidator.cpp
+++ b/polly/lib/Support/SCEVValidator.cpp
@@ -287,7 +287,7 @@ public:
// if 'start' is not zero.
const SCEV *ZeroStartExpr = SE.getAddRecExpr(
SE.getConstant(Expr->getStart()->getType(), 0),
- Expr->getStepRecurrence(SE), Expr->getLoop(), SCEV::FlagAnyWrap);
+ Expr->getStepRecurrence(SE), Expr->getLoop(), Expr->getNoWrapFlags());
ValidatorResult ZeroStartResult =
ValidatorResult(SCEVType::PARAM, ZeroStartExpr);
diff --git a/polly/test/ScopInfo/NonAffine/non-affine-loop-condition-dependent-access_2.ll b/polly/test/ScopInfo/NonAffine/non-affine-loop-condition-dependent-access_2.ll
index 40d6d3e19a1..6ea874a5dab 100644
--- a/polly/test/ScopInfo/NonAffine/non-affine-loop-condition-dependent-access_2.ll
+++ b/polly/test/ScopInfo/NonAffine/non-affine-loop-condition-dependent-access_2.ll
@@ -11,7 +11,7 @@
; INNERMOST: Function: f
; INNERMOST: Region: %bb15---%bb26
; INNERMOST: Max Loop Depth: 1
-; INNERMOST: p0: {0,+,{0,+,-1}<nw><%bb11>}<%bb13>
+; INNERMOST: p0: {0,+,{0,+,-1}<nw><%bb11>}<nw><%bb13>
; INNERMOST: p1: {0,+,{0,+,1}<nuw><nsw><%bb11>}<nuw><nsw><%bb13>
; INNERMOST: p2: {0,+,4}<nuw><nsw><%bb11>
; INNERMOST: p3: {0,+,4}<nuw><nsw><%bb13>
OpenPOWER on IntegriCloud