https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107723

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Xi Ruoyao <xry...@gcc.gnu.org>:

https://gcc.gnu.org/g:99182ea09f10beca8445396cbab491899536f5c3

commit r14-6455-g99182ea09f10beca8445396cbab491899536f5c3
Author: Xi Ruoyao <xry...@xry111.site>
Date:   Fri Nov 24 11:08:19 2023 +0800

    Only allow (int)trunc(x) to (int)x simplification with
-ffp-int-builtin-inexact [PR107723]

    With -fno-fp-int-builtin-inexact, trunc is not allowed to raise
    FE_INEXACT and it should produce an integral result (if the input is not
    NaN or Inf).  Thus FE_INEXACT should not be raised.

    But (int)x may raise FE_INEXACT when x is a non-integer, non-NaN, and
    non-Inf value.  C23 recommends to do so in a footnote.

    Thus we should not simplify (int)trunc(x) to (int)x if
    -fno-fp-int-builtin-inexact is in-effect.

    gcc/ChangeLog:

            PR middle-end/107723
            * convert.cc (convert_to_integer_1) [case BUILT_IN_TRUNC]: Break
            early if !flag_fp_int_builtin_inexact and flag_trapping_math.

    gcc/testsuite/ChangeLog:

            PR middle-end/107723
            * gcc.dg/torture/builtin-fp-int-inexact-trunc.c: New test.

Reply via email to