target/openrisc: Optimize l.jal to next
authorRichard Henderson <rth@twiddle.net>
Tue, 5 Apr 2016 18:50:16 +0000 (11:50 -0700)
committerRichard Henderson <rth@twiddle.net>
Mon, 13 Feb 2017 21:15:00 +0000 (08:15 +1100)
This allows the tcg optimizer to see, and fold, all of the
constants involved in a GOT base register load sequence.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
target/openrisc/translate.c

index 66064e182949a32f54eb70950930b172d99807da..cda84b61cb0c89a36aae7dc9892c0cb88d1ab802 100644 (file)
@@ -198,7 +198,11 @@ static void gen_jump(DisasContext *dc, int32_t n26, uint32_t reg, uint32_t op0)
         tcg_gen_movi_tl(jmp_pc, tmp_pc);
         break;
     case 0x01:     /* l.jal */
-        tcg_gen_movi_tl(cpu_R[9], (dc->pc + 8));
+        tcg_gen_movi_tl(cpu_R[9], dc->pc + 8);
+        /* Optimize jal being used to load the PC for PIC.  */
+        if (tmp_pc == dc->pc + 8) {
+            return;
+        }
         tcg_gen_movi_tl(jmp_pc, tmp_pc);
         break;
     case 0x03:     /* l.bnf */