From: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
To: qemu-devel@nongnu.org
Subject: [PULL 04/18] target/mips: Use gen_mxu_logic for gen_mxu_S32MAX_S32MIN
Date: Thu, 24 Sep 2026 17:23:39 +0200 [thread overview]
Message-ID: <20260924152353.36209-5-philmd@oss.qualcomm.com> (raw)
In-Reply-To: <20260924152353.36209-1-philmd@oss.qualcomm.com>
From: Richard Henderson <richard.henderson@linaro.org>
Split S32MAX, S32MIN to separate functions.
Fixes a bug in that "0" was passed in one of the zero reg cases,
aka NULL, instead of a proper zero constant.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260914230901.1781309-5-richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
target/mips/tcg/mxu_translate.c | 47 +++++++--------------------------
1 file changed, 9 insertions(+), 38 deletions(-)
diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c
index 3f8acfcdb8f..4b2c264f031 100644
--- a/target/mips/tcg/mxu_translate.c
+++ b/target/mips/tcg/mxu_translate.c
@@ -2045,45 +2045,14 @@ static void gen_mxu_q16sxxv(DisasContext *ctx, bool right, bool arithmetic)
* Update XRa with the minimum of signed 32-bit integers contained
* in XRb and XRc.
*/
-static void gen_mxu_S32MAX_S32MIN(DisasContext *ctx)
+static void gen_mxu_S32MAX(DisasContext *ctx)
{
- uint32_t pad, opc, XRc, XRb, XRa;
+ gen_mxu_logic(ctx, tcg_gen_smax_i32);
+}
- pad = extract32(ctx->opcode, 21, 5);
- opc = extract32(ctx->opcode, 18, 3);
- XRc = extract32(ctx->opcode, 14, 4);
- XRb = extract32(ctx->opcode, 10, 4);
- XRa = extract32(ctx->opcode, 6, 4);
-
- 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 == 0))) {
- /* both operands zero registers -> just set destination to zero */
- tcg_gen_movi_i32(mxu_gpr[XRa - 1], 0);
- } else if (unlikely((XRb == 0) || (XRc == 0))) {
- /* exactly one operand is zero register - find which one is not...*/
- uint32_t XRx = XRb ? XRb : XRc;
- /* ...and do max/min operation with one operand 0 */
- if (opc == OPC_MXU_S32MAX) {
- tcg_gen_smax_i32(mxu_gpr[XRa - 1], mxu_gpr[XRx - 1], 0);
- } else {
- tcg_gen_smin_i32(mxu_gpr[XRa - 1], mxu_gpr[XRx - 1], 0);
- }
- } else if (unlikely(XRb == XRc)) {
- /* both operands same -> just set destination to one of them */
- tcg_gen_mov_i32(mxu_gpr[XRa - 1], mxu_gpr[XRb - 1]);
- } else {
- /* the most general case */
- if (opc == OPC_MXU_S32MAX) {
- tcg_gen_smax_i32(mxu_gpr[XRa - 1], mxu_gpr[XRb - 1],
- mxu_gpr[XRc - 1]);
- } else {
- tcg_gen_smin_i32(mxu_gpr[XRa - 1], mxu_gpr[XRb - 1],
- mxu_gpr[XRc - 1]);
- }
- }
+static void gen_mxu_S32MIN(DisasContext *ctx)
+{
+ gen_mxu_logic(ctx, tcg_gen_smin_i32);
}
/*
@@ -4328,8 +4297,10 @@ static void decode_opc_mxu__pool00(DisasContext *ctx)
switch (opcode) {
case OPC_MXU_S32MAX:
+ gen_mxu_S32MAX(ctx);
+ break;
case OPC_MXU_S32MIN:
- gen_mxu_S32MAX_S32MIN(ctx);
+ gen_mxu_S32MIN(ctx);
break;
case OPC_MXU_D16MAX:
case OPC_MXU_D16MIN:
--
2.53.0
next prev parent reply other threads:[~2026-09-24 15:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 15:23 [PULL 00/18] Misc target/ patches for 2026-09-24 Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 01/18] target/mips: Fix zero in gen_mxu_d8sum Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 02/18] target/mips: Drop zero optimization in gen_mxu_s32mul Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 03/18] target/mips: Split out gen_mxu_logic Philippe Mathieu-Daudé
2026-09-24 15:23 ` Philippe Mathieu-Daudé [this message]
2026-09-24 15:23 ` [PULL 05/18] target/mips: Use gen_mxu_logic for gen_mxu_S32SLT Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 06/18] target/mips: Use gen_mxu_logic for gen_mxu_S32CPS Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 07/18] target/riscv: Stub out kvm functions Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 08/18] system: Document has_work() synchronization requirements Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 09/18] target/s390x: Use s390_cpu_get_state() consistently Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 10/18] target/s390x: Extend comment about PV cpu load state Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 11/18] target/s390x: Make s390_cpu_set_state() return void Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 12/18] target/s390x: Use S390CpuState for CPU state APIs Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 13/18] target/s390x: Access S390CpuState atomically Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 14/18] target/arm: Un-inline arm_set_cpu_power_state() Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 15/18] target/arm: Access PSCI state atomically Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 16/18] target/arm: Access halt " Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 17/18] target/i386: Use an acquire load for interrupt_request() Philippe Mathieu-Daudé
2026-09-24 15:23 ` [PULL 18/18] target/ppc: Stop vCPU thread before calling parent_unrealize Philippe Mathieu-Daudé
2026-09-25 2:35 ` [PULL 00/18] Misc target/ patches for 2026-09-24 Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260924152353.36209-5-philmd@oss.qualcomm.com \
--to=philmd@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.