Skip to content

Commit 5f58aae

Browse files
committed
[Polly][CodeGen] Allow nesting of BandAttr mark without loop.
BandAttr markers are added as parents of schedule tree bands. These also appear as markers its equivalent AST, but a band does not necessarily corresponds to a loop in this. Iterations may be peeled or the loop being unrolled (e.g. if it has just one iteration). In such cases it may happend that there is not loop between a BandAttr marker and the marker for a loop nested in the former parent band/loop. Handle the situation by giving priority to the inner marker over the outer. Fixes the polly-x86_64-linux-test-suite buildbot.
1 parent 7202f47 commit 5f58aae

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

polly/lib/CodeGen/IslNodeBuilder.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,18 +428,23 @@ void IslNodeBuilder::createMark(__isl_take isl_ast_node *Node) {
428428
}
429429

430430
BandAttr *ChildLoopAttr = getLoopAttr(isl::manage_copy(Id));
431+
BandAttr *AncestorLoopAttr;
431432
if (ChildLoopAttr) {
432-
assert(!Annotator.getStagingAttrEnv() &&
433-
"conflicting loop attr environments");
433+
// Save current LoopAttr environment to restore again when leaving this
434+
// subtree. This means there was no loop between the ancestor LoopAttr and
435+
// this mark, i.e. the ancestor LoopAttr did not directly mark a loop. This
436+
// can happen e.g. if the AST build peeled or unrolled the loop.
437+
AncestorLoopAttr = Annotator.getStagingAttrEnv();
438+
434439
Annotator.getStagingAttrEnv() = ChildLoopAttr;
435440
}
436441

437442
create(Child);
438443

439444
if (ChildLoopAttr) {
440445
assert(Annotator.getStagingAttrEnv() == ChildLoopAttr &&
441-
"Nest must not overwrite loop attr environment");
442-
Annotator.getStagingAttrEnv() = nullptr;
446+
"Nest must not overwrite loop attr environment");
447+
Annotator.getStagingAttrEnv() = AncestorLoopAttr;
443448
}
444449

445450
isl_id_free(Id);

0 commit comments

Comments
 (0)