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: optimize CA calculations #852

Merged
merged 13 commits into from Sep 5, 2014
Merged

Conversation

FioraAeterna
Copy link
Contributor

JIT64: optimize CA calculations

Omit carry calculations that get overwritten later in the block before they're used. Very common in the case of srawix and friends.

I previously had a patch to do PS1 optimizations too here but I dropped it for now because it was becoming rather scary and messy (and still broken).

Please only review the last patch in this PR; the others are just patches that it depends on (the FPRF branch and integeropts branch).

@FioraAeterna FioraAeterna force-pushed the optimizeca branch 2 times, most recently from 3a9294c to 2c9dc1f Compare August 22, 2014 04:25
@FioraAeterna FioraAeterna changed the title JIT64: optimize carry calculations JIT64: optimize CA + PS1 calculations Aug 22, 2014
@FioraAeterna FioraAeterna force-pushed the optimizeca branch 3 times, most recently from 7ddfefd to e258345 Compare August 22, 2014 11:08
@FioraAeterna FioraAeterna changed the title JIT64: optimize CA + PS1 calculations JIT64: optimize CA calculations Aug 22, 2014
@@ -34,7 +34,7 @@ static GekkoOPTemplate primarytable[] =
{10, Interpreter::cmpli, {"cmpli", OPTYPE_INTEGER, FL_IN_A | FL_SET_CRn, 1, 0, 0, 0}},
{11, Interpreter::cmpi, {"cmpi", OPTYPE_INTEGER, FL_IN_A | FL_SET_CRn, 1, 0, 0, 0}},
{12, Interpreter::addic, {"addic", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A | FL_SET_CA, 1, 0, 0, 0}},
{13, Interpreter::addic_rc, {"addic_rc", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A | FL_SET_CR0, 1, 0, 0, 0}},
{ 13, Interpreter::addic_rc, { "addic_rc", OPTYPE_INTEGER, FL_OUT_D | FL_IN_A | FL_SET_CA | FL_SET_CR0, 1, 0, 0, 0 } },

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Also remove unused pow2/pow2f functions.
Factor out common code and handle a few more common cases.
Take advantage of movzx as a replacement for anding with 0xff or 0xffff, and
abuse loads from the register cache to save ops.
Use TEST instead of CMP if we're comparing against 0 (rather common), and
optimize the case of immediate compares further.
Also remove some comments that no longer apply since x86_32 was dropped.
Register B gets immediately moved into the shift register, so even if a == b
it doesn't need to be loaded.
Carries are rather common and unpredictable, so do them branchlessly wherever
we can.
Shift by 31 and 1, both of which are pretty common, can be done in a few less
instructions. Tested with a hwtest.
Not quite as common a branch instruction as cmpwi, but close.
Omit carry calculations that get overwritten later in the block before they're
used. Very common in the case of srawix and friends.
@skidau
Copy link
Contributor

skidau commented Sep 4, 2014

Code looks ok. What games/homebrew have you tested this on?

@comex
Copy link
Contributor

comex commented Sep 4, 2014

I have reviewed some of this and it looks reasonable. ☂

comex added a commit that referenced this pull request Sep 5, 2014
JIT64: optimize CA calculations
@comex comex merged commit 97420c6 into dolphin-emu:master Sep 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants