From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQfdJ-0002WE-9f for qemu-devel@nongnu.org; Thu, 20 Mar 2014 12:16:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQfdA-0003Ck-Qp for qemu-devel@nongnu.org; Thu, 20 Mar 2014 12:15:53 -0400 Received: from mail-qg0-x22e.google.com ([2607:f8b0:400d:c04::22e]:60387) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQfdA-0003Ca-Cm for qemu-devel@nongnu.org; Thu, 20 Mar 2014 12:15:44 -0400 Received: by mail-qg0-f46.google.com with SMTP id e89so3249444qgf.5 for ; Thu, 20 Mar 2014 09:15:44 -0700 (PDT) Sender: Richard Henderson Message-ID: <532B142C.9060800@twiddle.net> Date: Thu, 20 Mar 2014 09:15:40 -0700 From: Richard Henderson MIME-Version: 1.0 References: <532A1A30.3040306@caramail.com> In-Reply-To: <532A1A30.3040306@caramail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] sparc32 : Signed integer division overflow List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Olivier Danet , qemu-devel , Blue Swirl , Mark Cave-Ayland On 03/19/2014 03:29 PM, Olivier Danet wrote: > + if ((int32_t) x0 != x0) { > + x0 = x0 < 0 ? 0x80000000 : 0x7fffffff; > + overflow = 1; > + } Actually, there's an existing bug here that we might as well fix. ## ... the 32-bit result is sign-extended to 64 bits and ## written into register R[rd]. That 0x80000000 is not going to promote properly to 64-bits. We might as well go ahead and use INT32_MIN and INT32_MAX here at the same time. r~