FunctionSpecialization: Make the ordering of BestSpecs stricter

otherwise it's not guaranteed which of two candidates with the same
score would get specialized first, or at all.
This commit is contained in:
Hans Wennborg 2024-06-12 13:54:06 +02:00
parent 0e346eeac6
commit 575e68e571

View File

@ -689,7 +689,9 @@ bool FunctionSpecializer::run() {
// specialization budget, which is derived from maximum number of
// specializations per specialization candidate function.
auto CompareScore = [&AllSpecs](unsigned I, unsigned J) {
return AllSpecs[I].Score > AllSpecs[J].Score;
if (AllSpecs[I].Score != AllSpecs[J].Score)
return AllSpecs[I].Score > AllSpecs[J].Score;
return I > J;
};
const unsigned NSpecs =
std::min(NumCandidates * MaxClones, unsigned(AllSpecs.size()));