diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 1f517b52326f39..52d96c229f3dc3 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -6138,6 +6138,9 @@ class Compiler // written to, and SZ-array element type equivalence classes updated. void optComputeLoopSideEffects(); + // Compute the sets of long and float vars (lvaLongVars, lvaFloatVars). + void optComputeInterestingVarSets(); + #ifdef DEBUG bool optAnyChildNotRemoved(unsigned loopNum); #endif // DEBUG diff --git a/src/coreclr/jit/optimizer.cpp b/src/coreclr/jit/optimizer.cpp index da63679b4319cb..16c7ec94c7f357 100644 --- a/src/coreclr/jit/optimizer.cpp +++ b/src/coreclr/jit/optimizer.cpp @@ -6670,6 +6670,8 @@ PhaseStatus Compiler::optHoistLoopCode() } #endif + optComputeInterestingVarSets(); + // Consider all the loop nests, in inner-to-outer order // bool modified = false; @@ -6824,9 +6826,8 @@ bool Compiler::optHoistThisLoop(unsigned lnum, LoopHoistContext* hoistCtxt, Basi pLoopDsc->lpHoistAddedPreheader = false; #ifndef TARGET_64BIT - unsigned longVarsCount = VarSetOps::Count(this, lvaLongVars); - if (longVarsCount > 0) + if (!VarSetOps::IsEmpty(this, lvaLongVars)) { // Since 64-bit variables take up two registers on 32-bit targets, we increase // the Counts such that each TYP_LONG variable counts twice. @@ -6861,9 +6862,7 @@ bool Compiler::optHoistThisLoop(unsigned lnum, LoopHoistContext* hoistCtxt, Basi } #endif - unsigned floatVarsCount = VarSetOps::Count(this, lvaFloatVars); - - if (floatVarsCount > 0) + if (!VarSetOps::IsEmpty(this, lvaFloatVars)) { VARSET_TP loopFPVars(VarSetOps::Intersection(this, loopVars, lvaFloatVars)); VARSET_TP inOutFPVars(VarSetOps::Intersection(this, pLoopDsc->lpVarInOut, lvaFloatVars)); @@ -6888,7 +6887,7 @@ bool Compiler::optHoistThisLoop(unsigned lnum, LoopHoistContext* hoistCtxt, Basi } #endif } - else // (floatVarsCount == 0) + else // lvaFloatVars is empty { pLoopDsc->lpLoopVarFPCount = 0; pLoopDsc->lpVarInOutFPCount = 0; @@ -8489,7 +8488,10 @@ void Compiler::optComputeLoopSideEffects() optComputeLoopNestSideEffects(lnum); } } +} +void Compiler::optComputeInterestingVarSets() +{ VarSetOps::AssignNoCopy(this, lvaFloatVars, VarSetOps::MakeEmpty(this)); #ifndef TARGET_64BIT VarSetOps::AssignNoCopy(this, lvaLongVars, VarSetOps::MakeEmpty(this));