Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KaIYh-0007F2-SF for qemu-devel@nongnu.org; Mon, 01 Sep 2008 19:11:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KaIYh-0007Eg-E3 for qemu-devel@nongnu.org; Mon, 01 Sep 2008 19:11:43 -0400 Received: from [199.232.76.173] (port=48200 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KaIYh-0007Ed-8R for qemu-devel@nongnu.org; Mon, 01 Sep 2008 19:11:43 -0400 Received: from hall.aurel32.net ([91.121.138.14]:59030) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KaIYg-0004A7-SD for qemu-devel@nongnu.org; Mon, 01 Sep 2008 19:11:43 -0400 Date: Tue, 2 Sep 2008 01:11:40 +0200 From: Aurelien Jarno Subject: Re: [Qemu-devel] sparc smul problem Message-ID: <20080901231140.GE20940@volta.aurel32.net> References: <20080901121035.R83237@stanley.csl.cornell.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Mon, Sep 01, 2008 at 10:05:45PM +0300, Blue Swirl wrote: > On 9/1/08, Vince Weaver wrote: > > Hello! > > > > I've been stuck on this all weekend, as I can't find where the actual > > problem is. I might be completely missing it, but I've tried a lot of things > > and can't make it work. > > > > On SPARC, the "smul" instruction multiplies two numbers, puts the result in > > the result register but also puts the top 32-bits of the 64-bit result into > > the "Y" register. > > > > As the attached code shows, the value of "Y" is wrong. Somehow after the > > multiply, the top 32 bits of the product rae all zeros. I've played around > > with the code generated by translate.c, and it looks like the shift and > > other instructions all work properly, but the 64-bit multiply the result is > > somehow being truncated. But I've looked at the generated code (on x86_64) > > and it looks like it is doing the right thing. > > > > So anyway, I'll have to take a look at this again later, but in case anyone > > else wants to look at it in case I am missing anything obvious. > > It looks like TCG on i386 host generates incorrect code for mulu2_i32, > I think the op should be imul (unsigned) instead of mul. This patch > fixes the problem. According to the IA-32 manual, mul (F7/4) corresponds to unsigned multiplication, while imul (F7/5) corresponds to signed multiplication. Therefore the patch does not looks correct. -- .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net