This is the mail archive of the
mailing list for the GCC project.
Re: float to int conversions
On Thu, Feb 27, 2003 at 10:37:28AM +1030, Alan Modra wrote:
> ... particularly people who have worked with IBM compilers, expect
> float->int conversions to peg at the min/max values.
They should be educated as to what the relevant standards actually
say, and thus what can actually be relied upon.
> Which is of
> course what the underlying machine instructions do on powerpc, and
> probably on most architectures.
Possibly. Though most architectures don't have both signed and
unsigned conversion instructions, and you won't want to add extra
overhead for the not-implemented case if it's not necessary.
> Should I look at implementing target hooks, so that this patch can be
> made Java specific?
For FLOAT_FIX_BOUND_OVERFLOW? I suppose, sure. That would
allow better optimization for Java in the cases that matter.
I'd be surprised if any target yields 0 for NaN; most of the
ones I know yield INT_MAX. For this I think you'd be best
just open-coding the comparison in the trees that Java emits.
> That way we could enable FLOAT_FIX_NANS_TO_ZERO
> and FLOAT_FIX_BOUND_OVERFLOW for Java, and C, C++ and Fortran would
> just get FLOAT_FIX_BOUND_OVERFLOW, resulting in minimal overhead.
Um, why would C, C++ and Fortran get FLOAT_FIX_BOUND_OVERFLOW?