Commit aebd6eb16b for qemu.org
commit aebd6eb16b369657edb4d0e7f554815f4684fb84
Author: Richard Henderson <richard.henderson@linaro.org>
Date: Mon Sep 14 13:01:55 2026 -1000
target/mips/tcg: Use gen_mxu_logic for gen_mxu_S32CPS
Use movcond instead of a pair of branches to perform
the computation, packed in a new gen_cps_i32.
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c
index 293eeb46c2..a38f4da12b 100644
--- a/target/mips/tcg/mxu_translate.c
+++ b/target/mips/tcg/mxu_translate.c
@@ -2640,39 +2640,19 @@ static void gen_mxu_s32movzn(DisasContext *ctx, TCGCond cond)
* Update XRa if XRc < 0 by value of 0 - XRb
* else XRa = XRb
*/
-static void gen_mxu_S32CPS(DisasContext *ctx)
-{
- uint32_t pad, XRc, XRb, XRa;
- pad = extract32(ctx->opcode, 21, 5);
- XRc = extract32(ctx->opcode, 14, 4);
- XRb = extract32(ctx->opcode, 10, 4);
- XRa = extract32(ctx->opcode, 6, 4);
+static void gen_cps_i32(TCGv_i32 a, TCGv_i32 b, TCGv_i32 c)
+{
+ TCGv_i32 n = tcg_temp_new_i32();
+ TCGv_i32 z = tcg_constant_i32(0);
- if (unlikely(pad != 0)) {
- /* opcode padding incorrect -> do nothing */
- } else if (unlikely(XRa == 0)) {
- /* destination is zero register -> do nothing */
- } else if (unlikely(XRb == 0)) {
- /* XRc make no sense 0 - 0 = 0 -> just set destination to zero */
- tcg_gen_movi_i32(mxu_gpr[XRa - 1], 0);
- } else if (unlikely(XRc == 0)) {
- /* condition always false -> just move XRb to XRa */
- tcg_gen_mov_i32(mxu_gpr[XRa - 1], mxu_gpr[XRb - 1]);
- } else {
- /* the most general case */
- TCGv_i32 t0 = tcg_temp_new_i32();
- TCGLabel *l_not_less = gen_new_label();
- TCGLabel *l_done = gen_new_label();
+ tcg_gen_neg_i32(n, b);
+ tcg_gen_movcond_i32(TCG_COND_LT, a, c, z, n, b);
+}
- tcg_gen_brcondi_i32(TCG_COND_GE, mxu_gpr[XRc - 1], 0, l_not_less);
- tcg_gen_neg_i32(t0, mxu_gpr[XRb - 1]);
- tcg_gen_br(l_done);
- gen_set_label(l_not_less);
- gen_load_mxu_gpr(t0, XRb);
- gen_set_label(l_done);
- gen_store_mxu_gpr(t0, XRa);
- }
+static void gen_mxu_S32CPS(DisasContext *ctx)
+{
+ gen_mxu_logic(ctx, gen_cps_i32);
}
/*