diff --git a/polly/include/polly/ZoneAlgo.h b/polly/include/polly/ZoneAlgo.h index 43a9da9eb327..5f009c8befce 100644 --- a/polly/include/polly/ZoneAlgo.h +++ b/polly/include/polly/ZoneAlgo.h @@ -336,8 +336,8 @@ protected: /// should have been replaced by their incoming values. /// /// @see #NormalizedPHI - bool isNormalized(isl::map Map); - bool isNormalized(isl::union_map Map); + isl::boolean isNormalized(isl::map Map); + isl::boolean isNormalized(isl::union_map Map); /// @} public: diff --git a/polly/lib/Transform/ForwardOpTree.cpp b/polly/lib/Transform/ForwardOpTree.cpp index 9a6439167812..9c24170bcd55 100644 --- a/polly/lib/Transform/ForwardOpTree.cpp +++ b/polly/lib/Transform/ForwardOpTree.cpp @@ -500,7 +500,8 @@ public: // { DomainDef[] -> ValInst[] } isl::map ExpectedVal = makeValInst(Inst, UseStmt, UseLoop); - assert(isNormalized(ExpectedVal) && "LoadInsts are always normalized"); + assert(!isNormalized(ExpectedVal).is_false() && + "LoadInsts are always normalized"); // { DomainUse[] -> DomainTarget[] } isl::map UseToTarget = getDefToTarget(UseStmt, TargetStmt); diff --git a/polly/lib/Transform/ZoneAlgo.cpp b/polly/lib/Transform/ZoneAlgo.cpp index 2ad40d83d36b..a34fcb377543 100644 --- a/polly/lib/Transform/ZoneAlgo.cpp +++ b/polly/lib/Transform/ZoneAlgo.cpp @@ -842,20 +842,26 @@ bool ZoneAlgorithm::isNormalizable(MemoryAccess *MA) { return true; } -bool ZoneAlgorithm::isNormalized(isl::map Map) { +isl::boolean ZoneAlgorithm::isNormalized(isl::map Map) { isl::space Space = Map.get_space(); isl::space RangeSpace = Space.range(); - if (!RangeSpace.is_wrapping()) - return true; + isl::boolean IsWrapping = RangeSpace.is_wrapping(); + if (!IsWrapping.is_true()) + return !IsWrapping; + isl::space Unwrapped = RangeSpace.unwrap(); - auto *PHI = dyn_cast(static_cast( - RangeSpace.unwrap().get_tuple_id(isl::dim::out).get_user())); + isl::id OutTupleId = Unwrapped.get_tuple_id(isl::dim::out); + if (OutTupleId.is_null()) + return isl::boolean(); + auto *PHI = dyn_cast(static_cast(OutTupleId.get_user())); if (!PHI) return true; - auto *IncomingStmt = static_cast( - RangeSpace.unwrap().get_tuple_id(isl::dim::in).get_user()); + isl::id InTupleId = Unwrapped.get_tuple_id(isl::dim::in); + if (OutTupleId.is_null()) + return isl::boolean(); + auto *IncomingStmt = static_cast(InTupleId.get_user()); MemoryAccess *PHIRead = IncomingStmt->lookupPHIReadOf(PHI); if (!isNormalizable(PHIRead)) return true; @@ -863,13 +869,15 @@ bool ZoneAlgorithm::isNormalized(isl::map Map) { return false; } -bool ZoneAlgorithm::isNormalized(isl::union_map UMap) { - auto Result = UMap.foreach_map([this](isl::map Map) -> isl::stat { - if (isNormalized(Map)) +isl::boolean ZoneAlgorithm::isNormalized(isl::union_map UMap) { + isl::boolean Result = true; + UMap.foreach_map([this, &Result](isl::map Map) -> isl::stat { + Result = isNormalized(Map); + if (Result.is_true()) return isl::stat::ok; return isl::stat::error; }); - return Result == isl::stat::ok; + return Result; } void ZoneAlgorithm::computeCommon() {