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

Hongtao.liu <crazylht at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |crazylht at gmail dot com

--- Comment #4 from Hongtao.liu <crazylht at gmail dot com> ---
The intrinsic is expanded to rtl FIX, and then be optimized to 0 for NANs.

2201      /* Although the overflow semantics of RTL's FIX and UNSIGNED_FIX
2202         operators are intentionally left unspecified (to ease
implementation
2203         by target backends), for consistency, this routine implements the
2204         same semantics for constant folding as used by the middle-end.  */
2205
2206      /* This was formerly used only for non-IEEE float.
2207         egg...@twinsun.com says it is safe for IEEE also.  */
2208      REAL_VALUE_TYPE t;
2209      const REAL_VALUE_TYPE *x = CONST_DOUBLE_REAL_VALUE (op);
2210      wide_int wmax, wmin;
2211      /* This is part of the abi to real_to_integer, but we check
2212         things before making this call.  */
2213      bool fail;
2214
2215      switch (code)
2216        {
2217        case FIX:
2218          if (REAL_VALUE_ISNAN (*x))
2219            return const0_rtx;

According to IEEE-2019, when a NaN or infinite operand cannot be represented in
the destination format and this cannot otherwise be indicated, the invalid
operation exception shall be signaled.
And there's comments says "for consistency, this routine implements the same
semantics for constant folding as used by the middle-end." and "This was
formerly used only for non-IEEE float."

Maybe we should prevent this.

Reply via email to