> > -    if ((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31)) {
> > +    if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 31) {
> > +       /* operands of same sign, result different sign */
> >         CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW);
> >     }
>
> I see this went in, but - huh?  The math doesn't make sense.
>
> T0 ^ T1 -> operands of different sign
> tmp ^ T1 ^ (-1) -> result has same sign as T1

The definitive reference for all this bit twiddling magic and
much more besides is an excellent book, "Hacker's Delight", by
Hank Warren.  It has loads of stuff about integer overflow and
whatnot.

J


_______________________________________________
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Reply via email to