From: Daniel Jacobowitz <drow@false.org>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add/subtract
Date: Mon, 1 May 2006 15:18:11 -0400 [thread overview]
Message-ID: <20060501191811.GA10837@nevyn.them.org> (raw)
In-Reply-To: <44565680.4050003@mail.berlios.de>
On Mon, May 01, 2006 at 08:42:08PM +0200, Stefan Weil wrote:
> >- if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 31) {
> >+ if (~(T0 ^ T1) & (T0 ^ tmp) & 0x80000000) {
> Hello Dirk,
>
> which additions / subtractions are handled incorrectly by the current code?
> Here is the result of a test which shows that the current code (which is
> based on my patch)
> raises an exception for 0x80000000 + 0x80000000.
>
> Daniel, perhaps you could sent the code you used to check overflow
> conditions?
I used GDB.
(gdb) set $T0 = 0x80000000
(gdb) set $T1 = 0x80000000
(gdb) set $tmp = $T0 + $T1
(gdb) p (($tmp ^ $T1 ^ (-1)) & ($T0 ^ $T1)) >> 31
$1 = 0
I see no reason why it should be wrong. $tmp is of course zero.
The high bit of tmp is not the same as the high bit of T1, therefore
$tmp ^ $T1 ^ (-1) == 0. Therefore the if is false. I even compiled
and ran the sample -> no exception.
Oh, damn! tmp is not the result, T0 is the result. No wonder this
didn't make any sense. I apologize, I'm really batting zero today.
--
Daniel Jacobowitz
CodeSourcery
next prev parent reply other threads:[~2006-05-01 19:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-01 18:42 [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add/subtract Stefan Weil
2006-05-01 19:18 ` Daniel Jacobowitz [this message]
2006-05-01 21:40 ` Fabrice Bellard
-- strict thread matches above, loose matches on Subject: below --
2006-05-01 16:44 Dirk Behme
2006-05-01 19:01 ` Fabrice Bellard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060501191811.GA10837@nevyn.them.org \
--to=drow@false.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).