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" @@ -174,12 +175,6 @@ cl::desc("Do not emit remarks about assumptions that are known"), cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::cat(PollyCategory)); -static cl::opt RunTimeChecksMaxAccessDisjuncts( - "polly-rtc-max-array-disjuncts", - cl::desc("The maximal number of disjunts allowed in memory accesses to " - "to build RTCs."), - cl::Hidden, cl::ZeroOrMore, cl::init(8), cl::cat(PollyCategory)); - static cl::opt RunTimeChecksMaxParameters( "polly-rtc-max-parameters", cl::desc("The maximal number of parameters allowed in RTCs."), cl::Hidden, @@ -2307,9 +2302,13 @@ unsigned Pos; isl::ctx Ctx = Set.get_ctx(); - Set = Set.remove_divs(); + isl::set &&simple_set = Set.remove_divs(); + polly::simplify(simple_set); + + if (isl_set_n_basic_set(simple_set.get()) >= MaxDisjunctsInDomain) + simple_set = simple_set.simple_hull(); - if (isl_set_n_basic_set(Set.get()) >= MaxDisjunctsInDomain) + if (isl_set_n_basic_set(simple_set.get()) >= MaxDisjunctsInDomain) return isl::stat::error; // Restrict the number of parameters involved in the access as the lexmin/ @@ -2326,33 +2325,32 @@ // 11 | 6.78 // 12 | 30.38 // - if (isl_set_n_param(Set.get()) > RunTimeChecksMaxParameters) { + if (isl_set_n_param(simple_set.get()) > RunTimeChecksMaxParameters) { unsigned InvolvedParams = 0; - for (unsigned u = 0, e = isl_set_n_param(Set.get()); u < e; u++) - if (Set.involves_dims(isl::dim::param, u, 1)) + for (unsigned u = 0, e = isl_set_n_param(simple_set.get()); u < e; u++) + if (simple_set.involves_dims(isl::dim::param, u, 1)) InvolvedParams++; if (InvolvedParams > RunTimeChecksMaxParameters) return isl::stat::error; } - if (isl_set_n_basic_set(Set.get()) > RunTimeChecksMaxAccessDisjuncts) - return isl::stat::error; + MinPMA = simple_set.lexmin_pw_multi_aff(); + MaxPMA = simple_set.lexmax_pw_multi_aff(); - MinPMA = Set.lexmin_pw_multi_aff(); - MaxPMA = Set.lexmax_pw_multi_aff(); + MinPMA = MinPMA.coalesce(); + MaxPMA = MaxPMA.coalesce(); if (isl_ctx_last_error(Ctx.get()) == isl_error_quota) return isl::stat::error; - MinPMA = MinPMA.coalesce(); - MaxPMA = MaxPMA.coalesce(); - // Adjust the last dimension of the maximal access by one as we want to // 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 || !MinPMA) || 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 +2358,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,9 +2385,6 @@ 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); };