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

DSPJit: Various minor improvements #9008

Merged
merged 3 commits into from Aug 8, 2020
Merged

Conversation

Sintendo
Copy link
Member

@Sintendo Sintendo commented Aug 5, 2020

See commit messages for details.

- LEA is a bit silly when the source and the destination are the same. A
simple ADD or SHL will do in those cases.

66 8D 04 45 00 00 00 00 lea         ax,[rax*2]
66 03 C0                add         ax,ax

48 8D 04 00             lea         rax,[rax+rax]
48 03 C0                add         rax,rax

66 8D 14 D5 00 00 00 00 lea         dx,[rdx*8]
66 C1 E2 03             shl         dx,3

- When scaling by 2, consider summing the register with itself instead.
The former always needs a 32-bit displacement, so the sum is more
compact.

66 8D 14 45 00 00 00 00 lea dx,[rax*2]
66 8D 14 00             lea dx,[rax+rax]
There's no need to load the 64-bit immediate into a temporary register.
x64 will sign-extend 32-bit immediates to 64 bits, giving us the exact
value we need in this case.

48 C7 C0 00 00 FF FF    mov         rax,0FFFFFFFFFFFF0000h
48 21 C2                and         rdx,rax

48 81 E2 00 00 FF FF    and         rdx,0FFFFFFFFFFFF0000h
The intent here is to generate a more compact instruction if a 32-bit
immediate can be zero-extended to the desired 64-bit immediate.

Nowadays the emitter is smart enough to do this for us, so this logic is
redundant.
Copy link
Member

@BhaaLseN BhaaLseN left a comment

Choose a reason for hiding this comment

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

Code changes seem good, untested tho.

@Tilka Tilka merged commit 340c08a into dolphin-emu:master Aug 8, 2020
10 checks passed
@Sintendo Sintendo deleted the dspjitlea branch October 5, 2020 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants