Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -86,6 +86,11 @@ cl::Hidden, cl::ZeroOrMore, cl::init(true), cl::cat(PollyCategory)); +static cl::opt AllowUnbounded("polly-allow-unbounded", + cl::desc("Allow unbounded loops"), + cl::Hidden, cl::ZeroOrMore, cl::init(false), + cl::cat(PollyCategory)); + // Create a sequence of two schedules. Either argument may be null and is // interpreted as the empty schedule. Can also return null if both schedules are // empty. @@ -903,9 +908,15 @@ isl_set *UpperBoundSet = isl_pw_aff_le_set(IV, UpperBound); Domain = isl_set_intersect(Domain, UpperBoundSet); } else { - // If SCEV cannot provide a loop trip count we compute it with ISL. + // If SCEV cannot provide a loop trip count, we compute it with ISL. If + // the domain remains unbounded, make the assumed context infeasible + // unless we explicitly allow unbounded loops. Code generation currently + // does not expect unbounded loops. addLoopTripCountToDomain(L); isl_pw_aff_free(IV); + if (!AllowUnbounded) + if (!isl_set_dim_has_upper_bound(Domain, isl_dim_set, i)) + Parent.addAssumption(isl_set_empty(Parent.getParamSpace())); } } Index: test/ScopInfo/isl_trip_count_02.ll =================================================================== --- test/ScopInfo/isl_trip_count_02.ll +++ test/ScopInfo/isl_trip_count_02.ll @@ -1,4 +1,4 @@ -; RUN: opt %loadPolly -polly-detect-unprofitable -polly-allow-non-scev-backedge-taken-count -polly-scops -analyze < %s | FileCheck %s +; RUN: opt %loadPolly -polly-detect-unprofitable -polly-allow-non-scev-backedge-taken-count -polly-allow-unbounded -polly-scops -analyze < %s | FileCheck %s ; ; CHECK: [M, N] -> { Stmt_for_body[i0] : i0 >= 0 and N <= -1 + M }; ;