Received: from eggs.gnu.org ([2001:4830:134:3::10]:32776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBsHV-0000D1-P9 for qemu-devel@nongnu.org; Tue, 29 Nov 2016 18:57:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBsHS-0008DW-NT for qemu-devel@nongnu.org; Tue, 29 Nov 2016 18:57:49 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:57644) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cBsHS-0008DJ-EV for qemu-devel@nongnu.org; Tue, 29 Nov 2016 18:57:46 -0500 References: <1478699171-10637-1-git-send-email-rth@twiddle.net> <1478699171-10637-4-git-send-email-rth@twiddle.net> <2848eb04-1484-9947-9bf4-2917727b091c@twiddle.net> From: Laurent Vivier Message-ID: <21e07a80-6239-e449-b94a-488ca59fb9bf@vivier.eu> Date: Wed, 30 Nov 2016 00:52:33 +0100 MIME-Version: 1.0 In-Reply-To: <2848eb04-1484-9947-9bf4-2917727b091c@twiddle.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v2 3/5] target-m68k: Inline shifts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: qemu-devel@nongnu.org Le 28/11/2016 à 15:54, Richard Henderson a écrit : > On 11/27/2016 11:35 AM, Laurent Vivier wrote: >>>> + tcg_gen_extr_i64_i32(QREG_CC_N, QREG_CC_C, t64); >> This does not extract correctly the C flag when the opsize is word or byte. >> I think we should use a shift instead: >> >> - tcg_gen_extr_i64_i32(QREG_CC_N, QREG_CC_C, t64); >> - >> - /* Note that C=0 if shift count is 0, and we get that for free. */ >> + if (opsize == OS_LONG) { >> + tcg_gen_extr_i64_i32(QREG_CC_N, QREG_CC_C, t64); >> + /* Note that C=0 if shift count is 0, and we get that for >> free. */ >> + } else { >> + TCGv zero = tcg_const_i32(0); >> + tcg_gen_extrl_i64_i32(QREG_CC_N, t64); >> + tcg_gen_shri_i64(t64, t64, bits); >> + tcg_gen_extrl_i64_i32(QREG_CC_C, t64); >> + tcg_gen_movcond_i32(TCG_COND_EQ, QREG_CC_C, >> + s32, zero, zero, QREG_CC_C); >> + tcg_temp_free(zero); >> + } >> >> Do you have a better idea? > > if (opsize == OS_LONG) { > tcg_gen_extr_i64_i32(QREG_CC_N, QREG_CC_C, t64); > } else { > tcg_gen_extrl_i64_i32(QREG_CC_N, t64); > tcg_gen_shri_i32(QREG_CC_C, QREG_CC_N, bits); > } > > Since we zero-extend the input from bits, it's still true that a zero shift > gets C=0 for free. > It doesn't work because we work with word/byte where the bit sign has been extended to the long word. So in the case of 0 shift, with retrieve C= and not 0. Laurent