[PATCH]: fix conversion of nearbyint/rint -> lrint

Kaveh R. GHAZI ghazi@caip.rutgers.edu
Mon Mar 5 15:17:00 GMT 2007


On Mon, 5 Mar 2007, Richard Guenther wrote:

> > Okay for mainline/4.2/4.1?
>
> I think this is not correct, as lrint will get extra exceptions compared
> to using conversion and rint (the invalid exception in case the result
> doesn't fit the integer type). It looks like now we are only trying to
> not remove traps and do not care about introducing more, which is wrong
> as you noted.  I fear the only valid solution is to make both
> transformations conditional under flag_no_trapping_math.
>
> Or am I missing something?

True, plain rint won't generate FE_INVALID.  But we're not converting
plain rint, we're converting e.g. (long)rint -> lrint.

AFAICT, the cast-to-long will generate FE_INVALID given an argument that
doesn't fit into a long.  Try it with e.g. DBL_MAX.

		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu



More information about the Gcc-patches mailing list