From 638e872a3361d1b017a36550483774ab39543485 Mon Sep 17 00:00:00 2001 From: Martien de Jong Date: Tue, 22 Oct 2024 11:03:07 +0200 Subject: [PATCH] [AIE] Make one more copy in the unrolled dag This is necessary to try sufficient stages, but makes it very difficult to reach the earlier NCopies == 1 crash situation. --- llvm/lib/Target/AIE/AIEMachineScheduler.cpp | 5 +++-- .../CodeGen/AIE/aie2/schedule/postpipeliner/crash.mir | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Target/AIE/AIEMachineScheduler.cpp b/llvm/lib/Target/AIE/AIEMachineScheduler.cpp index 6c23868b8daa..113ebcb1531c 100644 --- a/llvm/lib/Target/AIE/AIEMachineScheduler.cpp +++ b/llvm/lib/Target/AIE/AIEMachineScheduler.cpp @@ -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++) { diff --git a/llvm/test/CodeGen/AIE/aie2/schedule/postpipeliner/crash.mir b/llvm/test/CodeGen/AIE/aie2/schedule/postpipeliner/crash.mir index 3a3c9bc4b772..a5dae2d34a2a 100644 --- a/llvm/test/CodeGen/AIE/aie2/schedule/postpipeliner/crash.mir +++ b/llvm/test/CodeGen/AIE/aie2/schedule/postpipeliner/crash.mir @@ -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 --- | @@ -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