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
Conversation
3a9294c
to
2c9dc1f
Compare
7ddfefd
to
e258345
Compare
@@ -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.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
e258345
to
db24597
Compare
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.
db24597
to
3aa40da
Compare
Code looks ok. What games/homebrew have you tested this on? |
I have reviewed some of this and it looks reasonable. ☂ |
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).