This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] S/390: Throw FE_INVALID exception in the fp2int libgcc routines
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Andreas Krebbel <krebbel at linux dot vnet dot ibm dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 30 Jan 2014 17:47:03 +0000
- Subject: Re: [PATCH] S/390: Throw FE_INVALID exception in the fp2int libgcc routines
- Authentication-results: sourceware.org; auth=none
- References: <20140130145746 dot GA30339 at bart>
On Thu, 30 Jan 2014, Andreas Krebbel wrote:
> @@ -81,6 +91,8 @@ __fixdfdi (double a1)
> l = (long long)1<<63;
> if (!SIGND(dl1))
> l--;
> + /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
> + fexceptdiv (0.0, 0.0);
> return l;
My understanding of this code is that the condition exp >= 11 means a
number with magnitude at least 0x1p63. If the number is exactly -0x1p63,
then the result of the most negative "long long" value should not involve
the "invalid" exception.
> @@ -78,6 +88,8 @@ __fixsfdi (float a1)
> l = (long long)1<<63;
> if (!SIGN(fl1))
> l--;
> + /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
> + fexceptdiv (0.0, 0.0);
> return l;
Likewise.
> @@ -90,6 +100,8 @@ __fixtfdi (long double a1)
> or more. */
> if (exp >= 0)
> {
> + /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
> + fexceptdiv (0.0, 0.0);
> l = 1ULL << 63; /* long long min */
> return SIGND (dl1) ? l : l - 1;
Likewise, except in this case there are also values whose integer part is
LLONG_MIN but whose fractional part is nonzero, for which "invalid" should
also not be raised.
(This complication only arises for conversion to signed integers, not for
conversion to unsigned. But for the conversions to unsigned, you need to
raise "invalid" for arguments <= -1, which your patch doesn't seem to do.)
--
Joseph S. Myers
joseph@codesourcery.com