JIT: Avoid xchg for resolution (#81216)
authorJakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
Wed, 1 Feb 2023 10:12:25 +0000 (11:12 +0100)
committerGitHub <noreply@github.com>
Wed, 1 Feb 2023 10:12:25 +0000 (11:12 +0100)
commit842ec4aaa723daaf2ce5d6d8931d09773ae55831
treea8504d0d0841abf84d0ca789e3be6d44db89d723
parent351d2bfde86a6c2dce3825a68724f95541bc63f2
JIT: Avoid xchg for resolution (#81216)

LSRA today uses xchg for reg-reg resolution when there are cycles in the
resolution graph. Benchmarks show that xchg is handled much less
efficiently by Intel CPUs than using a few movs with a temporary
register. This PR enables using temporary registers for this kind of
resolution on xarch (it was already enabled for non-xarch
architectures). xchg is still used on xarch if no temporary register is
available.

Additionally this PR adds support for getting a temporary register even
for shared critical edges. Before this change we would spill on
non-xarch for this case.

Finally, we now try to prefer a non callee saved temporary register so
that we don't need to save/restore it in prolog/epilog.

This mostly fixes the string hashcode regressions from #80743.
src/coreclr/jit/lsra.cpp
src/coreclr/jit/lsra.h