From c4a1cdceaebf8d01151fc20ae3e3a053180db9e7 Mon Sep 17 00:00:00 2001 From: Yuriy Sydorov <jura@cp-lab.com> Date: Mon, 1 Nov 2021 12:19:45 +0200 Subject: [PATCH] * Corrected calculation of spilling efficiency. --- compiler/rgobj.pas | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/compiler/rgobj.pas b/compiler/rgobj.pas index 419c56b7ea..0f14e75e82 100644 --- a/compiler/rgobj.pas +++ b/compiler/rgobj.pas @@ -3013,7 +3013,7 @@ unit rgobj; Higher value is better. } var - i,spillingcounter,max_weight:longint; + i,j,spillingcounter,max_weight:longint; all_weight,spill_weight,d: double; begin max_weight:=1; @@ -3027,17 +3027,22 @@ unit rgobj; all_weight:=0; for i:=first_imaginary to maxreg-1 do with reginfo[i] do - begin - d:=weight/max_weight; - all_weight:=all_weight+d; - if (weight>100) and - (i<=high(spillinfo)) and - spillinfo[i].spilled then - begin - inc(spillingcounter); - spill_weight:=spill_weight+d; - end; - end; + if not (ri_spill_helper in flags) then + begin + d:=weight/max_weight; + all_weight:=all_weight+d; + if (ri_coalesced in flags) and (alias>=first_imaginary) then + j:=alias + else + j:=i; + if (reginfo[j].weight>100) and + (j<=high(spillinfo)) and + spillinfo[j].spilled then + begin + inc(spillingcounter); + spill_weight:=spill_weight+d; + end; + end; if spillingcounter>0 then begin d:=(1.0-spill_weight/all_weight)*100.0;