@@ -480,7 +480,8 @@ void ScheduleDAGMI::enterRegion(MachineBasicBlock *bb,
480
480
{
481
481
ScheduleDAGInstrs::enterRegion (bb, begin, end, regioninstrs);
482
482
483
- ShouldTrackPressure = EnableRegPressure;
483
+ ShouldTrackPressure =
484
+ EnableRegPressure && SchedImpl->shouldTrackPressure (regioninstrs);
484
485
485
486
// For convenience remember the end of the liveness region.
486
487
LiveRegionEnd =
@@ -1583,6 +1584,7 @@ class ConvergingScheduler : public MachineSchedStrategy {
1583
1584
};
1584
1585
1585
1586
private:
1587
+ const MachineSchedContext *Context;
1586
1588
ScheduleDAGMI *DAG;
1587
1589
const TargetSchedModel *SchedModel;
1588
1590
const TargetRegisterInfo *TRI;
@@ -1600,8 +1602,11 @@ class ConvergingScheduler : public MachineSchedStrategy {
1600
1602
LogMaxQID = 2
1601
1603
};
1602
1604
1603
- ConvergingScheduler ():
1604
- DAG (0 ), SchedModel(0 ), TRI(0 ), Top(TopQID, " TopQ" ), Bot(BotQID, " BotQ" ) {}
1605
+ ConvergingScheduler (const MachineSchedContext *C):
1606
+ Context (C), DAG(0 ), SchedModel(0 ), TRI(0 ),
1607
+ Top (TopQID, " TopQ" ), Bot(BotQID, " BotQ" ) {}
1608
+
1609
+ virtual bool shouldTrackPressure (unsigned NumRegionInstrs);
1605
1610
1606
1611
virtual void initialize (ScheduleDAGMI *dag);
1607
1612
@@ -1669,6 +1674,16 @@ init(ScheduleDAGMI *dag, const TargetSchedModel *smodel, SchedRemainder *rem) {
1669
1674
ExecutedResCounts.resize (SchedModel->getNumProcResourceKinds ());
1670
1675
}
1671
1676
1677
+ // / Avoid setting up the register pressure tracker for small regions to save
1678
+ // / compile time. As a rough heuristic, only track pressure when the number
1679
+ // / of schedulable instructions exceeds half the integer register file.
1680
+ bool ConvergingScheduler::shouldTrackPressure (unsigned NumRegionInstrs) {
1681
+ unsigned NIntRegs = Context->RegClassInfo ->getNumAllocatableRegs (
1682
+ Context->MF ->getTarget ().getTargetLowering ()->getRegClassFor (MVT::i32 ));
1683
+
1684
+ return NumRegionInstrs > (NIntRegs / 2 );
1685
+ }
1686
+
1672
1687
void ConvergingScheduler::initialize (ScheduleDAGMI *dag) {
1673
1688
DAG = dag;
1674
1689
SchedModel = DAG->getSchedModel ();
@@ -2371,7 +2386,7 @@ void ConvergingScheduler::tryCandidate(SchedCandidate &Cand,
2371
2386
const RegPressureTracker &RPTracker,
2372
2387
RegPressureTracker &TempTracker) {
2373
2388
2374
- if (DAG->shouldTrackPressure ()) {
2389
+ if (DAG->isTrackingPressure ()) {
2375
2390
// Always initialize TryCand's RPDelta.
2376
2391
if (Zone.isTop ()) {
2377
2392
TempTracker.getMaxDownwardPressureDelta (
@@ -2413,19 +2428,19 @@ void ConvergingScheduler::tryCandidate(SchedCandidate &Cand,
2413
2428
2414
2429
// Avoid exceeding the target's limit. If signed PSetID is negative, it is
2415
2430
// invalid; convert it to INT_MAX to give it lowest priority.
2416
- if (DAG->shouldTrackPressure () && tryPressure (TryCand.RPDelta .Excess ,
2417
- Cand.RPDelta .Excess ,
2418
- TryCand, Cand, RegExcess))
2431
+ if (DAG->isTrackingPressure () && tryPressure (TryCand.RPDelta .Excess ,
2432
+ Cand.RPDelta .Excess ,
2433
+ TryCand, Cand, RegExcess))
2419
2434
return ;
2420
2435
2421
2436
// For loops that are acyclic path limited, aggressively schedule for latency.
2422
2437
if (Rem.IsAcyclicLatencyLimited && tryLatency (TryCand, Cand, Zone))
2423
2438
return ;
2424
2439
2425
2440
// Avoid increasing the max critical pressure in the scheduled region.
2426
- if (DAG->shouldTrackPressure () && tryPressure (TryCand.RPDelta .CriticalMax ,
2427
- Cand.RPDelta .CriticalMax ,
2428
- TryCand, Cand, RegCritical))
2441
+ if (DAG->isTrackingPressure () && tryPressure (TryCand.RPDelta .CriticalMax ,
2442
+ Cand.RPDelta .CriticalMax ,
2443
+ TryCand, Cand, RegCritical))
2429
2444
return ;
2430
2445
2431
2446
// Keep clustered nodes together to encourage downstream peephole
@@ -2447,9 +2462,9 @@ void ConvergingScheduler::tryCandidate(SchedCandidate &Cand,
2447
2462
return ;
2448
2463
}
2449
2464
// Avoid increasing the max pressure of the entire region.
2450
- if (DAG->shouldTrackPressure () && tryPressure (TryCand.RPDelta .CurrentMax ,
2451
- Cand.RPDelta .CurrentMax ,
2452
- TryCand, Cand, RegMax))
2465
+ if (DAG->isTrackingPressure () && tryPressure (TryCand.RPDelta .CurrentMax ,
2466
+ Cand.RPDelta .CurrentMax ,
2467
+ TryCand, Cand, RegMax))
2453
2468
return ;
2454
2469
2455
2470
// Avoid critical resource consumption and balance the schedule.
@@ -2744,9 +2759,7 @@ void ConvergingScheduler::schedNode(SUnit *SU, bool IsTopNode) {
2744
2759
// / Create the standard converging machine scheduler. This will be used as the
2745
2760
// / default scheduler if the target does not set a default.
2746
2761
static ScheduleDAGInstrs *createConvergingSched (MachineSchedContext *C) {
2747
- assert ((!ForceTopDown || !ForceBottomUp) &&
2748
- " -misched-topdown incompatible with -misched-bottomup" );
2749
- ScheduleDAGMI *DAG = new ScheduleDAGMI (C, new ConvergingScheduler ());
2762
+ ScheduleDAGMI *DAG = new ScheduleDAGMI (C, new ConvergingScheduler (C));
2750
2763
// Register DAG post-processors.
2751
2764
//
2752
2765
// FIXME: extend the mutation API to allow earlier mutations to instantiate
0 commit comments