[PATCH][4.3] Deprecate -ftrapv
Robert Dewar
dewar@adacore.com
Sat Mar 1 02:33:00 GMT 2008
Joseph S. Myers wrote:
> On Fri, 29 Feb 2008, Robert Dewar wrote:
>
>> Well no one "needs" anything in this sense, any interfaced is Turing
>> complete so there is *always* a work around deficiencies in the back end. But
>> right now, the "do this itself" is really horribly inefficient:
>
> You can see the C code in libgcc2.c (__addvSI3 etc.) used by -ftrapv (that
> code depends on signed overflow wrapping as has been noted before, it
> should of course be written with unsigned types). It does use
> double-width types for multiplication (and some more complicated code for
> multiplication of types that are already double-width).
>
> If it were done at gimplification time I imagine something like the libgcc
> code would be used, but with conversions to/from unsigned inserted as
> needed. It would be possible to do optimizations at gimplification time
> if one argument is constant (converting to a range check).
Well presumably one would want to use target dependent stuff for
detecting overflow where it exists (sticky overflow bits on
power, O flag on PC, trapping add on MIPS etc).
>
More information about the Gcc-patches
mailing list