diff options
| author | Yang Liu <liuyang22@iscas.ac.cn> | 2025-05-26 19:16:54 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-26 13:16:54 +0200 |
| commit | 77c2683762e3995bf7d598bcfea695a202e5d34f (patch) | |
| tree | c2076b80b46514126958ef40c87287482612759e /src | |
| parent | ae9ee3d9d8370bc41b15c12fc136c4c5f057045d (diff) | |
| download | box64-77c2683762e3995bf7d598bcfea695a202e5d34f.tar.gz box64-77c2683762e3995bf7d598bcfea695a202e5d34f.zip | |
[RV64_DYNAREC] Removed useless zero-ups in some emit_* functions (#2672)
Diffstat (limited to 'src')
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_emit_logic.c | 43 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_emit_math.c | 18 |
2 files changed, 41 insertions, 20 deletions
diff --git a/src/dynarec/rv64/dynarec_rv64_emit_logic.c b/src/dynarec/rv64/dynarec_rv64_emit_logic.c index ba4e991b..f5c5f72c 100644 --- a/src/dynarec/rv64/dynarec_rv64_emit_logic.c +++ b/src/dynarec/rv64/dynarec_rv64_emit_logic.c @@ -92,7 +92,12 @@ void emit_xor32(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int s2, int s SET_FLAGS_LTZ(s1, F_SF, s3, s4); } - if (!rex.w && s1 != s2) ZEROUP(s1); + if (!rex.w && s1 != s2) { + IFX (X_ZF) + ZEROUP(s1); + else if (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion) + ZEROUP(s1); + } IFX (X_PEND) { SDxw(s1, xEmu, offsetof(x64emu_t, res)); @@ -129,8 +134,12 @@ void emit_xor32c(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int64_t c, i if (!rex.w) SEXT_W(s1, s1); SET_FLAGS_LTZ(s1, F_SF, s3, s4); } - if (!rex.w) ZEROUP(s1); - + if (!rex.w) { + IFX (X_ZF) + ZEROUP(s1); + else if (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion) + ZEROUP(s1); + } IFX (X_PEND) { SDxw(s1, xEmu, offsetof(x64emu_t, res)); } @@ -222,9 +231,11 @@ void emit_or32(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int s2, int s3 SET_FLAGS_LTZ(s1, F_SF, s3, s4); } if (!rex.w) { - ZEROUP(s1); + IFX (X_ZF) + ZEROUP(s1); + else if (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion) + ZEROUP(s1); } - IFX (X_PEND) { SDxw(s1, xEmu, offsetof(x64emu_t, res)); } @@ -260,9 +271,11 @@ void emit_or32c(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int64_t c, in SET_FLAGS_LTZ(s1, F_SF, s3, s4); } if (!rex.w) { - ZEROUP(s1); + IFX (X_ZF) + ZEROUP(s1); + else if (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion) + ZEROUP(s1); } - IFX (X_PEND) { SDxw(s1, xEmu, offsetof(x64emu_t, res)); } @@ -372,8 +385,12 @@ void emit_and32(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int s2, int s } AND(s1, s1, s2); // res = s1 & s2 - if (!rex.w) ZEROUP(s1); - + if (!rex.w) { + IFX (X_ZF | X_SF) + ZEROUP(s1); + else if (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion) + ZEROUP(s1); + } IFX (X_PEND) { SDxw(s1, xEmu, offsetof(x64emu_t, res)); } @@ -406,8 +423,12 @@ void emit_and32c(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int64_t c, i MOV64xw(s3, c); AND(s1, s1, s3); // res = s1 & s2 } - if (!rex.w && c < 0) ZEROUP(s1); - + if (!rex.w) { + IFX (X_ZF | X_SF) + ZEROUP(s1); + else if (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion) + ZEROUP(s1); + } IFX (X_PEND) { SDxw(s1, xEmu, offsetof(x64emu_t, res)); } diff --git a/src/dynarec/rv64/dynarec_rv64_emit_math.c b/src/dynarec/rv64/dynarec_rv64_emit_math.c index 9c2291a9..df5c921d 100644 --- a/src/dynarec/rv64/dynarec_rv64_emit_math.c +++ b/src/dynarec/rv64/dynarec_rv64_emit_math.c @@ -86,7 +86,7 @@ void emit_add32(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int s2, int s IFX (X_SF) { SET_FLAGS_LTZ(s1, F_SF, s3, s5); } - if (!rex.w) { + if (!rex.w && (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion)) { ZEROUP(s1); } IFX (X_PF) { @@ -189,7 +189,7 @@ void emit_add32c(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int64_t c, i IFX (X_SF) { SET_FLAGS_LTZ(s1, F_SF, s3, s5); } - if (!rex.w) { + if (!rex.w && (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion)) { ZEROUP(s1); } IFX (X_PF) { @@ -491,7 +491,7 @@ void emit_sub32(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int s2, int s IFX (X_SF) { SET_FLAGS_LTZ(s1, F_SF, s3, s4); } - if (!rex.w) { + if (!rex.w && (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion)) { ZEROUP(s1); } CALC_SUB_FLAGS(s5, s2, s1, s3, s4, rex.w ? 64 : 32); @@ -558,7 +558,7 @@ void emit_sub32c(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int64_t c, i IFX (X_SF) { SET_FLAGS_LTZ(s1, F_SF, s3, s4); } - if (!rex.w) { + if (!rex.w && (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion)) { ZEROUP(s1); } CALC_SUB_FLAGS(s5, s2, s1, s3, s4, rex.w ? 64 : 32); @@ -725,7 +725,7 @@ void emit_inc32(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int s2, int s IFX (X_SF) { SET_FLAGS_LTZ(s1, F_SF, s4, s5); } - if (!rex.w) { + if (!rex.w && (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion)) { ZEROUP(s1); } IFX (X_PF) { @@ -778,7 +778,7 @@ void emit_dec32(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int s2, int s IFX (X_SF) { SET_FLAGS_LTZ(s1, F_SF, s4, s5); } - if (!rex.w) { + if (!rex.w && (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion)) { ZEROUP(s1); } IFX (X_PF) { @@ -1082,7 +1082,7 @@ void emit_sbb32(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int s2, int s IFX (X_SF) { SET_FLAGS_LTZ(s1, F_SF, s4, s5); } - if (!rex.w) { + if (!rex.w && (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion)) { ZEROUP(s1); } @@ -1143,7 +1143,7 @@ void emit_neg32(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int s2, int s IFX (X_SF) { SET_FLAGS_LTZ(s1, F_SF, s4, s5); } - if (!rex.w) { + if (!rex.w && (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion)) { ZEROUP(s1); } IFX (X_PF) { @@ -1402,7 +1402,7 @@ void emit_adc32(dynarec_rv64_t* dyn, int ninst, rex_t rex, int s1, int s2, int s IFX (X_SF) { SET_FLAGS_LTZ(s1, F_SF, s5, s6); } - if (!rex.w) { + if (!rex.w && (IS_GPR(s1) || dyn->insts[ninst].nat_flags_fusion)) { ZEROUP(s1); } IFX (X_PF) { |