[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add / subtract
From: |
Daniel Jacobowitz |
Subject: |
Re: [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add / subtract |
Date: |
Fri, 28 Apr 2006 11:47:01 -0400 |
User-agent: |
Mutt/1.5.8i |
On Fri, Apr 28, 2006 at 04:51:39PM +0200, Dirk Behme wrote:
> Daniel Jacobowitz wrote:
> >I haven't tested the patched qemu, but I did test the expressions
> >themselves in standalone code, and they definitely do not detect
> >overflow.
>
> Maybe you can test Ralf's alternative proposal
>
> http://lists.gnu.org/archive/html/qemu-devel/2006-02/msg00154.html
>
> as well?
Using 64-bit math for this would be awful for performance. My original
checks were wrong; we just need to use a correct fix... Lightly
tested, but I think this is right for add:
- if ((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31)) {
+ if (~(T0 ^ T1) & (T0 ^ tmp) & 0x80000000) {
And this for sub:
- if (!((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31))) {
+ if ((T0 ^ T1) & (T0 ^ tmp) & 0x80000000) {
--
Daniel Jacobowitz
CodeSourcery