[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PULL 21/26] target-hppa: Implement branches
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PULL 21/26] target-hppa: Implement branches |
Date: |
Thu, 26 Jan 2017 13:14:04 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 |
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;
> + }
> +}
- [Qemu-devel] [PULL 14/26] linux-user: Add HPPA target_signal.h and target_cpu.h, (continued)
- [Qemu-devel] [PULL 14/26] linux-user: Add HPPA target_signal.h and target_cpu.h, Richard Henderson, 2017/01/22
- [Qemu-devel] [PULL 15/26] linux-user: Add HPPA signal handling, Richard Henderson, 2017/01/22
- [Qemu-devel] [PULL 17/26] target-hppa: Add softfloat specializations, Richard Henderson, 2017/01/22
- [Qemu-devel] [PULL 01/26] Revert "Remove remainders of HPPA backend", Richard Henderson, 2017/01/22
- [Qemu-devel] [PULL 16/26] linux-user: Add HPPA startup and main loop, Richard Henderson, 2017/01/22
- [Qemu-devel] [PULL 22/26] target-hppa: Implement linux-user gateway page, Richard Henderson, 2017/01/22
- [Qemu-devel] [PULL 20/26] target-hppa: Implement basic arithmetic, Richard Henderson, 2017/01/22
- [Qemu-devel] [PULL 19/26] target-hppa: Add nullification framework, Richard Henderson, 2017/01/22
- [Qemu-devel] [PULL 18/26] target-hppa: Add framework and enable compilation, Richard Henderson, 2017/01/22
- [Qemu-devel] [PULL 21/26] target-hppa: Implement branches, Richard Henderson, 2017/01/22
- Re: [Qemu-devel] [PULL 21/26] target-hppa: Implement branches,
Paolo Bonzini <=
- [Qemu-devel] [PULL 23/26] target-hppa: Implement shifts and deposits, Richard Henderson, 2017/01/22
- [Qemu-devel] [PULL 25/26] target-hppa: Implement system and memory-management insns, Richard Henderson, 2017/01/22
- [Qemu-devel] [PULL 24/26] target-hppa: Implement loads and stores, Richard Henderson, 2017/01/22
- [Qemu-devel] [PULL 26/26] target-hppa: Implement floating-point insns, Richard Henderson, 2017/01/22
- Re: [Qemu-devel] [PULL 00/26] New hppa-linux target support, Peter Maydell, 2017/01/23