summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2016-07-31 15:13:09 +1000
committerDavid Gibson <david@gibson.dropbear.id.au>2016-09-07 12:40:12 +1000
commitaccc60c47c9b57f49865d1bed6df3d3085fec81d (patch)
treec9a050d055bdec065e94817c72916506bf7c5198
parent4f5d326046fa522010c0a66f1bcaac9068253085 (diff)
downloadfocaccia-qemu-accc60c47c9b57f49865d1bed6df3d3085fec81d.tar.gz
focaccia-qemu-accc60c47c9b57f49865d1bed6df3d3085fec81d.zip
ppc: Don't generate dead code on unconditional branches
We are always generating the "else" case of the condition even when
generating an unconditional branch that will never hit it.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--target-ppc/translate.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index 0a5a3e21f0..618334ae51 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -3480,8 +3480,10 @@ static inline void gen_bcond(DisasContext *ctx, int type)
         } else {
             gen_goto_tb(ctx, 0, li);
         }
-        gen_set_label(l1);
-        gen_goto_tb(ctx, 1, ctx->nip);
+        if ((bo & 0x14) != 0x14) {
+            gen_set_label(l1);
+            gen_goto_tb(ctx, 1, ctx->nip);
+        }
     } else {
         if (NARROW_MODE(ctx)) {
             tcg_gen_andi_tl(cpu_nip, target, (uint32_t)~3);
@@ -3489,9 +3491,11 @@ static inline void gen_bcond(DisasContext *ctx, int type)
             tcg_gen_andi_tl(cpu_nip, target, ~3);
         }
         tcg_gen_exit_tb(0);
-        gen_set_label(l1);
-        gen_update_nip(ctx, ctx->nip);
-        tcg_gen_exit_tb(0);
+        if ((bo & 0x14) != 0x14) {
+            gen_set_label(l1);
+            gen_update_nip(ctx, ctx->nip);
+            tcg_gen_exit_tb(0);
+        }
     }
     if (type == BCOND_LR || type == BCOND_CTR || type == BCOND_TAR) {
         tcg_temp_free(target);