On 12/15/24 03:06, Paolo Bonzini wrote:
> The same "if" is present in all generator functions for string instructions.
> Push it inside gen_repz() and gen_repz_nz() instead.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> target/i386/tcg/translate.c | 12 +++++++++--
> target/i386/tcg/emit.c.inc | 42 +++++++------------------------------
> 2 files changed, 17 insertions(+), 37 deletions(-)
>
> diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
> index 8bf6aa1fcf6..63a39d9f15a 100644
> --- a/target/i386/tcg/translate.c
> +++ b/target/i386/tcg/translate.c
> @@ -1340,13 +1340,21 @@ static void gen_repz(DisasContext *s, MemOp ot,
> void (*fn)(DisasContext *s, MemOp ot))
>
> {
> - do_gen_rep(s, ot, fn, false);
> + if (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) {
> + do_gen_rep(s, ot, fn, false);
> + } else {
> + fn(s, ot);
> + }
> }
>
> static void gen_repz_nz(DisasContext *s, MemOp ot,
> void (*fn)(DisasContext *s, MemOp ot))
> {
> - do_gen_rep(s, ot, fn, true);
> + if (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) {
> + do_gen_rep(s, ot, fn, true);
> + } else {
> + fn(s, ot);
> + }
> }
Why not push it into do_gen_rep?
Just because do_gen_rep is already complicated enough by the end of the series.
Paolo