@@ -979,7 +979,43 @@ int LinearScanRA::linearScanRA()
979
979
globalLinearScan ra (gra, &l, globalLiveIntervals, &preAssignedLiveIntervals, inputIntervals, pregManager,
980
980
mem, numRegLRA, numRowsEOT, latestLexID,
981
981
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)
983
1019
{
984
1020
undoLinearScanRAAssignments ();
985
1021
return VISA_FAILURE;
@@ -1019,10 +1055,6 @@ int LinearScanRA::linearScanRA()
1019
1055
COUT_ERROR << " ===== printSpillLiveIntervals============" << std::endl;
1020
1056
printSpillLiveIntervals (spillLRs);
1021
1057
#endif
1022
- for (auto lr : spillLRs)
1023
- {
1024
- GRFSpillFillCount += lr->getNumRefs ();
1025
- }
1026
1058
1027
1059
// update jit metadata information for spill
1028
1060
if (auto jitInfo = builder.getJitInfo ())
@@ -1066,33 +1098,6 @@ int LinearScanRA::linearScanRA()
1066
1098
std::cout << " \t\t GRFSpillFillCount: " << GRFSpillFillCount << " \n " ;
1067
1099
}
1068
1100
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
-
1096
1101
iterator++;
1097
1102
} while (spillLRs.size () && iterator < MAXIMAL_ITERATIONS);
1098
1103
@@ -2279,7 +2284,7 @@ bool globalLinearScan::runLinearScan(IR_Builder& builder, std::vector<LSLiveRang
2279
2284
COUT_ERROR << " Failed to spill registers for " << lr->getTopDcl ()->getName () << " , rows :" << lr->getTopDcl ()->getNumRows () << std::endl;
2280
2285
printActives ();
2281
2286
#endif
2282
- spillLRs. push_back (lr) ;
2287
+ return false ;
2283
2288
}
2284
2289
}
2285
2290
}
0 commit comments