[Top] [All Lists]

Re: [RFC] MIPS division by zero and libgcj...

To: Andrew Haley <>
Subject: Re: [RFC] MIPS division by zero and libgcj...
From: David Daney <>
Date: Thu, 10 Jun 2004 13:31:14 -0700
In-reply-to: <>
Original-recipient: rfc822;
References: <> <> <> <>
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031030
Andrew Haley wrote:

David Daney writes:
> Andrew Haley wrote:
> > MIPS div instructions never trap. However I think that GCC always emits > things like this when it cannot determine that the divisor is non zero: > > div $0,$17,$16
>         bne     $16,$0,1f
>         nop
>         break   7
> 1:
> >
> >No, there's no reason not to do it.  You'll have to write some hairy
> >code to satisfy all the rules, though.
> >
> What are the rules? Are they more complicated then throw an > ArithmeticException when the divisor is zero?

Yes.  You also have to do

 if (dividend == (jint) 0x80000000L && divisor == -1)
   return dividend;
and not throw an exception.

That is evidently what you have to do on i386. MIPS gives the right answer without faulting (i.e. hitting the break 7).

David Daney.

<Prev in Thread] Current Thread [Next in Thread>