From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2pmW-000171-1p for qemu-devel@nongnu.org; Thu, 03 Jul 2014 18:47:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2pmV-0005HE-60 for qemu-devel@nongnu.org; Thu, 03 Jul 2014 18:47:07 -0400 Received: from zeniv.linux.org.uk ([2002:c35c:fd02::1]:53022) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2pmU-0005Fn-VI for qemu-devel@nongnu.org; Thu, 03 Jul 2014 18:47:07 -0400 Date: Thu, 3 Jul 2014 23:47:04 +0100 From: Al Viro Message-ID: <20140703224704.GR18016@ZenIV.linux.org.uk> References: <53B2E9CA.4040802@twiddle.net> <20140701175036.GJ18016@ZenIV.linux.org.uk> <53B2FE3B.6050306@twiddle.net> <20140702040508.GK18016@ZenIV.linux.org.uk> <53B41E36.30906@twiddle.net> <20140702152027.GN18016@ZenIV.linux.org.uk> <20140703065104.GP18016@ZenIV.linux.org.uk> <20140703182501.GQ18016@ZenIV.linux.org.uk> <53B5BAC7.1010603@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <53B5BAC7.1010603@twiddle.net> Sender: Al Viro Subject: Re: [Qemu-devel] [RFC] alpha qemu arithmetic exceptions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: Peter Maydell , QEMU Developers On Thu, Jul 03, 2014 at 01:19:19PM -0700, Richard Henderson wrote: > > Grr... Wrong check, obviously - we want to check that tmp + MSB(tmp2) is 0. > > Something like > > setcond_32 tmp2, tmp2, zero, TCG_COND_LT > > add_i32 tmp, tmp2, tmp > > call helper_IOV_if_not_zero tmp > > for 32bit ones and > > setcond_64 tmp2, vc, zero, TCG_COND_LT > > add_i64 tmp, tmp2, tmp > > call helper_IOV_if_not_zero tmp > > for 64bit ones, or would it be better just to pass both arguments to helper > > and let it deal with the check? I'm not familiar enough with TCG, sorry... > > > > I believe I have a tidy solution to these /v insns. New patch set shortly. Hmm... + tcg_gen_eqv_i64(tmp, va, vb); + tcg_gen_mov_i64(tmp2, va); + tcg_gen_add_i64(vc, va, vb); + tcg_gen_xor_i64(tmp2, tmp2, vc); + tcg_gen_and_i64(tmp, tmp, tmp2); + tcg_gen_shri_i64(tmp, tmp, 63); + tcg_gen_movi_i64(tmp2, 0); + gen_helper_check_overflow(cpu_env, tmp, tmp2); How can that be correct? Suppose a = b = 0. We get tcg_gen_eqv_i64(tmp, va, vb); -> tmp = -1 tcg_gen_mov_i64(tmp2, va); -> tmp2 = 0 tcg_gen_add_i64(vc, va, vb); -> c = 0 tcg_gen_xor_i64(tmp2, tmp2, vc);-> tmp2 = 0 tcg_gen_and_i64(tmp, tmp, tmp2);-> tmp = -1 tcg_gen_shri_i64(tmp, tmp, 63); -> tmp = 1 tcg_gen_movi_i64(tmp2, 0); -> tmp2 = 0 gen_helper_check_overflow(cpu_env, tmp, tmp2); -> not equal, overflow. What am I missing here?