@@ -979,7 +979,43 @@ int LinearScanRA::linearScanRA()
979979 globalLinearScan ra (gra, &l, globalLiveIntervals, &preAssignedLiveIntervals, inputIntervals, pregManager,
980980 mem, numRegLRA, numRowsEOT, latestLexID,
981981 doBCR, highInternalConflict);
982- if (!ra.runLinearScan (builder, globalLiveIntervals, spillLRs))
982+
983+ bool success = ra.runLinearScan (builder, globalLiveIntervals, spillLRs);
984+
985+ auto underSpillThreshold = [this ](int numSpill, int asmCount)
986+ {
987+ int threshold = std::min (builder.getOptions ()->getuInt32Option (vISA_AbortOnSpillThreshold), 200u );
988+ return (numSpill * 200 ) < (threshold * asmCount);
989+ };
990+
991+ for (auto lr : spillLRs)
992+ {
993+ GRFSpillFillCount += lr->getNumRefs ();
994+ }
995+
996+ int instNum = 0 ;
997+ for (auto bb : kernel.fg )
998+ {
999+ instNum += (int )bb->size ();
1000+ }
1001+ if (GRFSpillFillCount && builder.getOption (vISA_AbortOnSpill) && !underSpillThreshold (GRFSpillFillCount, instNum))
1002+ {
1003+ // update jit metadata information
1004+ if (auto jitInfo = builder.getJitInfo ())
1005+ {
1006+ jitInfo->isSpill = true ;
1007+ jitInfo->spillMemUsed = 0 ;
1008+ jitInfo->numAsmCount = instNum;
1009+ jitInfo->numGRFSpillFill = GRFSpillFillCount;
1010+ }
1011+
1012+ // Early exit when -abortonspill is passed, instead of
1013+ // spending time inserting spill code and then aborting.
1014+ return VISA_SPILL;
1015+ }
1016+
1017+ // Try other graphcoloring
1018+ if (!success)
9831019 {
9841020 undoLinearScanRAAssignments ();
9851021 return VISA_FAILURE;
@@ -1019,10 +1055,6 @@ int LinearScanRA::linearScanRA()
10191055 COUT_ERROR << " ===== printSpillLiveIntervals============" << std::endl;
10201056 printSpillLiveIntervals (spillLRs);
10211057#endif
1022- for (auto lr : spillLRs)
1023- {
1024- GRFSpillFillCount += lr->getNumRefs ();
1025- }
10261058
10271059 // update jit metadata information for spill
10281060 if (auto jitInfo = builder.getJitInfo ())
@@ -1066,33 +1098,6 @@ int LinearScanRA::linearScanRA()
10661098 std::cout << " \t\t GRFSpillFillCount: " << GRFSpillFillCount << " \n " ;
10671099 }
10681100
1069- auto underSpillThreshold = [this ](int numSpill, int asmCount)
1070- {
1071- int threshold = std::min (builder.getOptions ()->getuInt32Option (vISA_AbortOnSpillThreshold), 200u );
1072- return (numSpill * 200 ) < (threshold * asmCount);
1073- };
1074-
1075- int instNum = 0 ;
1076- for (auto bb : kernel.fg )
1077- {
1078- instNum += (int )bb->size ();
1079- }
1080- if (GRFSpillFillCount && builder.getOption (vISA_AbortOnSpill) && !underSpillThreshold (GRFSpillFillCount, instNum))
1081- {
1082- // update jit metadata information
1083- if (auto jitInfo = builder.getJitInfo ())
1084- {
1085- jitInfo->isSpill = true ;
1086- jitInfo->spillMemUsed = 0 ;
1087- jitInfo->numAsmCount = instNum;
1088- jitInfo->numGRFSpillFill = GRFSpillFillCount;
1089- }
1090-
1091- // Early exit when -abortonspill is passed, instead of
1092- // spending time inserting spill code and then aborting.
1093- return VISA_SPILL;
1094- }
1095-
10961101 iterator++;
10971102 } while (spillLRs.size () && iterator < MAXIMAL_ITERATIONS);
10981103
@@ -2279,7 +2284,7 @@ bool globalLinearScan::runLinearScan(IR_Builder& builder, std::vector<LSLiveRang
22792284 COUT_ERROR << " Failed to spill registers for " << lr->getTopDcl ()->getName () << " , rows :" << lr->getTopDcl ()->getNumRows () << std::endl;
22802285 printActives ();
22812286#endif
2282- spillLRs. push_back (lr) ;
2287+ return false ;
22832288 }
22842289 }
22852290 }
0 commit comments