Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -24,6 +24,7 @@ #include "polly/ScopDetection.h" #include "polly/Support/GICHelper.h" #include "polly/Support/ISLOStream.h" +#include "polly/Support/ISLTools.h" #include "polly/Support/SCEVAffinator.h" #include "polly/Support/SCEVValidator.h" #include "polly/Support/ScopHelper.h" @@ -2299,15 +2300,19 @@ } /// Add the minimal/maximal access in @p Set to @p User. -static isl::stat -buildMinMaxAccess(isl::set Set, Scop::MinMaxVectorTy &MinMaxAccesses, Scop &S) { +static isl::stat buildMinMaxAccess(isl::set &Set, + Scop::MinMaxVectorTy &MinMaxAccesses, + Scop &S) { isl::pw_multi_aff MinPMA, MaxPMA; isl::pw_aff LastDimAff; isl::aff OneAff; unsigned Pos; isl::ctx Ctx = Set.get_ctx(); - Set = Set.remove_divs(); + polly::simplify(Set); + + if (isl_set_n_basic_set(Set.get()) > RunTimeChecksMaxAccessDisjuncts) + Set = Set.simple_hull(); if (isl_set_n_basic_set(Set.get()) >= MaxDisjunctsInDomain) return isl::stat::error; @@ -2336,15 +2341,9 @@ return isl::stat::error; } - if (isl_set_n_basic_set(Set.get()) > RunTimeChecksMaxAccessDisjuncts) - return isl::stat::error; - MinPMA = Set.lexmin_pw_multi_aff(); MaxPMA = Set.lexmax_pw_multi_aff(); - if (isl_ctx_last_error(Ctx.get()) == isl_error_quota) - return isl::stat::error; - MinPMA = MinPMA.coalesce(); MaxPMA = MaxPMA.coalesce(); @@ -2352,7 +2351,9 @@ // enclose the accessed memory region by MinPMA and MaxPMA. The pointer // we test during code generation might now point after the end of the // allocated array but we will never dereference it anyway. - assert(MaxPMA.dim(isl::dim::out) && "Assumed at least one output dimension"); + assert((!MaxPMA || MaxPMA.dim(isl::dim::out)) && + "Assumed at least one output dimension"); + Pos = MaxPMA.dim(isl::dim::out) - 1; LastDimAff = MaxPMA.get_pw_aff(Pos); OneAff = isl::aff(isl::local_space(LastDimAff.get_domain_space())); @@ -2360,6 +2361,9 @@ LastDimAff = LastDimAff.add(OneAff); MaxPMA = MaxPMA.set_pw_aff(Pos, LastDimAff); + if (!MinPMA || !MaxPMA) + return isl::stat::error; + MinMaxAccesses.push_back(std::make_pair(MinPMA, MaxPMA)); return isl::stat::ok; @@ -2384,11 +2388,10 @@ Accesses = Accesses.intersect_domain(Domains); isl::union_set Locations = Accesses.range(); - Locations = Locations.coalesce(); - Locations = Locations.detect_equalities(); auto Lambda = [&MinMaxAccesses, &S](isl::set Set) -> isl::stat { - return buildMinMaxAccess(Set, MinMaxAccesses, S); + isl::set &SimpleSet = Set; + return buildMinMaxAccess(SimpleSet, MinMaxAccesses, S); }; return Locations.foreach_set(Lambda) == isl::stat::ok; }