@@ -1022,7 +1022,7 @@ void BankConflictPass::setupBankConflictsForBBTGL(G4_BB *bb,
1022
1022
} else {
1023
1023
setupBankConflictsforMad(inst);
1024
1024
}
1025
- } else if (gra.kernel.getOption(vISA_forceBCR) && !forGlobal &&
1025
+ } else if (gra.forceBCR && !forGlobal &&
1026
1026
inst->getNumSrc() == 2) {
1027
1027
threeSourceInstNum++;
1028
1028
setupBankConflictsforMad(inst);
@@ -3499,7 +3499,7 @@ bool Augmentation::markNonDefaultMaskDef() {
3499
3499
nonDefaultMaskDefFound = true;
3500
3500
}
3501
3501
3502
- if (kernel.getOption(vISA_forceBCR) &&
3502
+ if (gra.favorBCR &&
3503
3503
gra.getBankConflict(dcl) != BANK_CONFLICT_NONE) {
3504
3504
gra.setAugmentationMask(dcl, AugmentationMasks::NonDefault);
3505
3505
nonDefaultMaskDefFound = true;
@@ -6660,7 +6660,6 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF,
6660
6660
6661
6661
bool failed_alloc = false;
6662
6662
G4_Declare *dcl = lrVar->getDeclare();
6663
-
6664
6663
if (!(noIndirForceSpills && liveAnalysis.isAddressSensitive(lr_id)) &&
6665
6664
forceSpill &&
6666
6665
(dcl->getRegFile() == G4_GRF || dcl->getRegFile() == G4_FLAG) &&
@@ -6723,7 +6722,7 @@ bool GraphColor::assignColors(ColorHeuristic colorHeuristicGRF,
6723
6722
// pass) then abort on spill
6724
6723
//
6725
6724
if ((heuristic == ROUND_ROBIN ||
6726
- (doBankConflict && !kernel.getOption(vISA_forceBCR) )) &&
6725
+ (doBankConflict && !gra.forceBCR )) &&
6727
6726
(lr->getRegKind() == G4_GRF || lr->getRegKind() == G4_FLAG)) {
6728
6727
return false;
6729
6728
} else if (kernel.fg.isPseudoDcl(dcl)) {
@@ -7345,7 +7344,7 @@ bool GraphColor::regAlloc(bool doBankConflictReduction,
7345
7344
return false;
7346
7345
}
7347
7346
7348
- if (!kernel.getOption(vISA_forceBCR) ) {
7347
+ if (!gra.forceBCR ) {
7349
7348
if (!success && doBankConflictReduction) {
7350
7349
resetTemporaryRegisterAssignments();
7351
7350
assignColors(FIRST_FIT);
@@ -10113,6 +10112,16 @@ bool GlobalRA::tryHybridRA() {
10113
10112
return true;
10114
10113
}
10115
10114
10115
+ //Skip hybridRA if BCR is needed
10116
+ if (favorBCR) {
10117
+ lra.undoLocalRAAssignments(true);
10118
+ // Restore alignment in case LRA modified it
10119
+ copyAlignment();
10120
+ //reset favorBCR
10121
+ favorBCR = forceBCR;
10122
+ return false;
10123
+ }
10124
+
10116
10125
if (useHybridRAwithSpill) {
10117
10126
insertPhyRegDecls();
10118
10127
} else {
@@ -10433,14 +10442,14 @@ std::pair<bool, bool> GlobalRA::bankConflict() {
10433
10442
bool doBankConflictReduction = false, highInternalConflict = false;
10434
10443
if (builder.getOption(vISA_LocalBankConflictReduction) &&
10435
10444
builder.hasBankCollision()) {
10436
- bool reduceBCInRR = false;
10437
- bool reduceBCInTAandFF = false;
10445
+ bool reduceBC = false;
10446
+ bool threeSouceBCR = false;
10438
10447
BankConflictPass bc(*this, true);
10439
10448
10440
- reduceBCInRR = bc.setupBankConflictsForKernel(
10441
- true, reduceBCInTAandFF , SECOND_HALF_BANK_START_GRF * 2,
10449
+ reduceBC = bc.setupBankConflictsForKernel(
10450
+ true, threeSouceBCR , SECOND_HALF_BANK_START_GRF * 2,
10442
10451
highInternalConflict);
10443
- doBankConflictReduction = reduceBCInRR && reduceBCInTAandFF ;
10452
+ doBankConflictReduction = reduceBC && threeSouceBCR ;
10444
10453
}
10445
10454
return std::make_pair(doBankConflictReduction, highInternalConflict);
10446
10455
}
@@ -10771,11 +10780,8 @@ GlobalRA::insertSpillCode(bool enableSpillSpaceCompression,
10771
10780
10772
10781
bool GlobalRA::rerunGRAIter(bool rerunGRA)
10773
10782
{
10774
- if (getIterNo() == 0 && (rerunGRA || kernel.getOption(vISA_forceBCR))) {
10775
- if (kernel.getOption(vISA_forceBCR)) {
10776
- // FIXME: We shouldn't modify options. Use local bool flag instead.
10777
- kernel.getOptions()->setOption(vISA_forceBCR, false);
10778
- }
10783
+ if (getIterNo() == 0 && (rerunGRA || forceBCR)) {
10784
+ forceBCR = false;
10779
10785
return true;
10780
10786
}
10781
10787
return false;
@@ -10993,6 +10999,7 @@ int GlobalRA::coloringRegAlloc() {
10993
10999
if (!fastCompile) {
10994
11000
rpe.run();
10995
11001
writeVerboseRPEStats(rpe);
11002
+ favorBCR |= doBankConflictReduction && (rpe.getMaxRP() < kernel.getNumRegTotal() - 16);
10996
11003
}
10997
11004
GraphColor coloring(liveAnalysis, false, forceSpill);
10998
11005
0 commit comments