@@ -255,15 +255,13 @@ bool MachinePipeliner::scheduleLoop(MachineLoop &L) {
255
255
<< " Failed to pipeline loop" ;
256
256
});
257
257
258
- LI.LoopPipelinerInfo .reset ();
259
258
return Changed;
260
259
}
261
260
262
261
++NumTrytoPipeline;
263
262
264
263
Changed = swingModuloScheduler (L);
265
264
266
- LI.LoopPipelinerInfo .reset ();
267
265
return Changed;
268
266
}
269
267
@@ -356,8 +354,7 @@ bool MachinePipeliner::canPipelineLoop(MachineLoop &L) {
356
354
357
355
LI.LoopInductionVar = nullptr ;
358
356
LI.LoopCompare = nullptr ;
359
- LI.LoopPipelinerInfo = TII->analyzeLoopForPipelining (L.getTopBlock ());
360
- if (!LI.LoopPipelinerInfo ) {
357
+ if (!TII->analyzeLoopForPipelining (L.getTopBlock ())) {
361
358
LLVM_DEBUG (dbgs () << " Unable to analyzeLoop, can NOT pipeline Loop\n " );
362
359
NumFailLoop++;
363
360
ORE->emit ([&]() {
@@ -422,7 +419,7 @@ bool MachinePipeliner::swingModuloScheduler(MachineLoop &L) {
422
419
assert (L.getBlocks ().size () == 1 && " SMS works on single blocks only." );
423
420
424
421
SwingSchedulerDAG SMS (*this , L, getAnalysis<LiveIntervals>(), RegClassInfo,
425
- II_setByPragma, LI. LoopPipelinerInfo . get () );
422
+ II_setByPragma);
426
423
427
424
MachineBasicBlock *MBB = L.getHeader ();
428
425
// The kernel should not include any terminator instructions. These
@@ -1425,7 +1422,7 @@ void SwingSchedulerDAG::CopyToPhiMutation::apply(ScheduleDAGInstrs *DAG) {
1425
1422
// / We ignore the back-edge recurrence in order to avoid unbounded recursion
1426
1423
// / in the calculation of the ASAP, ALAP, etc functions.
1427
1424
static bool ignoreDependence (const SDep &D, bool isPred) {
1428
- if (D.isArtificial () || D. getSUnit ()-> isBoundaryNode () )
1425
+ if (D.isArtificial ())
1429
1426
return true ;
1430
1427
return D.getKind () == SDep::Anti && isPred;
1431
1428
}
@@ -1474,8 +1471,6 @@ void SwingSchedulerDAG::computeNodeFunctions(NodeSetType &NodeSets) {
1474
1471
SUnit *SU = &SUnits[I];
1475
1472
for (const SDep &S : SU->Succs ) {
1476
1473
SUnit *succ = S.getSUnit ();
1477
- if (succ->isBoundaryNode ())
1478
- continue ;
1479
1474
if (S.getLatency () == 0 )
1480
1475
zeroLatencyHeight =
1481
1476
std::max (zeroLatencyHeight, getZeroLatencyHeight (succ) + 1 );
@@ -1793,8 +1788,7 @@ void SwingSchedulerDAG::addConnectedNodes(SUnit *SU, NodeSet &NewSet,
1793
1788
NodesAdded.insert (SU);
1794
1789
for (auto &SI : SU->Succs ) {
1795
1790
SUnit *Successor = SI.getSUnit ();
1796
- if (!SI.isArtificial () && !Successor->isBoundaryNode () &&
1797
- NodesAdded.count (Successor) == 0 )
1791
+ if (!SI.isArtificial () && NodesAdded.count (Successor) == 0 )
1798
1792
addConnectedNodes (Successor, NewSet, NodesAdded);
1799
1793
}
1800
1794
for (auto &PI : SU->Preds ) {
@@ -2086,11 +2080,6 @@ bool SwingSchedulerDAG::schedulePipeline(SMSchedule &Schedule) {
2086
2080
});
2087
2081
} while (++NI != NE && scheduleFound);
2088
2082
2089
- // If a schedule is found, ensure non-pipelined instructions are in stage 0
2090
- if (scheduleFound)
2091
- scheduleFound =
2092
- Schedule.normalizeNonPipelinedInstructions (this , LoopPipelinerInfo);
2093
-
2094
2083
// If a schedule is found, check if it is a valid schedule too.
2095
2084
if (scheduleFound)
2096
2085
scheduleFound = Schedule.isValidSchedule (this );
@@ -2274,7 +2263,7 @@ MachineInstr *SwingSchedulerDAG::findDefInLoop(Register Reg) {
2274
2263
bool SwingSchedulerDAG::isLoopCarriedDep (SUnit *Source, const SDep &Dep,
2275
2264
bool isSucc) {
2276
2265
if ((Dep.getKind () != SDep::Order && Dep.getKind () != SDep::Output) ||
2277
- Dep.isArtificial () || Dep. getSUnit ()-> isBoundaryNode () )
2266
+ Dep.isArtificial ())
2278
2267
return false ;
2279
2268
2280
2269
if (!SwpPruneLoopCarried)
@@ -2441,7 +2430,7 @@ int SMSchedule::latestCycleInChain(const SDep &Dep) {
2441
2430
while (!Worklist.empty ()) {
2442
2431
const SDep &Cur = Worklist.pop_back_val ();
2443
2432
SUnit *SuccSU = Cur.getSUnit ();
2444
- if (Visited.count (SuccSU) || SuccSU-> isBoundaryNode () )
2433
+ if (Visited.count (SuccSU))
2445
2434
continue ;
2446
2435
std::map<SUnit *, int >::const_iterator it = InstrToCycle.find (SuccSU);
2447
2436
if (it == InstrToCycle.end ())
@@ -2708,91 +2697,21 @@ bool SMSchedule::isLoopCarriedDefOfUse(SwingSchedulerDAG *SSD,
2708
2697
return false ;
2709
2698
}
2710
2699
2711
- // / Determine transitive dependences of unpipelineable instructions
2712
- SmallSet<SUnit *, 8 > SMSchedule::computeUnpipelineableNodes (
2713
- SwingSchedulerDAG *SSD, TargetInstrInfo::PipelinerLoopInfo *PLI) {
2714
- SmallSet<SUnit *, 8 > DoNotPipeline;
2715
- SmallVector<SUnit *, 8 > Worklist;
2716
-
2717
- for (auto &SU : SSD->SUnits )
2718
- if (SU.isInstr () && PLI->shouldIgnoreForPipelining (SU.getInstr ()))
2719
- Worklist.push_back (&SU);
2720
-
2721
- while (!Worklist.empty ()) {
2722
- auto SU = Worklist.pop_back_val ();
2723
- if (DoNotPipeline.count (SU))
2724
- continue ;
2725
- LLVM_DEBUG (dbgs () << " Do not pipeline SU(" << SU->NodeNum << " )\n " );
2726
- DoNotPipeline.insert (SU);
2727
- for (auto &Dep : SU->Preds )
2728
- Worklist.push_back (Dep.getSUnit ());
2729
- if (SU->getInstr ()->isPHI ())
2730
- for (auto &Dep : SU->Succs )
2731
- if (Dep.getKind () == SDep::Anti)
2732
- Worklist.push_back (Dep.getSUnit ());
2733
- }
2734
- return DoNotPipeline;
2735
- }
2736
-
2737
- // Determine all instructions upon which any unpipelineable instruction depends
2738
- // and ensure that they are in stage 0. If unable to do so, return false.
2739
- bool SMSchedule::normalizeNonPipelinedInstructions (
2740
- SwingSchedulerDAG *SSD, TargetInstrInfo::PipelinerLoopInfo *PLI) {
2741
- SmallSet<SUnit *, 8 > DNP = computeUnpipelineableNodes (SSD, PLI);
2742
-
2743
- int NewLastCycle = INT_MIN;
2744
- for (SUnit &SU : SSD->SUnits ) {
2745
- if (!SU.isInstr ())
2746
- continue ;
2747
- if (!DNP.contains (&SU) || stageScheduled (&SU) == 0 ) {
2748
- NewLastCycle = std::max (NewLastCycle, InstrToCycle[&SU]);
2749
- continue ;
2750
- }
2751
-
2752
- // Put the non-pipelined instruction as early as possible in the schedule
2753
- int NewCycle = getFirstCycle ();
2754
- for (auto &Dep : SU.Preds )
2755
- NewCycle = std::max (InstrToCycle[Dep.getSUnit ()], NewCycle);
2756
-
2757
- int OldCycle = InstrToCycle[&SU];
2758
- if (OldCycle != NewCycle) {
2759
- InstrToCycle[&SU] = NewCycle;
2760
- auto &OldS = getInstructions (OldCycle);
2761
- OldS.erase (std::remove (OldS.begin (), OldS.end (), &SU), OldS.end ());
2762
- getInstructions (NewCycle).emplace_back (&SU);
2763
- LLVM_DEBUG (dbgs () << " SU(" << SU.NodeNum
2764
- << " ) is not pipelined; moving from cycle " << OldCycle
2765
- << " to " << NewCycle << " Instr:" << *SU.getInstr ());
2766
- }
2767
- NewLastCycle = std::max (NewLastCycle, NewCycle);
2768
- }
2769
- LastCycle = NewLastCycle;
2770
- return true ;
2771
- }
2772
-
2773
2700
// Check if the generated schedule is valid. This function checks if
2774
2701
// an instruction that uses a physical register is scheduled in a
2775
2702
// different stage than the definition. The pipeliner does not handle
2776
2703
// physical register values that may cross a basic block boundary.
2777
- // Furthermore, if a physical def/use pair is assigned to the same
2778
- // cycle, orderDependence does not guarantee def/use ordering, so that
2779
- // case should be considered invalid. (The test checks for both
2780
- // earlier and same-cycle use to be more robust.)
2781
2704
bool SMSchedule::isValidSchedule (SwingSchedulerDAG *SSD) {
2782
2705
for (SUnit &SU : SSD->SUnits ) {
2783
2706
if (!SU.hasPhysRegDefs )
2784
2707
continue ;
2785
2708
int StageDef = stageScheduled (&SU);
2786
- int CycleDef = InstrToCycle[&SU];
2787
2709
assert (StageDef != -1 && " Instruction should have been scheduled." );
2788
2710
for (auto &SI : SU.Succs )
2789
- if (SI.isAssignedRegDep () && !SI. getSUnit ()-> isBoundaryNode () )
2790
- if (Register::isPhysicalRegister (SI.getReg ())) {
2711
+ if (SI.isAssignedRegDep ())
2712
+ if (Register::isPhysicalRegister (SI.getReg ()))
2791
2713
if (stageScheduled (SI.getSUnit ()) != StageDef)
2792
2714
return false ;
2793
- if (InstrToCycle[SI.getSUnit ()] <= CycleDef)
2794
- return false ;
2795
- }
2796
2715
}
2797
2716
return true ;
2798
2717
}
0 commit comments