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

[RV64_DYNAREC] Optimized XOR Ew, Gw when Ew == Gw #1289

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 62 additions & 8 deletions src/dynarec/rv64/dynarec_rv64_66.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,73 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
INST_NAME("XOR Ew, Gw");
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGW(x2);
GETEW(x1, 0);
emit_xor16(dyn, ninst, x1, x2, x4, x5, x6);
EWBACK;
// try to determine ed and gd
ed = 0;
GETGD;
if (MODREG) {
GETED(0);
}
if (ed == gd) {
// optimize XOR Gw, Gw
CLEAR_FLAGS();
IFX(X_PEND) {
SET_DF(x6, d_xor16);
} else IFX(X_ALL) {
SET_DFNONE();
}
SRLI(ed, ed, 16);
SLLI(ed, ed, 16);
IFX(X_PEND) {
SH(ed, xEmu, offsetof(x64emu_t, res));
}
IFX(X_ZF) {
ORI(xFlags, xFlags, 1 << F_ZF);
}
IFX(X_PF) {
ORI(xFlags, xFlags, 1 << F_PF);
}
} else {
GETGW(x2);
GETEW(x1, 0);
emit_xor16(dyn, ninst, x1, x2, x4, x5, x6);
EWBACK;
}
break;
case 0x33:
INST_NAME("XOR Gw, Ew");
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGW(x1);
GETEW(x2, 0);
emit_xor16(dyn, ninst, x1, x2, x4, x5, x6);
GWBACK;
// try to determine ed and gd
ed = 0;
GETGD;
if (MODREG) {
GETED(0);
}
if (ed == gd) {
// optimize XOR Gw, Gw
CLEAR_FLAGS();
IFX(X_PEND) {
SET_DF(x6, d_xor16);
} else IFX(X_ALL) {
SET_DFNONE();
}
SRLI(ed, ed, 16);
SLLI(ed, ed, 16);
IFX(X_PEND) {
SH(ed, xEmu, offsetof(x64emu_t, res));
}
IFX(X_ZF) {
ORI(xFlags, xFlags, 1 << F_ZF);
}
IFX(X_PF) {
ORI(xFlags, xFlags, 1 << F_PF);
}
} else {
GETGW(x1);
GETEW(x2, 0);
emit_xor16(dyn, ninst, x1, x2, x4, x5, x6);
GWBACK;
}
break;
case 0x35:
INST_NAME("XOR AX, Iw");
Expand Down
Loading