From 074aaf5bd7505c84f0470d45b4275bc10975faa7 Mon Sep 17 00:00:00 2001 From: Vacantron Chen Date: Sun, 17 Dec 2023 01:08:00 +0800 Subject: [PATCH] Fix branch-misses on Raspberry Pi 3B According to "Arm Cortex-A53 MPCore Processor Technical Reference Manual", the data-processing instructions using the PC as a destination register is not predicted. Replace the `MOV pc, ...` with `BLX` or `POP` instruction. Ref: #93 --- src/arm-codegen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arm-codegen.c b/src/arm-codegen.c index 731f7e56..77bc6769 100644 --- a/src/arm-codegen.c +++ b/src/arm-codegen.c @@ -315,7 +315,7 @@ void emit_ph2_ir(ph2_ir_t *ph2_ir) emit(__movt(__AL, __r8, ph2_ir->src1 + 4)); emit(__add_r(__AL, __sp, __sp, __r8)); emit(__lw(__AL, __lr, __sp, -4)); - emit(__mov_r(__AL, __pc, __lr)); + emit(__blx(__AL, __lr)); return; case OP_add: emit(__add_r(__AL, rd, rn, rm));