[RyuJIT][LSRA] Let variables within a loop use register first #8846
Labels
area-CodeGen-coreclr
CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
enhancement
Product code improvement that does NOT require public API changes/additions
optimization
tenet-performance
Performance related issue
Milestone
Consider this code:
it generated following assembly code on Windows x64 .Net Core 2.0
As we can see
a~h
is holding registeresi~r13
yetxa~xf
always use stack.Then I write another version:
And run a benchmark, gives
SampleB is much faster because it let
xa~xf
use register, the following 100 cycles will also use these registers.I dig a bit with lldb on Linux x64, here is what's happing during LSRA form SampleA:
Notice it's on Linux x64 so the registers doesn't match with the assembly code above.
isPhysRegRef
, the interval of f holding rax will spillisPhysRegRef
, the interval of g holding rax will spillisPhysRegRef
, the interval of h holding rax will spillisPhysRegRef
, the interval of xa holding rax will spillDuring the process, allocateBusyReg is not used at all,
I can see getWeight(refPos of st.lclvar a) is 200 and getWeight(refPos of st.lclvar xa) is 800, but xa has no chance to get the register.
On the contrary, gcc and clang can handle this situation very well:
category:cq
theme:register-allocator
skill-level:expert
cost:large
The text was updated successfully, but these errors were encountered: