@@ -5544,42 +5544,17 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
5544
5544
doBankConflict, availableGregs, availableSubRegs, availableAddrs, availableFlags, weakEdgeUsage);
5545
5545
bool noIndirForceSpills = builder.getOption (vISA_NoIndirectForceSpills);
5546
5546
5547
- auto & varSplitPass = *gra.getVarSplitPass ();
5548
-
5549
- auto assignColor = [&](LiveRange* lr)
5547
+ // colorOrder is in reverse order (unconstrained at front)
5548
+ for (auto iter = colorOrder.rbegin (), iterEnd = colorOrder.rend (); iter != iterEnd; ++iter)
5550
5549
{
5550
+ LiveRange* lr = *iter;
5551
5551
auto lrVar = lr->getVar ();
5552
5552
5553
5553
//
5554
- // assign register to live ranges
5554
+ // assign regiser to live ranges
5555
5555
//
5556
5556
if (lr->getPhyReg () == NULL && !lrVar->isSpilled () && !lr->getIsPartialDcl ()) // no assigned register yet and not spilled
5557
5557
{
5558
- G4_Declare* parentDcl = nullptr ;
5559
- bool skipParentIntf = false ;
5560
- if (lr->hasAllocHint ())
5561
- {
5562
- parms.startGRFReg = lr->getAllocHint ();
5563
- if (varSplitPass.isPartialDcl (lr->getDcl ()))
5564
- {
5565
- parentDcl = varSplitPass.getParentDcl (lr->getDcl ());
5566
- auto parentGRF = parentDcl->getRegVar ()->getPhyReg ();
5567
- if (!parentGRF && parentDcl->getRegVar ()->isRegAllocPartaker ())
5568
- {
5569
- parentGRF = lrs[parentDcl->getRegVar ()->getId ()]->getPhyReg ();
5570
- }
5571
- if (parentGRF)
5572
- {
5573
- auto siblingNum = varSplitPass.getSiblingNum (lr->getDcl ());
5574
- auto parentGRFNum = parentGRF->asGreg ()->getRegNum ();
5575
- auto forbiddenStart = parentGRFNum + ((siblingNum + 1 ) * lr->getDcl ()->getNumRows ());
5576
- auto forbiddenEnd = parentGRFNum + parentDcl->getNumRows ();
5577
- lr->markForbidden (forbiddenStart, forbiddenEnd - forbiddenStart);
5578
- skipParentIntf = true ;
5579
- }
5580
- }
5581
- }
5582
-
5583
5558
unsigned lr_id = lrVar->getId ();
5584
5559
//
5585
5560
// compute what registers are already assigned
@@ -5588,6 +5563,7 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
5588
5563
5589
5564
std::vector<unsigned int >& intfs = intf.getSparseIntfForVar (lr_id);
5590
5565
auto weakEdgeSet = intf.getCompatibleSparseIntf (lrVar->getDeclare ()->getRootDeclare ());
5566
+
5591
5567
for (auto it : intfs)
5592
5568
{
5593
5569
LiveRange* lrTemp = lrs[it];
@@ -5598,9 +5574,6 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
5598
5574
continue ;
5599
5575
}
5600
5576
5601
- if (skipParentIntf && lrTemp->getDcl () == parentDcl)
5602
- continue ;
5603
-
5604
5577
regUsage.updateRegUsage (lrTemp);
5605
5578
}
5606
5579
}
@@ -5656,6 +5629,7 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
5656
5629
5657
5630
ColorHeuristic heuristic = colorHeuristicGRF;
5658
5631
5632
+
5659
5633
bool failed_alloc = false ;
5660
5634
G4_Declare* dcl = lrVar->getDeclare ();
5661
5635
@@ -5680,7 +5654,7 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
5680
5654
// When evenAlignNeeded is true, it is binding for correctness
5681
5655
bool evenAlignNeeded = gra.isEvenAligned (lrVar->getDeclare ());
5682
5656
BankAlign align = evenAlignNeeded ? BankAlign::Even : BankAlign::Either;
5683
- if (allocFromBanks && !lr-> hasAllocHint () )
5657
+ if (allocFromBanks)
5684
5658
{
5685
5659
5686
5660
if (!isHybrid && oneGRFBankDivision &&
@@ -5694,8 +5668,7 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
5694
5668
else
5695
5669
{
5696
5670
failed_alloc |= !regUsage.assignRegs (highInternalConflict, lr, lr->getForbidden (),
5697
- align, gra.getSubRegAlign (lrVar->getDeclare ()), heuristic, lr->getSpillCost (),
5698
- lr->hasAllocHint ());
5671
+ align, gra.getSubRegAlign (lrVar->getDeclare ()), heuristic, lr->getSpillCost ());
5699
5672
}
5700
5673
}
5701
5674
@@ -5723,52 +5696,11 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
5723
5696
spilledLRs.push_back (lr);
5724
5697
}
5725
5698
}
5726
- else
5727
- {
5728
- // Allocation succeeded, set hint if this is a split/child dcl
5729
- if (varSplitPass.isSplitDcl (dcl) || varSplitPass.isPartialDcl (dcl))
5730
- {
5731
- varSplitPass.writeHints (dcl, lrs);
5732
- }
5733
- }
5734
5699
}
5735
5700
#ifdef DEBUG_VERBOSE_ON
5736
5701
lr->dump ();
5737
5702
COUT_ERROR << std::endl;
5738
5703
#endif
5739
- return true ;
5740
- };
5741
-
5742
- // colorOrder is in reverse order (unconstrained at front)
5743
- for (auto iter = colorOrder.rbegin (), iterEnd = colorOrder.rend (); iter != iterEnd; ++iter)
5744
- {
5745
- auto lr = (*iter);
5746
- bool ret = assignColor (lr);
5747
-
5748
- // early exit
5749
- if (!ret)
5750
- return false ;
5751
-
5752
- if (gra.getIterNo () == 0 )
5753
- {
5754
- if (varSplitPass.isSplitDcl (lr->getDcl ()))
5755
- {
5756
- // Try allocating children, out of order in hopes
5757
- // of getting a coalescable assignment
5758
- auto children = varSplitPass.getChildren (lr->getDcl ());
5759
- for (auto child : *children)
5760
- {
5761
- if (child->getRegVar ()->isRegAllocPartaker ())
5762
- {
5763
- auto childLR = lrs[child->getRegVar ()->getId ()];
5764
- if (!childLR->getPhyReg ())
5765
- {
5766
- assignColor (childLR);
5767
- }
5768
- }
5769
- }
5770
- }
5771
- }
5772
5704
}
5773
5705
5774
5706
// record RA type
@@ -8934,7 +8866,6 @@ int GlobalRA::coloringRegAlloc()
8934
8866
{
8935
8867
std::cout << " --GRF RA iteration " << iterationNo << " --\n " ;
8936
8868
}
8937
- setIterNo (iterationNo);
8938
8869
8939
8870
resetGlobalRAStates ();
8940
8871
0 commit comments