Skip to content

Commit

Permalink
[AIE] Make one more copy in the unrolled dag
Browse files Browse the repository at this point in the history
This is necessary to try sufficient stages, but makes it very difficult to reach the earlier
NCopies == 1 crash situation.
  • Loading branch information
Martien de Jong committed Nov 18, 2024
1 parent 547edf0 commit 638e872
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/Target/AIE/AIEMachineScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1235,8 +1235,9 @@ void llvm::AIEPostRASchedStrategy::buildGraph(ScheduleDAGMI &DAG, AAResults *AA,
assert(BS.getRegions().size() == 1);
// Try to wrap the linear schedule within II.
// We virtually unroll the body by the stagecount, computed from rounding
// up the length divided by II.
NCopies = (BS.getScheduleLength() + II - 1) / II;
// up the length divided by II, adding one more stage to account for
// the added resource contention
NCopies = (BS.getScheduleLength() + II - 1) / II + 1;
}
DEBUG_BLOCKS(dbgs() << " buildGraph, NCopies=" << NCopies << "\n");
for (int S = 0; S < NCopies; S++) {
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/CodeGen/AIE/aie2/schedule/postpipeliner/crash.mir
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# RUN: llc --mtriple=aie2 -O2 --start-before=postmisched %s -o - | FileCheck %s

# This crashed the postpipeliner because it reaches NCopies=1 which causes an out of
# bound access when setting up LCD heuristics.
# bound access when setting up LCD heuristics.
# The filecheck reference is the unpipelined loop

--- |
Expand All @@ -29,13 +29,13 @@
; CHECK-NEXT: .p2align 4
; CHECK-NEXT: .LBB0_1: // %for.body
; CHECK-NEXT: // =>This Inner Loop Header: Depth=1
; CHECK-NEXT: nopb ; lda r0, [p2, #0]; nops ; nopxm ; nopv
; CHECK-NEXT: nopx
; CHECK-NEXT: nopb ; lda r0, [p2, #0]; nops ; nopx ; mov p2, p1; nopv
; CHECK-NEXT: nopa ; nopx
; CHECK-NEXT: nop
; CHECK-NEXT: nop
; CHECK-NEXT: nop
; CHECK-NEXT: nop
; CHECK-NEXT: nop
; CHECK-NEXT: mov p2, p1
; CHECK-NEXT: .L_LEnd0:
; CHECK-NEXT: nopb ; nopa ; st r0, [p0, #0]; nopxm ; nopv
; CHECK-NEXT: // %bb.2: // %for.cond.cleanup
Expand Down

0 comments on commit 638e872

Please sign in to comment.