diff options
author | David Penry <david.penry@arm.com> | 2022-03-29 10:13:55 -0700 |
---|---|---|
committer | David Penry <david.penry@arm.com> | 2022-04-28 13:01:18 -0700 |
commit | 28d09bbbc3d09c912b54a4d5edb32cab7de32a6f (patch) | |
tree | 9eaa368ad76da65ab8bf1b3b0f7297bece624887 /llvm/lib/CodeGen/ModuloSchedule.cpp | |
parent | 651d9f70ed75e360b0a166ddca40526c2df43fe3 (diff) | |
download | llvm-28d09bbbc3d09c912b54a4d5edb32cab7de32a6f.zip llvm-28d09bbbc3d09c912b54a4d5edb32cab7de32a6f.tar.gz llvm-28d09bbbc3d09c912b54a4d5edb32cab7de32a6f.tar.bz2 |
[CodeGen][ARM] Enable Swing Module Scheduling for ARM
This patch permits Swing Modulo Scheduling for ARM targets
turns it on by default for the Cortex-M7. The t2Bcc
instruction is recognized as a loop-ending branch.
MachinePipeliner is extended by adding support for
"unpipelineable" instructions. These instructions are
those which contribute to the loop exit test; in the SMS
papers they are removed before creating the dependence graph
and then inserted into the final schedule of the kernel and
prologues. Support for these instructions was not previously
necessary because current targets supporting SMS have only
supported it for hardware loop branches, which have no
loop-exit-contributing instructions in the loop body.
The current structure of the MachinePipeliner makes it difficult
to remove/exclude these instructions from the dependence graph.
Therefore, this patch leaves them in the graph, but adds a
"normalization" method which moves them in the schedule to
stage 0, which causes them to appear properly in kernel and
prologues.
It was also necessary to be more careful about boundary nodes
when iterating across successors in the dependence graph because
the loop exit branch is now a non-artificial successor to
instructions in the graph. In additional, schedules with physical
use/def pairs in the same cycle should be treated as creating an
invalid schedule because the scheduling logic doesn't respect
physical register dependence once scheduled to the same cycle.
Reviewed By: dmgreen
Differential Revision: https://reviews.llvm.org/D122672
Diffstat (limited to 'llvm/lib/CodeGen/ModuloSchedule.cpp')
-rw-r--r-- | llvm/lib/CodeGen/ModuloSchedule.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/ModuloSchedule.cpp b/llvm/lib/CodeGen/ModuloSchedule.cpp index b974fa98..20aecdf 100644 --- a/llvm/lib/CodeGen/ModuloSchedule.cpp +++ b/llvm/lib/CodeGen/ModuloSchedule.cpp @@ -158,7 +158,7 @@ void ModuloScheduleExpander::generatePipelinedLoop() { SmallVector<MachineBasicBlock *, 4> EpilogBBs; // Generate the epilog instructions to complete the pipeline. - generateEpilog(MaxStageCount, KernelBB, VRMap, EpilogBBs, PrologBBs); + generateEpilog(MaxStageCount, KernelBB, BB, VRMap, EpilogBBs, PrologBBs); // We need this step because the register allocation doesn't handle some // situations well, so we insert copies to help out. @@ -240,11 +240,9 @@ void ModuloScheduleExpander::generateProlog(unsigned LastStage, /// Generate the pipeline epilog code. The epilog code finishes the iterations /// that were started in either the prolog or the kernel. We create a basic /// block for each stage that needs to complete. -void ModuloScheduleExpander::generateEpilog(unsigned LastStage, - MachineBasicBlock *KernelBB, - ValueMapTy *VRMap, - MBBVectorTy &EpilogBBs, - MBBVectorTy &PrologBBs) { +void ModuloScheduleExpander::generateEpilog( + unsigned LastStage, MachineBasicBlock *KernelBB, MachineBasicBlock *OrigBB, + ValueMapTy *VRMap, MBBVectorTy &EpilogBBs, MBBVectorTy &PrologBBs) { // We need to change the branch from the kernel to the first epilog block, so // this call to analyze branch uses the kernel rather than the original BB. MachineBasicBlock *TBB = nullptr, *FBB = nullptr; @@ -314,7 +312,12 @@ void ModuloScheduleExpander::generateEpilog(unsigned LastStage, // Create a branch to the new epilog from the kernel. // Remove the original branch and add a new branch to the epilog. TII->removeBranch(*KernelBB); - TII->insertBranch(*KernelBB, KernelBB, EpilogStart, Cond, DebugLoc()); + assert((OrigBB == TBB || OrigBB == FBB) && + "Unable to determine looping branch direction"); + if (OrigBB != TBB) + TII->insertBranch(*KernelBB, EpilogStart, KernelBB, Cond, DebugLoc()); + else + TII->insertBranch(*KernelBB, KernelBB, EpilogStart, Cond, DebugLoc()); // Add a branch to the loop exit. if (EpilogBBs.size() > 0) { MachineBasicBlock *LastEpilogBB = EpilogBBs.back(); |