[Committed] Use force_fit_type_double in round_up

Roger Sayle roger@eyesopen.com
Tue Jan 30 05:03:00 GMT 2007


As suggested by Richard Guenther, the following patch improves upon my
recent bug fix to fold-const.c's round_up.  Instead of calling
build_int_cst_wide_type to construct an INTEGER_CST and then call
copy_node on the result if we need to set TREE_OVERFLOW, it's slightly
more convenient to use the new force_fit_type_double API to do this for
us.  Additionally, I made or two other minor tweaks, including changing
the type of the local variable "high" to be an *unsigned* HOST_WIDE_INT to
avoid invoking undefined behaviour on overflow.

The following patch was tested on i686-pc-linux-gnu, with a full "make
bootstrap", all default languages including Ada and regression tested with
a top-level "make -k check" with no new failures.

Committed to mainline as revision 121332.


2007-01-29  Roger Sayle  <roger@eyesopen.com>
            Richard Guenther  <rguenther@suse.de>

        * fold-const.c (round_up): Make HIGH an unsigned HOST_WIDE_INT to
        avoid undefined behaviour on overflow.  Use force_fit_type_double
        to construct the constant with the specified TREE_OVERFLOW.

Roger
--
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patchs8.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070130/e5a92cc3/attachment.txt>


More information about the Gcc-patches mailing list