summaryrefslogtreecommitdiff
path: root/polly/lib/CodeGen/IslAst.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'polly/lib/CodeGen/IslAst.cpp')
-rw-r--r--polly/lib/CodeGen/IslAst.cpp38
1 files changed, 18 insertions, 20 deletions
diff --git a/polly/lib/CodeGen/IslAst.cpp b/polly/lib/CodeGen/IslAst.cpp
index 0923726c87b..1862950ed67 100644
--- a/polly/lib/CodeGen/IslAst.cpp
+++ b/polly/lib/CodeGen/IslAst.cpp
@@ -119,6 +119,9 @@ struct AstBuildUserInfo {
/// Flag to indicate that we are inside a parallel for node.
bool InParallelFor = false;
+ /// Flag to indicate that we are inside an SIMD node.
+ bool InSIMD = false;
+
/// The last iterator id created for the current SCoP.
isl_id *LastForNodeId = nullptr;
};
@@ -131,7 +134,6 @@ static void freeIslAstUserPayload(void *Ptr) {
IslAstInfo::IslAstUserPayload::~IslAstUserPayload() {
isl_ast_build_free(Build);
- isl_pw_aff_free(MinimalDependenceDistance);
}
/// Print a string @p str in a single line using @p Printer.
@@ -226,7 +228,10 @@ static bool astScheduleDimIsParallel(__isl_keep isl_ast_build *Build,
D->getDependences(Dependences::TYPE_RAW | Dependences::TYPE_WAW |
Dependences::TYPE_WAR | Dependences::TYPE_TC_RED)
.release();
- D->isParallel(Schedule, DepsAll, &NodeInfo->MinimalDependenceDistance);
+ isl_pw_aff *MinimalDependenceDistance = nullptr;
+ D->isParallel(Schedule, DepsAll, &MinimalDependenceDistance);
+ NodeInfo->MinimalDependenceDistance =
+ isl::manage(MinimalDependenceDistance);
isl_union_map_free(Schedule);
return false;
}
@@ -268,10 +273,13 @@ static __isl_give isl_id *astBuildBeforeFor(__isl_keep isl_ast_build *Build,
Id = isl_id_set_free_user(Id, freeIslAstUserPayload);
BuildInfo->LastForNodeId = Id;
+ Payload->IsParallel =
+ astScheduleDimIsParallel(Build, BuildInfo->Deps, Payload);
+
// Test for parallelism only if we are not already inside a parallel loop
- if (!BuildInfo->InParallelFor)
+ if (!BuildInfo->InParallelFor && !BuildInfo->InSIMD)
BuildInfo->InParallelFor = Payload->IsOutermostParallel =
- astScheduleDimIsParallel(Build, BuildInfo->Deps, Payload);
+ Payload->IsParallel;
return Id;
}
@@ -296,18 +304,8 @@ astBuildAfterFor(__isl_take isl_ast_node *Node, __isl_keep isl_ast_build *Build,
Payload->Build = isl_ast_build_copy(Build);
Payload->IsInnermost = (Id == BuildInfo->LastForNodeId);
- // Innermost loops that are surrounded by parallel loops have not yet been
- // tested for parallelism. Test them here to ensure we check all innermost
- // loops for parallelism.
- if (Payload->IsInnermost && BuildInfo->InParallelFor) {
- if (Payload->IsOutermostParallel) {
- Payload->IsInnermostParallel = true;
- } else {
- if (PollyVectorizerChoice == VECTORIZER_NONE)
- Payload->IsInnermostParallel =
- astScheduleDimIsParallel(Build, BuildInfo->Deps, Payload);
- }
- }
+ Payload->IsInnermostParallel =
+ Payload->IsInnermost && (BuildInfo->InSIMD || Payload->IsParallel);
if (Payload->IsOutermostParallel)
BuildInfo->InParallelFor = false;
@@ -323,7 +321,7 @@ static isl_stat astBuildBeforeMark(__isl_keep isl_id *MarkId,
AstBuildUserInfo *BuildInfo = (AstBuildUserInfo *)User;
if (strcmp(isl_id_get_name(MarkId), "SIMD") == 0)
- BuildInfo->InParallelFor = true;
+ BuildInfo->InSIMD = true;
return isl_stat_ok;
}
@@ -335,7 +333,7 @@ astBuildAfterMark(__isl_take isl_ast_node *Node,
AstBuildUserInfo *BuildInfo = (AstBuildUserInfo *)User;
auto *Id = isl_ast_node_mark_get_id(Node);
if (strcmp(isl_id_get_name(Id), "SIMD") == 0)
- BuildInfo->InParallelFor = false;
+ BuildInfo->InSIMD = false;
isl_id_free(Id);
return Node;
}
@@ -565,6 +563,7 @@ void IslAst::init(const Dependences &D) {
if (PerformParallelTest) {
BuildInfo.Deps = &D;
BuildInfo.InParallelFor = false;
+ BuildInfo.InSIMD = false;
Build = isl_ast_build_set_before_each_for(Build, &astBuildBeforeFor,
&BuildInfo);
@@ -664,8 +663,7 @@ IslAstInfo::getSchedule(__isl_keep isl_ast_node *Node) {
__isl_give isl_pw_aff *
IslAstInfo::getMinimalDependenceDistance(__isl_keep isl_ast_node *Node) {
IslAstUserPayload *Payload = getNodePayload(Node);
- return Payload ? isl_pw_aff_copy(Payload->MinimalDependenceDistance)
- : nullptr;
+ return Payload ? Payload->MinimalDependenceDistance.copy() : nullptr;
}
IslAstInfo::MemoryAccessSet *