This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Re: [PATCH] Java: expand divide, expand conversions
- To: tromey@cygnus.com
- Subject: Re: [PATCH] Java: expand divide, expand conversions
- From: Andrew Haley <aph@pasanda.cygnus.co.uk>
- Date: 19 Jul 1999 18:00:36 -0000
- CC: tromey@cygnus.com, java-discuss@sourceware.cygnus.com
> Date: Mon, 19 Jul 1999 10:52:17 -0700
> From: Tom Tromey <tromey@cygnus.com>
>
> >> It seems like we could potentially optimize the test away in some
> >> situations (that is, if gcc has the necessary machinery for this,
> >> which is something I don't know).
>
> Andrew> The call to the divide subroutine isn't generated when
> Andrew> dividing by a constant, so there's no overhead in that case.
>
> Cool. I also meant the case where we have "a / b" but can prove that
> b != 0. Can gcc do this?
Yes, I think that if it can prove a region of code is unreaschable the
code will just be deleted. For example, if a division was already in
an `if (i != 0) ...' guarded block, the test could just be removed.
However, what we need is a rule which says:
If you can prove that i != 0, generate a `div' insn. Otherwise,
call a divide subroutine.
It's an interesting idea, but I don't think there's any way to express
it in gcc. I wonder...
Andrew.