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: subfic - Optimize constants for d != a #9817

Merged
merged 1 commit into from Jun 17, 2021

Conversation

Sintendo
Copy link
Member

@Sintendo Sintendo commented Jun 15, 2021

These optimizations were already present, but only when d == a. They also make sense when this condition does not hold.


imm == 0

Before:

41 BB 00 00 00 00    mov         r11d,0
45 2B DF             sub         r11d,r15d

After:

45 8B DF             mov         r11d,r15d
41 F7 DB             neg         r11d
imm == -1

Before:

41 BD FF FF FF FF    mov         r13d,0FFFFFFFFh
44 2B EE             sub         r13d,esi
0F 93 45 68          setae       byte ptr [rbp+68h]

After:

44 8B EE             mov         r13d,esi
41 F7 D5             not         r13d
C6 45 68 01          mov         byte ptr [rbp+68h],1

Copy link
Member

@degasus degasus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, however I wonder if x64 has an 8bit sign extended immediate mov instruction. This should lead to the same code size and maybe with a lower latency.

These optimizations were already present, but only when d == a. They
also make sense when this condition does not hold.

- imm == 0
Before:
41 BB 00 00 00 00    mov         r11d,0
45 2B DF             sub         r11d,r15d

After:
45 8B DF             mov         r11d,r15d
41 F7 DB             neg         r11d

- imm == -1
Before:
41 BD FF FF FF FF    mov         r13d,0FFFFFFFFh
44 2B EE             sub         r13d,esi
0F 93 45 68          setae       byte ptr [rbp+68h]

After:
44 8B EE             mov         r13d,esi
41 F7 D5             not         r13d
C6 45 68 01          mov         byte ptr [rbp+68h],1
@Sintendo
Copy link
Member Author

Unfortunately, there is no such instruction. In fact, of all the x64 'core' instructions, MOV and TEST are the only ones to lack a compact encoding for 8-bit signed immediates.

@degasus degasus merged commit b530d9b into dolphin-emu:master Jun 17, 2021
11 checks passed
@Sintendo Sintendo deleted the jit64subfic branch June 17, 2021 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants