qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Richard Henderson <rth@twiddle.net>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PULL 21/26] target-hppa: Implement branches
Date: Thu, 26 Jan 2017 13:14:04 +0100	[thread overview]
Message-ID: <d010ae34-9ddd-d5fc-1fa0-82d3d2341c95@redhat.com> (raw)
In-Reply-To: <20170123021748.13170-22-rth@twiddle.net>

I haven't studied the code much, so I'm just reporting what Coverity
says.  Not sure if the code has a bug or can just be simplified.

On 23/01/2017 03:17, Richard Henderson wrote:
> +/* Emit a conditional branch to a direct target.  If the branch itself
> +   is nullified, we should have already used nullify_over.  */
> +static ExitStatus do_cbranch(DisasContext *ctx, target_long disp, bool is_n,
> +                             DisasCond *cond)
> +{
> +    target_ulong dest = iaoq_dest(ctx, disp);
> +    TCGLabel *taken = NULL;
> +    TCGCond c = cond->c;
> +    int which = 0;
> +    bool n;
> +
> +    assert(ctx->null_cond.c == TCG_COND_NEVER);
> +
> +    /* Handle TRUE and NEVER as direct branches.  */
> +    if (c == TCG_COND_ALWAYS) {
> +        return do_dbranch(ctx, dest, 0, is_n && disp >= 0);
> +    }
> +    if (c == TCG_COND_NEVER) {
> +        return do_dbranch(ctx, ctx->iaoq_n, 0, is_n && disp < 0);
> +    }
> +
> +    taken = gen_new_label();
> +    cond_prep(cond);
> +    tcg_gen_brcond_tl(c, cond->a0, cond->a1, taken);
> +    cond_free(cond);
> +
> +    /* Not taken: Condition not satisfied; nullify on backward branches. */
> +    n = is_n && disp < 0;
> +    if (n && use_nullify_skip(ctx)) {
> +        nullify_set(ctx, 0);
> +        gen_goto_tb(ctx, which++, ctx->iaoq_n, ctx->iaoq_n + 4);
> +    } else {
> +        if (!n && ctx->null_lab) {
> +            gen_set_label(ctx->null_lab);
> +            ctx->null_lab = NULL;
> +        }
> +        nullify_set(ctx, n);
> +        gen_goto_tb(ctx, which++, ctx->iaoq_b, ctx->iaoq_n);
> +    }

Both branches increment "which", so you can replace it with 0 and which
is always 1 now.

> +    gen_set_label(taken);
> +
> +    /* Taken: Condition satisfied; nullify on forward branches.  */
> +    n = is_n && disp >= 0;
> +    if (n && use_nullify_skip(ctx)) {
> +        nullify_set(ctx, 0);
> +        gen_goto_tb(ctx, which++, dest, dest + 4);
> +    } else {
> +        nullify_set(ctx, n);
> +        gen_goto_tb(ctx, which++, ctx->iaoq_b, dest);
> +    }

Both branches increment "which", so you can replace it with 1 and which
is always 2.

> +    /* Not taken: the branch itself was nullified.  */
> +    if (ctx->null_lab) {
> +        gen_set_label(ctx->null_lab);
> +        ctx->null_lab = NULL;
> +        if (which < 2) {
> +            nullify_set(ctx, 0);
> +            gen_goto_tb(ctx, which, ctx->iaoq_b, ctx->iaoq_n);
> +            return EXIT_GOTO_TB;

So this branch of the "if" is dead.

> +        } else {
> +            return EXIT_IAQ_N_STALE;
> +        }
> +    } else {
> +        return EXIT_GOTO_TB;
> +    }
> +}

  reply	other threads:[~2017-01-26 12:14 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-23  2:17 [Qemu-devel] [PULL 00/26] New hppa-linux target support Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 01/26] Revert "Remove remainders of HPPA backend" Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 02/26] linux-user: Support stack-grows-up in elfload.c Richard Henderson
2017-06-27 16:32   ` Peter Maydell
2017-01-23  2:17 ` [Qemu-devel] [PULL 03/26] linux-user: Handle TIOCSTART and TIOCSTOP Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 04/26] linux-user: Add SIOCGPGRP, SIOCGSTAMP, SIOCGSTAMPNS Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 05/26] linux-user: Handle ERFKILL and EHWPOISON Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 06/26] linux-user: Handle more IPV6 sockopts Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 08/26] linux-user: Add HPPA socket.h definitions Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 09/26] linux-user: Add HPPA syscall numbers Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 10/26] linux-user: Add HPPA termbits.h Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 11/26] linux-user: Add HPPA target_syscall.h Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 12/26] linux-user: Add HPPA definitions to syscall_defs.h Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 13/26] linux-user: Add HPPA target_structs.h Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 14/26] linux-user: Add HPPA target_signal.h and target_cpu.h Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 15/26] linux-user: Add HPPA signal handling Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 16/26] linux-user: Add HPPA startup and main loop Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 17/26] target-hppa: Add softfloat specializations Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 18/26] target-hppa: Add framework and enable compilation Richard Henderson
2017-01-30 13:49   ` Peter Maydell
2017-02-07  2:27     ` Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 19/26] target-hppa: Add nullification framework Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 20/26] target-hppa: Implement basic arithmetic Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 21/26] target-hppa: Implement branches Richard Henderson
2017-01-26 12:14   ` Paolo Bonzini [this message]
2017-01-26 17:18     ` Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 22/26] target-hppa: Implement linux-user gateway page Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 23/26] target-hppa: Implement shifts and deposits Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 24/26] target-hppa: Implement loads and stores Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 25/26] target-hppa: Implement system and memory-management insns Richard Henderson
2017-01-23  2:17 ` [Qemu-devel] [PULL 26/26] target-hppa: Implement floating-point insns Richard Henderson
2017-01-23 10:31 ` [Qemu-devel] [PULL 00/26] New hppa-linux target support Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d010ae34-9ddd-d5fc-1fa0-82d3d2341c95@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).