Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jit64: addx revisited #9464

Merged
merged 1 commit into from Jun 28, 2021
Merged

Conversation

Sintendo
Copy link
Member

@Sintendo Sintendo commented Jan 22, 2021

This doesn't really add any new optimizations, but fixes an issue that prevented the optimizations introduced in #8551 and #8755 from being applied in specific cases. A similar issue was solved for subfx as part of #9425.

Consider the case where the destination register is also an input register and happens to hold an immediate value. This results in a set of constraints that forces the RegCache to allocate a register and move the immediate value into it for us. By the time we check for immediate values in the JIT, we're too late.

We solve this by refactoring the code in such a way that we can check for immediates before involving the RegCache.


Example 1

Before:

41 BF 00 68 00 CC    mov         r15d,0CC006800h
44 03 FF             add         r15d,edi

After:

44 8D BF 00 68 00 CC lea         r15d,[rdi-33FF9800h]
Example 2

Before:

41 BE 00 00 00 00    mov         r14d,0
44 03 F7             add         r14d,edi

After:

44 8B F7             mov         r14d,edi
Example 3

Before:

41 BD 03 00 00 00    mov         r13d,3
44 03 6D 8C          add         r13d,dword ptr [rbp-74h]

After:

44 8B 6D 8C          mov         r13d,dword ptr [rbp-74h]
41 83 C5 03          add         r13d,3

@Rumi-Larry
Copy link

FYI, all of the examples are labeled "1"

@Sintendo
Copy link
Member Author

FYI, all of the examples are labeled "1"

Oops, thanks for pointing that out.

This doesn't really add any new optimizations, but fixes an issue that
prevented the optimizations introduced in dolphin-emu#8551 and dolphin-emu#8755 from being
applied in specific cases. A similar issue was solved for subfx as part
of dolphin-emu#9425.

Consider the case where the destination register is also an input
register and happens to hold an immediate value. This results in a set
of constraints that forces the RegCache to allocate a register and move
the immediate value into it for us. By the time we check for immediate
values in the JIT, we're too late.

We solve this by refactoring the code in such a way that we can check
for immediates before involving the RegCache.

- Example 1
Before:
41 BF 00 68 00 CC    mov         r15d,0CC006800h
44 03 FF             add         r15d,edi

After:
44 8D BF 00 68 00 CC lea         r15d,[rdi-33FF9800h]

- Example 2
Before:
41 BE 00 00 00 00    mov         r14d,0
44 03 F7             add         r14d,edi

After:
44 8B F7             mov         r14d,edi

- Example 3
Before:
41 BD 03 00 00 00    mov         r13d,3
44 03 6D 8C          add         r13d,dword ptr [rbp-74h]

After:
44 8B 6D 8C          mov         r13d,dword ptr [rbp-74h]
41 83 C5 03          add         r13d,3
@JMC47
Copy link
Contributor

JMC47 commented Mar 3, 2021

Is there any more comments/complaints to this?

@ghost
Copy link

ghost commented May 22, 2021

Can I test on my Redmi Note 9 android phone?

@Pokechu22
Copy link
Contributor

This change affects the x64 JIT, not the ARM JIT. Most android devices use ARM, so I don't think this would have any meaningful impact there.

@Rumi-Larry
Copy link

Poking this pr

@JosJuice JosJuice merged commit 2ef2eee into dolphin-emu:master Jun 28, 2021
10 checks passed
@Sintendo Sintendo deleted the jit64addxreloaded branch June 28, 2021 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
7 participants