@@ -5544,42 +5544,17 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
55445544 doBankConflict, availableGregs, availableSubRegs, availableAddrs, availableFlags, weakEdgeUsage);
55455545 bool noIndirForceSpills = builder.getOption (vISA_NoIndirectForceSpills);
55465546
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)
55505549 {
5550+ LiveRange* lr = *iter;
55515551 auto lrVar = lr->getVar ();
55525552
55535553 //
5554- // assign register to live ranges
5554+ // assign regiser to live ranges
55555555 //
55565556 if (lr->getPhyReg () == NULL && !lrVar->isSpilled () && !lr->getIsPartialDcl ()) // no assigned register yet and not spilled
55575557 {
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-
55835558 unsigned lr_id = lrVar->getId ();
55845559 //
55855560 // compute what registers are already assigned
@@ -5588,6 +5563,7 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
55885563
55895564 std::vector<unsigned int >& intfs = intf.getSparseIntfForVar (lr_id);
55905565 auto weakEdgeSet = intf.getCompatibleSparseIntf (lrVar->getDeclare ()->getRootDeclare ());
5566+
55915567 for (auto it : intfs)
55925568 {
55935569 LiveRange* lrTemp = lrs[it];
@@ -5598,9 +5574,6 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
55985574 continue ;
55995575 }
56005576
5601- if (skipParentIntf && lrTemp->getDcl () == parentDcl)
5602- continue ;
5603-
56045577 regUsage.updateRegUsage (lrTemp);
56055578 }
56065579 }
@@ -5656,6 +5629,7 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
56565629
56575630 ColorHeuristic heuristic = colorHeuristicGRF;
56585631
5632+
56595633 bool failed_alloc = false ;
56605634 G4_Declare* dcl = lrVar->getDeclare ();
56615635
@@ -5680,7 +5654,7 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
56805654 // When evenAlignNeeded is true, it is binding for correctness
56815655 bool evenAlignNeeded = gra.isEvenAligned (lrVar->getDeclare ());
56825656 BankAlign align = evenAlignNeeded ? BankAlign::Even : BankAlign::Either;
5683- if (allocFromBanks && !lr-> hasAllocHint () )
5657+ if (allocFromBanks)
56845658 {
56855659
56865660 if (!isHybrid && oneGRFBankDivision &&
@@ -5694,8 +5668,7 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
56945668 else
56955669 {
56965670 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 ());
56995672 }
57005673 }
57015674
@@ -5723,52 +5696,11 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF, bool doBankConfl
57235696 spilledLRs.push_back (lr);
57245697 }
57255698 }
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- }
57345699 }
57355700#ifdef DEBUG_VERBOSE_ON
57365701 lr->dump ();
57375702 COUT_ERROR << std::endl;
57385703#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- }
57725704 }
57735705
57745706 // record RA type
@@ -8934,7 +8866,6 @@ int GlobalRA::coloringRegAlloc()
89348866 {
89358867 std::cout << " --GRF RA iteration " << iterationNo << " --\n " ;
89368868 }
8937- setIterNo (iterationNo);
89388869
89398870 resetGlobalRAStates ();
89408871
0 commit comments