This is the mail archive of the
java-discuss@sources.redhat.com
mailing list for the Java project.
Don't optimize by hand (Was Re: Lack of fabsf on Solaris (patch included))
Cedric Berger writes:
> Ok, this is becoming very, very interresting.
>
> I've tried compiling 3 variants of this code, ABS1()
> and ABS3() being legal C, ABS2() giving a warning.
>
> All of them compile properly ang give me valid code
> on my ARM platform (Green Hills compiler, optimized
> for space, thumb mode).
>
> But the surprising thing is that ABS1 is the variant
> that generates the better, optimum code!!! (only 3
> instruction, 6 byte of code, no data).
It's not all that surprising: the Green Hills compiler has a pattern
for fabs that it's used in this case.
It would be wrong to generalize too much from this, except perhaps
that the compiler ought to be able to do a better job with unions.
Andrew.