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

--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Kyrylo Tkachov <[email protected]>:

https://gcc.gnu.org/g:95decbde1acc0c9a459d39e806106ab4e232085a

commit r17-6689-g95decbde1acc0c9a459d39e806106ab4e232085a
Author: Kyrylo Tkachov <[email protected]>
Date:   Tue Nov 24 02:43:01 2026 -0800

    match.pd: Only fold float conversion chains through a format that holds the
input [PR128460] [PR128912]

    The two-conversion rule in match.pd compares element_precision of the
    float types to decide whether the intermediate conversion can be dropped.
    Equal bit width does not imply that one format can represent the other.
    For example, float 16777215 converted to _Decimal32 becomes 1.677722E+7
    and converts back to 16777220.0f:

      _2 = (_Decimal32) f_1;
      _3 = (float) _2;

    was folded to f_1, returning 16777215.0f.  The same problem affects
    _Float16 and __bf16, which have the same width but different mantissa and
    exponent ranges.  (double) (_Float16) (__bf16) x was folded to
    (double) (__bf16) x, losing the overflow of 65536.0 to +Inf in _Float16.

    Add real_exact_conversion_p, which returns true if every value of one
    floating-point mode is exactly representable in another, by comparing
    radix, precision, exponent range and special value support of the real
    formats.  Both float-to-float sub-rules now require the intermediate type
    to be able to hold the type it is converted from.

    Bootstrapped and tested on aarch64-none-linux-gnu.

    gcc/ChangeLog:

            PR middle-end/128460
            PR middle-end/128912
            * real.cc (real_exact_conversion_p): New function.
            * real.h (real_exact_conversion_p): Declare.
            * match.pd (two conversions in a row): Require the intermediate
            float type to exactly represent the inner type in the float
            sub-rules.

    gcc/testsuite/ChangeLog:

            PR middle-end/128460
            PR middle-end/128912
            * gcc.dg/dfp/pr128460.c: New test.
            * gcc.dg/torture/pr128912.c: New test.

    Signed-off-by: Kyrylo Tkachov <[email protected]>
  • [Bug middle-end/128460] wrong c... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to