OSDN Git Service

[optimizing] Improve x86 parallel moves/swaps
authorMark Mendell <mark.p.mendell@intel.com>
Wed, 1 Apr 2015 16:51:05 +0000 (12:51 -0400)
committerMark Mendell <mark.p.mendell@intel.com>
Fri, 10 Apr 2015 16:08:31 +0000 (12:08 -0400)
commita5c19ce8d200d68a528f2ce0ebff989106c4a933
tree4638a8d8e5b1562ec5ed05967490fec1ef7f0d17
parent6d80318c382a3490ab605b46fa7cb22c5e823fec
[optimizing] Improve x86 parallel moves/swaps

Add a new constructor to ScratchRegisterScope that will supply a
register if there is a free one, but not spill to force one.  Use this
to generated alternate code that doesn't use a temporary, as the
spill/restore of a register generates extra instructions that aren't
necessary on x86.

Here is the benefit for a 32 bit memory-to-memory exchange with no
free registers:
<        50            push eax
<        53            push ebx
<  8B44244C            mov eax, [esp + 76]
<  8B5C246C            mov ebx, [esp + 108]
<  8944246C            mov [esp + 108], eax
<  895C244C            mov [esp + 76], ebx
<        5B            pop ebx
<        58            pop eax
---
>  FF742444            push [esp + 68]
>  FF742468            push [esp + 104]
>  8F44244C            pop [esp + 72]
>  8F442468            pop [esp + 100]

Avoid using xchg instruction, as it is slow on smaller processors.

Change-Id: Id29ee3abd998577baaee552d55d23e60ae0c7871
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
compiler/optimizing/code_generator_x86.cc
compiler/optimizing/code_generator_x86.h
compiler/optimizing/code_generator_x86_64.cc
compiler/optimizing/code_generator_x86_64.h
compiler/optimizing/parallel_move_resolver.cc
compiler/optimizing/parallel_move_resolver.h