From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:32980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbsTo-0005tB-He for qemu-devel@nongnu.org; Tue, 25 Dec 2018 14:35:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gbsTk-0000F2-Jc for qemu-devel@nongnu.org; Tue, 25 Dec 2018 14:35:04 -0500 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:33610) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gbsTk-0000Ec-5g for qemu-devel@nongnu.org; Tue, 25 Dec 2018 14:35:00 -0500 Received: by mail-pf1-x443.google.com with SMTP id c123so7045394pfb.0 for ; Tue, 25 Dec 2018 11:34:59 -0800 (PST) References: <20181217200444.14812-1-aleksandar.markovic@rt-rk.com> <20181217200444.14812-6-aleksandar.markovic@rt-rk.com> From: Richard Henderson Message-ID: Date: Wed, 26 Dec 2018 06:34:48 +1100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 5/6] target/mips: MXU: Add handlers for max/min instructions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aleksandar Markovic , Aleksandar Markovic Cc: Stefan Markovic , qemu-devel@nongnu.org, Aleksandar Markovic , "Janeczek, Craig" Sorry I missed the original post, but: > + } 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]); You should not special case unlikely events, especially when ... > + } 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]); > + } ... the normal case will handle those special cases just fine.