On 17/11/26 20:18, Richard Henderson wrote:
On 11/13/26 08:11, Philippe Mathieu-Daudé wrote:
BNEC[16] with identical registers is never taken, so it is a NOP.
gen_compute_branch_nm() instead wrote $ra and skipped the next
4 bytes as if it were a MIPS branch-and-link-likely.
Also raise Reserved Instruction on NMS cores, where the 16-bit
forms are not available.
Fixes: 764371d24c51 ("target/mips: Add emulation of nanoMIPS 16-bit
branch")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
target/mips/tcg/nanomips_translate.c.inc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/target/mips/tcg/nanomips_translate.c.inc b/target/mips/
tcg/nanomips_translate.c.inc
index f9dc573dbb01..25d57e75a0b0 100644
--- a/target/mips/tcg/nanomips_translate.c.inc
+++ b/target/mips/tcg/nanomips_translate.c.inc
@@ -4756,6 +4756,10 @@ static int decode_isa_nanomips(CPUMIPSState
*env, DisasContext *ctx)
/* P16.BRI */
uint32_t opc = extract32(ctx->opcode, 4, 3) <
extract32(ctx->opcode, 7, 3) ?
OPC_BEQ : OPC_BNE;
+ check_nms(ctx);
+ if (rs == rt) {
+ break;
+ }
gen_compute_branch_nm(ctx, opc, 2, rs, rt,
extract32(ctx->opcode, 0, 4)
<< 1);
}
Surely not. BNE x,x is never taken, but BEQ x,x is.
Right... Updated as:
- if (rs == rt) {
+ if (opc == OPC_BNE && rs == rt) {