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: Merge arithcx into addx/subfx #10120

Merged
merged 3 commits into from Dec 20, 2021

Conversation

Sintendo
Copy link
Member

Various optimizations for addx/subfx can be applied to addcx/subfcx as well. Rather than painstakingly replicating these optimizations in arithcx, I feel it makes more sense to remove it entirely and just add handling for the carry flag to addx/subfx.


addcx

Optimize for size

Before:

BE 01 00 00 00       mov         esi,1
03 75 A8             add         esi,dword ptr [rbp-58h]

After:

8B 75 A8             mov         esi,dword ptr [rbp-58h]
83 C6 01             add         esi,1
Optimize constant zero

Before:

44 8B C7             mov         r8d,edi
41 83 C0 00          add         r8d,0

After:

44 8B C7             mov         r8d,edi
F8                   clc

subfcx

Optimize constant a and b (Example 1)

Before:

BE 00 00 00 00       mov         esi,0
83 EE 08             sub         esi,8

After:

F8                   clc
Optimize constant a and b (Example 2)

Before:

41 BF FF 00 00 00    mov         r15d,0FFh
41 83 EF 08          sub         r15d,8

After:

F9                   stc
Optimize b == 0

Before:

41 B8 00 00 00 00    mov         r8d,0
45 2B C6             sub         r8d,r14d

After:

45 8B C6             mov         r8d,r14d
41 F7 D8             neg         r8d
Optimize constant a

Before:

41 BE 08 00 00 00    mov         r14d,8
41 8B C6             mov         eax,r14d
44 8B F6             mov         r14d,esi
44 2B F0             sub         r14d,eax

After:

44 8B F6             mov         r14d,esi
41 83 EE 08          sub         r14d,8
Optimize a == 0

Before:

44 8B EE             mov         r13d,esi
41 83 ED 00          sub         r13d,0

After:

44 8B EE             mov         r13d,esi
F9                   stc

JitArm64 also opts to separate the two. The shared logic makes less
sense once we start adding more optimizations.
They are extremely similar and can share nearly all optimizations.
Again, logic and optimizations are mostly the same so it makes sense.
@JMC47 JMC47 merged commit 1714dc6 into dolphin-emu:master Dec 20, 2021
10 checks passed
@Sintendo Sintendo deleted the jit64arithcxrefactor branch December 22, 2021 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants