[RV64_DYNAREC] Minor optim to 8 bit TEST opcode (#2583)

This commit is contained in:
Yang Liu 2025-04-29 02:32:54 +08:00 committed by GitHub
parent 25de8bd35c
commit f72d43b77e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 13 deletions

View File

@ -263,8 +263,13 @@ uintptr_t dynarec64_00_2(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_FUSION);
nextop = F8;
GETEB(x1, 0);
GETGB(x2);
emit_test8(dyn, ninst, x1, x2, x6, x4, x5);
if (GB_EQ_EB())
u8 = x1;
else {
GETGB(x2);
u8 = x2;
}
emit_test8(dyn, ninst, x1, u8, x6, x4, x5);
break;
case 0x85:
INST_NAME("TEST Ed, Gd");
@ -845,10 +850,9 @@ uintptr_t dynarec64_00_2(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
case 0xA8:
INST_NAME("TEST AL, Ib");
SETFLAGS(X_ALL, SF_SET_PENDING, NAT_FLAGS_FUSION);
ANDI(x1, xRAX, 0xff);
u8 = F8;
MOV32w(x2, u8);
emit_test8(dyn, ninst, x1, x2, x3, x4, x5);
ADDI(x2, xZR, u8);
emit_test8(dyn, ninst, x2, xRAX, x3, x4, x5);
break;
case 0xA9:
INST_NAME("TEST EAX, Id");

View File

@ -315,29 +315,29 @@ void emit_test8(dynarec_rv64_t* dyn, int ninst, int s1, int s2, int s3, int s4,
SET_DFNONE();
}
AND(s3, s1, s2); // res = s1 & s2
if (s1 != s2) AND(s1, s1, s2); // res = s1 & s2
IFX_PENDOR0 {
SD(s3, xEmu, offsetof(x64emu_t, res));
SD(s1, xEmu, offsetof(x64emu_t, res));
}
if (dyn->insts[ninst].nat_flags_fusion) NAT_FLAGS_OPS(s3, xZR);
if (dyn->insts[ninst].nat_flags_fusion) NAT_FLAGS_OPS(s1, xZR);
IFX (X_SF) {
SRLI(s4, s3, 7);
SRLI(s4, s1, 7);
SET_FLAGS_NEZ(s4, F_SF, s5);
}
IFX (X_ZF) {
SET_FLAGS_EQZ(s3, F_ZF, s5);
SET_FLAGS_EQZ(s1, F_ZF, s5);
}
IFX (X_PF) {
emit_pf(dyn, ninst, s3, s4, s5);
emit_pf(dyn, ninst, s1, s4, s5);
}
NAT_FLAGS_ENABLE_SIGN();
if (dyn->insts[ninst].nat_flags_fusion && dyn->insts[ninst].nat_flags_needsign) {
SLLI(s3, s3, 56);
SRAI(s3, s3, 56);
SLLI(s1, s1, 56);
SRAI(s1, s1, 56);
}
}

View File

@ -394,6 +394,7 @@
OR(wback, wback, ed); \
}
#define GB_EQ_EB() (MODREG && ((nextop & 0x38) >> 3) == (nextop & 7) && (rex.r == rex.b))
#define YMM0(a) ymm_mark_zero(dyn, ninst, a);