From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=45444 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfadF-0005rN-BM for qemu-devel@nongnu.org; Wed, 19 Jan 2011 11:11:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PfadC-0003GT-CO for qemu-devel@nongnu.org; Wed, 19 Jan 2011 11:11:37 -0500 Received: from eu1sys200aog103.obsmtp.com ([207.126.144.115]:37589) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PfadC-0003Fp-4X for qemu-devel@nongnu.org; Wed, 19 Jan 2011 11:11:34 -0500 Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 747E691 for ; Wed, 19 Jan 2011 16:11:15 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas5.st.com [10.75.90.71]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id C211421F for ; Wed, 19 Jan 2011 16:11:14 +0000 (GMT) Message-ID: <4D370D0C.5040706@st.com> Date: Wed, 19 Jan 2011 17:10:52 +0100 From: Christophe Lyon MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] Support saturation with shift=0. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "qemu-devel@nongnu.org" This patch fixes corner-case saturations, when the target range is zero. It merely removes the guard against (sh == 0), and makes: __ssat(0x87654321, 1) return 0xffffffff and set the saturation flag __usat(0x87654321, 0) return 0 and set the saturation flag Signed-off-by: Christophe Lyon --- target-arm/translate.c | 28 ++++++++++++---------------- 1 files changed, 12 insertions(+), 16 deletions(-) diff --git a/target-arm/translate.c b/target-arm/translate.c index 721bada..41cbb96 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -6896,27 +6896,23 @@ static void disas_arm_insn(CPUState * env, DisasContext *s) tcg_gen_shli_i32(tmp, tmp, shift); } sh = (insn >> 16) & 0x1f; - if (sh != 0) { - tmp2 = tcg_const_i32(sh); - if (insn & (1 << 22)) - gen_helper_usat(tmp, tmp, tmp2); - else - gen_helper_ssat(tmp, tmp, tmp2); - tcg_temp_free_i32(tmp2); - } + tmp2 = tcg_const_i32(sh); + if (insn & (1 << 22)) + gen_helper_usat(tmp, tmp, tmp2); + else + gen_helper_ssat(tmp, tmp, tmp2); + tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((insn & 0x00300fe0) == 0x00200f20) { /* [us]sat16 */ tmp = load_reg(s, rm); sh = (insn >> 16) & 0x1f; - if (sh != 0) { - tmp2 = tcg_const_i32(sh); - if (insn & (1 << 22)) - gen_helper_usat16(tmp, tmp, tmp2); - else - gen_helper_ssat16(tmp, tmp, tmp2); - tcg_temp_free_i32(tmp2); - } + tmp2 = tcg_const_i32(sh); + if (insn & (1 << 22)) + gen_helper_usat16(tmp, tmp, tmp2); + else + gen_helper_ssat16(tmp, tmp, tmp2); + tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((insn & 0x00700fe0) == 0x00000fa0) { /* Select bytes. */ -- 1.7.2.3