-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[JIT] Optimization for CMP REG, 0xFFFFFFFF(FFFFFFFF) -> INC REG #52523
[JIT] Optimization for CMP REG, 0xFFFFFFFF(FFFFFFFF) -> INC REG #52523
Conversation
If def DISPLAY_SIZES = 1 in jit.h, then gives and error
If def DISPLAY_SIZES = 1, gives an error
because of intersection of names "dataSize" between "compiler.h" and in "codegenarm64.cpp"
transfer local declaration for dataSize
// "INC REG" instead of "CMP REG, 0xFFFFFFFF" (or just - if "CMP REG, -1") | ||
if (op1->isUsedFromReg() && op2->IsIntegralConst(-1) && targetReg != REG_NA) | ||
{ | ||
emit->emitIns_R(INS_inc, emitTypeSize(tree), op1->GetRegNum()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand this optimization - doesn't it modify op1 reg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good point! My big mistake. Yes, it changes the logic of the program by modify op1 value. Thank you.
Per Agner (see https://www.agner.org/optimize/microarchitecture.pdf, Sec. 12.6, Table 12.1), this might suppress macro-op fusion? |
Optimization for (example):
If in REG 0xFFFFFFFF, then instead of CMP => INC REG, thus the ZF flag changes in 1, and SETcc set byte in returned REG
If there are any pitfalls here, please explain to me.
Before:
After:
SPMI:
https://gist.github.com/DarkBullNull/1ea1218c1260b4ddb232ac2e07cf8c01