Skip to contentSkip to conversation

target/mips: Simplify Loongson MULTU.G opcode

PATCH Superseded Philippe Mathieu-Daudé 2 participants 2 messages Aug 31, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/mips: Simplify Loongson MULTU.G opcode

Since MULTU opcodes don't record the most significant bits of the infinite result, sign-extending the sources make no difference in the result.

Once we remove the sign extension of source registers, MULT and MULTU are identical (as are DMULT and DMULTU).

---
 target/mips/tcg/translate.c | 2 --
 1 file changed, 2 deletions(-)
target/mips/tcg/translate.c +0 -2
index 9bb40f1849..e0a76b9432 100644
@@ -3625,8 +3625,6 @@ static void gen_loongson_integer(DisasContext *ctx, uint32_t opc,
         break;
     case OPC_MULTU_G_2E:
     case OPC_MULTU_G_2F:
-        tcg_gen_ext32u_tl(t0, t0);
-        tcg_gen_ext32u_tl(t1, t1);
         tcg_gen_mul_tl(cpu_gpr[rd], t0, t1);
         tcg_gen_ext32s_tl(cpu_gpr[rd], cpu_gpr[rd]);
         break;
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Philippe Mathieu-Daudé

Since MULTU opcodes don't record the most significant bits of the infinite result, sign-extending the sources make no difference in the result.

Quoted 8 lines

Once we remove the sign extension of source registers, MULT and MULTU are identical (as are DMULT and DMULTU).

---
  target/mips/tcg/translate.c | 2 --
  1 file changed, 2 deletions(-)

r~