aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachinePipeliner.cpp
diff options
context:
space:
mode:
authorDavid Penry <david.penry@arm.com>2022-04-28 13:23:22 -0700
committerDavid Penry <david.penry@arm.com>2022-04-28 13:29:27 -0700
commitfa49021c68ef7a7adcdf7b8a44b9006506523191 (patch)
tree8a6803d1e2da889a45767c8866a6cf51d5fb8101 /llvm/lib/CodeGen/MachinePipeliner.cpp
parentab17ed0723fc715c752a71e59d3cef03cafcb68f (diff)
downloadllvm-fa49021c68ef7a7adcdf7b8a44b9006506523191.zip
llvm-fa49021c68ef7a7adcdf7b8a44b9006506523191.tar.gz
llvm-fa49021c68ef7a7adcdf7b8a44b9006506523191.tar.bz2
Revert "[CodeGen][ARM] Enable Swing Module Scheduling for ARM"
This reverts commit 28d09bbbc3d09c912b54a4d5edb32cab7de32a6f while I investigate a buildbot failure.
Diffstat (limited to 'llvm/lib/CodeGen/MachinePipeliner.cpp')
-rw-r--r--llvm/lib/CodeGen/MachinePipeliner.cpp97
1 files changed, 8 insertions, 89 deletions
diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp
index 9ea6e9b..0bffa91 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -255,7 +255,6 @@ bool MachinePipeliner::scheduleLoop(MachineLoop &L) {
<< "Failed to pipeline loop";
});
- LI.LoopPipelinerInfo.reset();
return Changed;
}
@@ -263,7 +262,6 @@ bool MachinePipeliner::scheduleLoop(MachineLoop &L) {
Changed = swingModuloScheduler(L);
- LI.LoopPipelinerInfo.reset();
return Changed;
}
@@ -356,8 +354,7 @@ bool MachinePipeliner::canPipelineLoop(MachineLoop &L) {
LI.LoopInductionVar = nullptr;
LI.LoopCompare = nullptr;
- LI.LoopPipelinerInfo = TII->analyzeLoopForPipelining(L.getTopBlock());
- if (!LI.LoopPipelinerInfo) {
+ if (!TII->analyzeLoopForPipelining(L.getTopBlock())) {
LLVM_DEBUG(dbgs() << "Unable to analyzeLoop, can NOT pipeline Loop\n");
NumFailLoop++;
ORE->emit([&]() {
@@ -422,7 +419,7 @@ bool MachinePipeliner::swingModuloScheduler(MachineLoop &L) {
assert(L.getBlocks().size() == 1 && "SMS works on single blocks only.");
SwingSchedulerDAG SMS(*this, L, getAnalysis<LiveIntervals>(), RegClassInfo,
- II_setByPragma, LI.LoopPipelinerInfo.get());
+ II_setByPragma);
MachineBasicBlock *MBB = L.getHeader();
// The kernel should not include any terminator instructions. These
@@ -1425,7 +1422,7 @@ void SwingSchedulerDAG::CopyToPhiMutation::apply(ScheduleDAGInstrs *DAG) {
/// We ignore the back-edge recurrence in order to avoid unbounded recursion
/// in the calculation of the ASAP, ALAP, etc functions.
static bool ignoreDependence(const SDep &D, bool isPred) {
- if (D.isArtificial() || D.getSUnit()->isBoundaryNode())
+ if (D.isArtificial())
return true;
return D.getKind() == SDep::Anti && isPred;
}
@@ -1474,8 +1471,6 @@ void SwingSchedulerDAG::computeNodeFunctions(NodeSetType &NodeSets) {
SUnit *SU = &SUnits[I];
for (const SDep &S : SU->Succs) {
SUnit *succ = S.getSUnit();
- if (succ->isBoundaryNode())
- continue;
if (S.getLatency() == 0)
zeroLatencyHeight =
std::max(zeroLatencyHeight, getZeroLatencyHeight(succ) + 1);
@@ -1793,8 +1788,7 @@ void SwingSchedulerDAG::addConnectedNodes(SUnit *SU, NodeSet &NewSet,
NodesAdded.insert(SU);
for (auto &SI : SU->Succs) {
SUnit *Successor = SI.getSUnit();
- if (!SI.isArtificial() && !Successor->isBoundaryNode() &&
- NodesAdded.count(Successor) == 0)
+ if (!SI.isArtificial() && NodesAdded.count(Successor) == 0)
addConnectedNodes(Successor, NewSet, NodesAdded);
}
for (auto &PI : SU->Preds) {
@@ -2086,11 +2080,6 @@ bool SwingSchedulerDAG::schedulePipeline(SMSchedule &Schedule) {
});
} while (++NI != NE && scheduleFound);
- // If a schedule is found, ensure non-pipelined instructions are in stage 0
- if (scheduleFound)
- scheduleFound =
- Schedule.normalizeNonPipelinedInstructions(this, LoopPipelinerInfo);
-
// If a schedule is found, check if it is a valid schedule too.
if (scheduleFound)
scheduleFound = Schedule.isValidSchedule(this);
@@ -2274,7 +2263,7 @@ MachineInstr *SwingSchedulerDAG::findDefInLoop(Register Reg) {
bool SwingSchedulerDAG::isLoopCarriedDep(SUnit *Source, const SDep &Dep,
bool isSucc) {
if ((Dep.getKind() != SDep::Order && Dep.getKind() != SDep::Output) ||
- Dep.isArtificial() || Dep.getSUnit()->isBoundaryNode())
+ Dep.isArtificial())
return false;
if (!SwpPruneLoopCarried)
@@ -2441,7 +2430,7 @@ int SMSchedule::latestCycleInChain(const SDep &Dep) {
while (!Worklist.empty()) {
const SDep &Cur = Worklist.pop_back_val();
SUnit *SuccSU = Cur.getSUnit();
- if (Visited.count(SuccSU) || SuccSU->isBoundaryNode())
+ if (Visited.count(SuccSU))
continue;
std::map<SUnit *, int>::const_iterator it = InstrToCycle.find(SuccSU);
if (it == InstrToCycle.end())
@@ -2708,91 +2697,21 @@ bool SMSchedule::isLoopCarriedDefOfUse(SwingSchedulerDAG *SSD,
return false;
}
-/// Determine transitive dependences of unpipelineable instructions
-SmallSet<SUnit *, 8> SMSchedule::computeUnpipelineableNodes(
- SwingSchedulerDAG *SSD, TargetInstrInfo::PipelinerLoopInfo *PLI) {
- SmallSet<SUnit *, 8> DoNotPipeline;
- SmallVector<SUnit *, 8> Worklist;
-
- for (auto &SU : SSD->SUnits)
- if (SU.isInstr() && PLI->shouldIgnoreForPipelining(SU.getInstr()))
- Worklist.push_back(&SU);
-
- while (!Worklist.empty()) {
- auto SU = Worklist.pop_back_val();
- if (DoNotPipeline.count(SU))
- continue;
- LLVM_DEBUG(dbgs() << "Do not pipeline SU(" << SU->NodeNum << ")\n");
- DoNotPipeline.insert(SU);
- for (auto &Dep : SU->Preds)
- Worklist.push_back(Dep.getSUnit());
- if (SU->getInstr()->isPHI())
- for (auto &Dep : SU->Succs)
- if (Dep.getKind() == SDep::Anti)
- Worklist.push_back(Dep.getSUnit());
- }
- return DoNotPipeline;
-}
-
-// Determine all instructions upon which any unpipelineable instruction depends
-// and ensure that they are in stage 0. If unable to do so, return false.
-bool SMSchedule::normalizeNonPipelinedInstructions(
- SwingSchedulerDAG *SSD, TargetInstrInfo::PipelinerLoopInfo *PLI) {
- SmallSet<SUnit *, 8> DNP = computeUnpipelineableNodes(SSD, PLI);
-
- int NewLastCycle = INT_MIN;
- for (SUnit &SU : SSD->SUnits) {
- if (!SU.isInstr())
- continue;
- if (!DNP.contains(&SU) || stageScheduled(&SU) == 0) {
- NewLastCycle = std::max(NewLastCycle, InstrToCycle[&SU]);
- continue;
- }
-
- // Put the non-pipelined instruction as early as possible in the schedule
- int NewCycle = getFirstCycle();
- for (auto &Dep : SU.Preds)
- NewCycle = std::max(InstrToCycle[Dep.getSUnit()], NewCycle);
-
- int OldCycle = InstrToCycle[&SU];
- if (OldCycle != NewCycle) {
- InstrToCycle[&SU] = NewCycle;
- auto &OldS = getInstructions(OldCycle);
- OldS.erase(std::remove(OldS.begin(), OldS.end(), &SU), OldS.end());
- getInstructions(NewCycle).emplace_back(&SU);
- LLVM_DEBUG(dbgs() << "SU(" << SU.NodeNum
- << ") is not pipelined; moving from cycle " << OldCycle
- << " to " << NewCycle << " Instr:" << *SU.getInstr());
- }
- NewLastCycle = std::max(NewLastCycle, NewCycle);
- }
- LastCycle = NewLastCycle;
- return true;
-}
-
// Check if the generated schedule is valid. This function checks if
// an instruction that uses a physical register is scheduled in a
// different stage than the definition. The pipeliner does not handle
// physical register values that may cross a basic block boundary.
-// Furthermore, if a physical def/use pair is assigned to the same
-// cycle, orderDependence does not guarantee def/use ordering, so that
-// case should be considered invalid. (The test checks for both
-// earlier and same-cycle use to be more robust.)
bool SMSchedule::isValidSchedule(SwingSchedulerDAG *SSD) {
for (SUnit &SU : SSD->SUnits) {
if (!SU.hasPhysRegDefs)
continue;
int StageDef = stageScheduled(&SU);
- int CycleDef = InstrToCycle[&SU];
assert(StageDef != -1 && "Instruction should have been scheduled.");
for (auto &SI : SU.Succs)
- if (SI.isAssignedRegDep() && !SI.getSUnit()->isBoundaryNode())
- if (Register::isPhysicalRegister(SI.getReg())) {
+ if (SI.isAssignedRegDep())
+ if (Register::isPhysicalRegister(SI.getReg()))
if (stageScheduled(SI.getSUnit()) != StageDef)
return false;
- if (InstrToCycle[SI.getSUnit()] <= CycleDef)
- return false;
- }
}
return true;
}