Ensure that all of the calculations for PerfScore are done using doubles (dotnet...
authorBrian Sullivan <briansul@microsoft.com>
Tue, 22 Oct 2019 21:04:41 +0000 (14:04 -0700)
committerGitHub <noreply@github.com>
Tue, 22 Oct 2019 21:04:41 +0000 (14:04 -0700)
Ensure that all of the calculations for PerfScore are done using doubles

Commit migrated from https://github.com/dotnet/coreclr/commit/020a8c44cc9606bf06b107597cd853533981bbd3

src/coreclr/src/jit/codegencommon.cpp
src/coreclr/src/jit/emit.cpp

index 4b60f94..15b584d 100644 (file)
@@ -2298,8 +2298,10 @@ void CodeGen::genGenerateCode(void** codePtr, ULONG* nativeSizeOfCode)
 
 #if defined(DEBUG) || defined(LATE_DISASM)
     // Add code size information into the Perf Score
-    compiler->info.compPerfScore += (compiler->info.compTotalHotCodeSize * PERFSCORE_CODESIZE_COST_HOT);
-    compiler->info.compPerfScore += (compiler->info.compTotalColdCodeSize * PERFSCORE_CODESIZE_COST_COLD);
+    // All compPerfScore calculations must be performed using doubles
+    compiler->info.compPerfScore += ((double)compiler->info.compTotalHotCodeSize * (double)PERFSCORE_CODESIZE_COST_HOT);
+    compiler->info.compPerfScore +=
+        ((double)compiler->info.compTotalColdCodeSize * (double)PERFSCORE_CODESIZE_COST_COLD);
 #endif // DEBUG || LATE_DISASM
 
 #ifdef DEBUG
index d9da0b2..ce00b19 100644 (file)
@@ -3414,7 +3414,8 @@ size_t emitter::emitIssue1Instr(insGroup* ig, instrDesc* id, BYTE** dp)
 
 #if defined(DEBUG) || defined(LATE_DISASM)
     float insExeCost = insEvaluateExecutionCost(id);
-    emitComp->info.compPerfScore += (ig->igWeight / BB_UNITY_WEIGHT) * insExeCost;
+    // All compPerfScore calculations must be performed using doubles
+    emitComp->info.compPerfScore += (double)(ig->igWeight / (double)BB_UNITY_WEIGHT) * insExeCost;
 #endif // defined(DEBUG) || defined(LATE_DISASM)
 
 // printf("[S=%02u]\n", emitCurStackLvl);