* Re: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
@ 2019-01-24 19:16 Dominique d'Humières
0 siblings, 0 replies; 8+ messages in thread
From: Dominique d'Humières @ 2019-01-24 19:16 UTC (permalink / raw)
To: H.J. Lu, Iain Sandoe; +Cc: gcc-patches
The test gcc.dg/torture/fp-int-convert-timode-3.c fails on darwin: the results are
-0x1p+127
-0x1p+127
TIA
Dominique
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
2019-01-24 15:42 ` Christophe Lyon
@ 2019-01-24 20:39 ` Joseph Myers
0 siblings, 0 replies; 8+ messages in thread
From: Joseph Myers @ 2019-01-24 20:39 UTC (permalink / raw)
To: Christophe Lyon; +Cc: H.J. Lu, GCC Patches
On Thu, 24 Jan 2019, Christophe Lyon wrote:
> On Thu, 24 Jan 2019 at 15:31, Joseph Myers <joseph@codesourcery.com> wrote:
> >
> > On Thu, 24 Jan 2019, Christophe Lyon wrote:
> >
> > > The attached small patch adds
> > > /* { dg-require-effective-target fenv_exceptions } */
> > > to them.
> >
> > It should be a *new* effective-target, because these tests are nothing to
> > do with exceptions; they're about rounding modes (but actually you only
> > need an effective-target that tests whether fenv.h can be included because
> > the tests contain #ifdef for the rounding modes used).
> >
>
> OK, here is an updated version, including a doc for fenv_exceptions.
OK.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
2019-01-24 14:58 ` Joseph Myers
@ 2019-01-24 15:42 ` Christophe Lyon
2019-01-24 20:39 ` Joseph Myers
0 siblings, 1 reply; 8+ messages in thread
From: Christophe Lyon @ 2019-01-24 15:42 UTC (permalink / raw)
To: Joseph Myers; +Cc: H.J. Lu, GCC Patches
[-- Attachment #1: Type: text/plain, Size: 651 bytes --]
On Thu, 24 Jan 2019 at 15:31, Joseph Myers <joseph@codesourcery.com> wrote:
>
> On Thu, 24 Jan 2019, Christophe Lyon wrote:
>
> > The attached small patch adds
> > /* { dg-require-effective-target fenv_exceptions } */
> > to them.
>
> It should be a *new* effective-target, because these tests are nothing to
> do with exceptions; they're about rounding modes (but actually you only
> need an effective-target that tests whether fenv.h can be included because
> the tests contain #ifdef for the rounding modes used).
>
OK, here is an updated version, including a doc for fenv_exceptions.
Christophe
> --
> Joseph S. Myers
> joseph@codesourcery.com
[-- Attachment #2: fix-r268216-fenv.patch-v2.txt --]
[-- Type: text/plain, Size: 3943 bytes --]
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 32a8f6a..a670456 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2128,6 +2128,13 @@ Target can truncate a file from a file descriptor, as used by
@file{libgfortran/io/unix.c:fd_truncate}; i.e.@: @code{ftruncate} or
@code{chsize}.
+@item fenv
+Target provides @file{fenv.h} include file.
+
+@item fenv_exceptions
+Target supports @file{fenv.h} with all the standard IEEE exceptions
+and floating-point exceptions are raised by arithmetic operations.
+
@item freestanding
Target is @samp{freestanding} as defined in section 4 of the C99 standard.
Effectively, it is a target which supports no extra headers or libraries
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c
index fa6eb6b..c445d10 100644
--- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c
@@ -4,6 +4,7 @@
/* { dg-require-effective-target __float128 } */
/* { dg-require-effective-target base_quadfloat_support } */
/* { dg-require-effective-target int128 } */
+/* { dg-require-effective-target fenv } */
/* { dg-options "-frounding-math" } */
/* { dg-add-options __float128 } */
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c
index d6454fa..0c524a8 100644
--- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c
@@ -2,6 +2,7 @@
float. */
/* { dg-do run } */
/* { dg-require-effective-target int128 } */
+/* { dg-require-effective-target fenv } */
/* { dg-options "-frounding-math" } */
#include <fenv.h>
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
index dbfa481..a82f03d 100644
--- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
@@ -2,6 +2,7 @@
float. */
/* { dg-do run } */
/* { dg-require-effective-target int128 } */
+/* { dg-require-effective-target fenv } */
/* { dg-options "-frounding-math" } */
#include <fenv.h>
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
index 63a305e..707d539 100644
--- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
@@ -2,6 +2,7 @@
float. */
/* { dg-do run } */
/* { dg-require-effective-target int128 } */
+/* { dg-require-effective-target fenv } */
/* { dg-options "-frounding-math" } */
#include <fenv.h>
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
index e716109..09600f9 100644
--- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
@@ -2,6 +2,7 @@
float. */
/* { dg-do run } */
/* { dg-require-effective-target int128 } */
+/* { dg-require-effective-target fenv } */
/* { dg-options "-frounding-math" } */
#include <fenv.h>
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index c0df467..92202ff 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -8536,6 +8536,14 @@ proc check_effective_target_avr_tiny { } {
}
}
+# Return 1 if <fenv.h> is available.
+
+proc check_effective_target_fenv {} {
+ return [check_no_compiler_messages fenv object {
+ #include <fenv.h>
+ } [add_options_for_ieee "-std=gnu99"]]
+}
+
# Return 1 if <fenv.h> is available with all the standard IEEE
# exceptions and floating-point exceptions are raised by arithmetic
# operations. (If the target requires special options for "inexact"
[-- Attachment #3: fix-r268216-fenv.chlog-v2.txt --]
[-- Type: text/plain, Size: 608 bytes --]
2019-01-24 Christophe Lyon <christophe.lyon@linaro.org>
gcc/
* doc/sourcebuild.texi (Environment attributes): Add fenv and
fenv_exceptions description.
2019-01-24 Christophe Lyon <christophe.lyon@linaro.org>
gcc/testsuite/
* lib/target-supports.exp (check_effective_target_fenv): New.
* gcc.dg/torture/fp-int-convert-float128-timode-3.c: Add missing
fenv effective target.
* gcc.dg/torture/fp-int-convert-timode-1.c: Likewise.
* gcc.dg/torture/fp-int-convert-timode-2.c: Likewise.
* gcc.dg/torture/fp-int-convert-timode-3.c: Likewise.
* gcc.dg/torture/fp-int-convert-timode-4.c: Likewise.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
2019-01-24 13:50 ` Christophe Lyon
@ 2019-01-24 14:58 ` Joseph Myers
2019-01-24 15:42 ` Christophe Lyon
0 siblings, 1 reply; 8+ messages in thread
From: Joseph Myers @ 2019-01-24 14:58 UTC (permalink / raw)
To: Christophe Lyon; +Cc: H.J. Lu, GCC Patches
On Thu, 24 Jan 2019, Christophe Lyon wrote:
> The attached small patch adds
> /* { dg-require-effective-target fenv_exceptions } */
> to them.
It should be a *new* effective-target, because these tests are nothing to
do with exceptions; they're about rounding modes (but actually you only
need an effective-target that tests whether fenv.h can be included because
the tests contain #ifdef for the rounding modes used).
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
2019-01-23 21:22 ` H.J. Lu
@ 2019-01-24 13:50 ` Christophe Lyon
2019-01-24 14:58 ` Joseph Myers
0 siblings, 1 reply; 8+ messages in thread
From: Christophe Lyon @ 2019-01-24 13:50 UTC (permalink / raw)
To: H.J. Lu; +Cc: Joseph Myers, GCC Patches
[-- Attachment #1: Type: text/plain, Size: 1156 bytes --]
On Wed, 23 Jan 2019 at 22:14, H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Wed, Jan 23, 2019 at 12:50 PM Joseph Myers <joseph@codesourcery.com> wrote:
> >
> > On Wed, 23 Jan 2019, H.J. Lu wrote:
> >
> > > + fesetround (FE_DOWNWARD);
> > > + float fs = s128;
> > > + if (fs != -0x1p+127)
> > > + abort ();
> > > + double ds = s128;
> > > + if (ds != -0x1p+127)
> > > + abort ();
> >
> > This definitely needs #ifdef FE_DOWNWARD; even just limited to glibc
> > configurations, there are soft-float 64-bit configurations with no support
> > for rounding modes other than to-nearest. Likewise for the other tests
> > using rounding modes other than FE_TONEAREST. OK with that change.
> >
> > It's possible it will turn out a new effective-target is needed for fenv.h
> > support, if there are still configurations people are testing with that
> > lack fenv.h at all.
> >
>
> This is the patch I am checking in.
>
Hi,
The new tests fail to compile on aarch64-elf:
fatal error: fenv.h: No such file or directory
The attached small patch adds
/* { dg-require-effective-target fenv_exceptions } */
to them.
OK?
Christophe
> Thanks.
>
> --
> H.J.
[-- Attachment #2: fix-r268216-fenv.chlog.txt --]
[-- Type: text/plain, Size: 317 bytes --]
2019-01-24 Christophe Lyon <christophe.lyon@linaro.org>
* gcc.dg/torture/fp-int-convert-timode-1.c: Add missing
fenv_exceptions effective target.
* gcc.dg/torture/fp-int-convert-timode-2.c: Likewise.
* gcc.dg/torture/fp-int-convert-timode-3.c: Likewise.
* gcc.dg/torture/fp-int-convert-timode-4.c: Likewise.
[-- Attachment #3: fix-r268216-fenv.patch.txt --]
[-- Type: text/plain, Size: 1964 bytes --]
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c
index d6454fa..8cadc1f 100644
--- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c
@@ -2,6 +2,7 @@
float. */
/* { dg-do run } */
/* { dg-require-effective-target int128 } */
+/* { dg-require-effective-target fenv_exceptions } */
/* { dg-options "-frounding-math" } */
#include <fenv.h>
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
index dbfa481..ef97c1a 100644
--- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
@@ -2,6 +2,7 @@
float. */
/* { dg-do run } */
/* { dg-require-effective-target int128 } */
+/* { dg-require-effective-target fenv_exceptions } */
/* { dg-options "-frounding-math" } */
#include <fenv.h>
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
index 63a305e..63f68fc 100644
--- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
@@ -2,6 +2,7 @@
float. */
/* { dg-do run } */
/* { dg-require-effective-target int128 } */
+/* { dg-require-effective-target fenv_exceptions } */
/* { dg-options "-frounding-math" } */
#include <fenv.h>
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
index e716109..acf1ce3 100644
--- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
@@ -2,6 +2,7 @@
float. */
/* { dg-do run } */
/* { dg-require-effective-target int128 } */
+/* { dg-require-effective-target fenv_exceptions } */
/* { dg-options "-frounding-math" } */
#include <fenv.h>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
2019-01-23 20:57 ` Joseph Myers
@ 2019-01-23 21:22 ` H.J. Lu
2019-01-24 13:50 ` Christophe Lyon
0 siblings, 1 reply; 8+ messages in thread
From: H.J. Lu @ 2019-01-23 21:22 UTC (permalink / raw)
To: Joseph Myers; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 824 bytes --]
On Wed, Jan 23, 2019 at 12:50 PM Joseph Myers <joseph@codesourcery.com> wrote:
>
> On Wed, 23 Jan 2019, H.J. Lu wrote:
>
> > + fesetround (FE_DOWNWARD);
> > + float fs = s128;
> > + if (fs != -0x1p+127)
> > + abort ();
> > + double ds = s128;
> > + if (ds != -0x1p+127)
> > + abort ();
>
> This definitely needs #ifdef FE_DOWNWARD; even just limited to glibc
> configurations, there are soft-float 64-bit configurations with no support
> for rounding modes other than to-nearest. Likewise for the other tests
> using rounding modes other than FE_TONEAREST. OK with that change.
>
> It's possible it will turn out a new effective-target is needed for fenv.h
> support, if there are still configurations people are testing with that
> lack fenv.h at all.
>
This is the patch I am checking in.
Thanks.
--
H.J.
[-- Attachment #2: 0001-libgcc2.c-Correct-DI-TI-SF-DF-conversions.patch --]
[-- Type: text/x-patch, Size: 5867 bytes --]
From ecb5e6357cff988a6e34aed324f13b777af82deb Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 22 Jan 2019 18:55:35 -0800
Subject: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
FSTYPE FUNC (DWtype u) in libgcc2.c, which converts DI/TI to SF/DF, has
/* No leading bits means u == minimum. */
if (count == 0)
return -(Wtype_MAXp1_F * (Wtype_MAXp1_F / 2));
in the third case (where actually count == 0 only means the high part is
minimum). It should be:
/* No leading bits means u == minimum. */
if (count == 0)
return Wtype_MAXp1_F * (FSTYPE) (hi | ((UWtype) u != 0));
instead.
gcc/testsuite/
2019-01-23 H.J. Lu <hongjiu.lu@intel.com>
PR libgcc/88931
* gcc.dg/torture/fp-int-convert-timode-1.c: New test.
* gcc.dg/torture/fp-int-convert-timode-2.c: Likewise.
* gcc.dg/torture/fp-int-convert-timode-3.c: Likewise.
* gcc.dg/torture/fp-int-convert-timode-4.c: Likewise.
libgcc/
2019-01-23 Joseph Myers <joseph@codesourcery.com>
PR libgcc/88931
* libgcc2.c (FSTYPE FUNC (DWtype u)): Correct no leading bits
case.
---
.../gcc.dg/torture/fp-int-convert-timode-1.c | 25 +++++++++++++++++
.../gcc.dg/torture/fp-int-convert-timode-2.c | 27 +++++++++++++++++++
.../gcc.dg/torture/fp-int-convert-timode-3.c | 27 +++++++++++++++++++
.../gcc.dg/torture/fp-int-convert-timode-4.c | 27 +++++++++++++++++++
libgcc/libgcc2.c | 2 +-
5 files changed, 107 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c
create mode 100644 gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
create mode 100644 gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
create mode 100644 gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c
new file mode 100644
index 00000000000..d6454fada72
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c
@@ -0,0 +1,25 @@
+/* Test for correct rounding of conversions from __int128 to
+ float. */
+/* { dg-do run } */
+/* { dg-require-effective-target int128 } */
+/* { dg-options "-frounding-math" } */
+
+#include <fenv.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+ volatile unsigned long long h = 0x8000000000000000LL;
+ volatile unsigned long long l = 0xdLL;
+ volatile unsigned __int128 u128 = (((unsigned __int128) h) << 64) | l;
+ volatile __int128 s128 = u128;
+ fesetround (FE_TONEAREST);
+ float fs = s128;
+ if (fs != -0x1p+127)
+ abort ();
+ double ds = s128;
+ if (ds != -0x1p+127)
+ abort ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
new file mode 100644
index 00000000000..dbfa481b4fb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
@@ -0,0 +1,27 @@
+/* Test for correct rounding of conversions from __int128 to
+ float. */
+/* { dg-do run } */
+/* { dg-require-effective-target int128 } */
+/* { dg-options "-frounding-math" } */
+
+#include <fenv.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+#ifdef FE_DOWNWARD
+ volatile unsigned long long h = 0x8000000000000000LL;
+ volatile unsigned long long l = 0xdLL;
+ volatile unsigned __int128 u128 = (((unsigned __int128) h) << 64) | l;
+ volatile __int128 s128 = u128;
+ fesetround (FE_DOWNWARD);
+ float fs = s128;
+ if (fs != -0x1p+127)
+ abort ();
+ double ds = s128;
+ if (ds != -0x1p+127)
+ abort ();
+#endif
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
new file mode 100644
index 00000000000..63a305ec3c2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
@@ -0,0 +1,27 @@
+/* Test for correct rounding of conversions from __int128 to
+ float. */
+/* { dg-do run } */
+/* { dg-require-effective-target int128 } */
+/* { dg-options "-frounding-math" } */
+
+#include <fenv.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+#ifdef FE_UPWARD
+ volatile unsigned long long h = 0x8000000000000000LL;
+ volatile unsigned long long l = 0xdLL;
+ volatile unsigned __int128 u128 = (((unsigned __int128) h) << 64) | l;
+ volatile __int128 s128 = u128;
+ fesetround (FE_UPWARD);
+ float fs = s128;
+ if (fs != -0x1.fffffep+126)
+ abort ();
+ double ds = s128;
+ if (ds != -0x1.fffffffffffffp+126)
+ abort ();
+#endif
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
new file mode 100644
index 00000000000..e71610995cd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
@@ -0,0 +1,27 @@
+/* Test for correct rounding of conversions from __int128 to
+ float. */
+/* { dg-do run } */
+/* { dg-require-effective-target int128 } */
+/* { dg-options "-frounding-math" } */
+
+#include <fenv.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+#ifdef FE_TOWARDZERO
+ volatile unsigned long long h = 0x8000000000000000LL;
+ volatile unsigned long long l = 0xdLL;
+ volatile unsigned __int128 u128 = (((unsigned __int128) h) << 64) | l;
+ volatile __int128 s128 = u128;
+ fesetround (FE_TOWARDZERO);
+ float fs = s128;
+ if (fs != -0x1.fffffep+126)
+ abort ();
+ double ds = s128;
+ if (ds != -0x1.fffffffffffffp+126)
+ abort ();
+#endif
+ exit (0);
+}
diff --git a/libgcc/libgcc2.c b/libgcc/libgcc2.c
index d84f25b0779..04d3185e805 100644
--- a/libgcc/libgcc2.c
+++ b/libgcc/libgcc2.c
@@ -1684,7 +1684,7 @@ FUNC (DWtype u)
/* No leading bits means u == minimum. */
if (count == 0)
- return -(Wtype_MAXp1_F * (Wtype_MAXp1_F / 2));
+ return Wtype_MAXp1_F * (FSTYPE) (hi | ((UWtype) u != 0));
shift = 1 + W_TYPE_SIZE - count;
--
2.20.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
2019-01-23 12:50 H.J. Lu
@ 2019-01-23 20:57 ` Joseph Myers
2019-01-23 21:22 ` H.J. Lu
0 siblings, 1 reply; 8+ messages in thread
From: Joseph Myers @ 2019-01-23 20:57 UTC (permalink / raw)
To: H.J. Lu; +Cc: gcc-patches
On Wed, 23 Jan 2019, H.J. Lu wrote:
> + fesetround (FE_DOWNWARD);
> + float fs = s128;
> + if (fs != -0x1p+127)
> + abort ();
> + double ds = s128;
> + if (ds != -0x1p+127)
> + abort ();
This definitely needs #ifdef FE_DOWNWARD; even just limited to glibc
configurations, there are soft-float 64-bit configurations with no support
for rounding modes other than to-nearest. Likewise for the other tests
using rounding modes other than FE_TONEAREST. OK with that change.
It's possible it will turn out a new effective-target is needed for fenv.h
support, if there are still configurations people are testing with that
lack fenv.h at all.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
@ 2019-01-23 12:50 H.J. Lu
2019-01-23 20:57 ` Joseph Myers
0 siblings, 1 reply; 8+ messages in thread
From: H.J. Lu @ 2019-01-23 12:50 UTC (permalink / raw)
To: gcc-patches; +Cc: Joseph Myers
FSTYPE FUNC (DWtype u) in libgcc2.c, which converts DI/TI to SF/DF, has
/* No leading bits means u == minimum. */
if (count == 0)
return -(Wtype_MAXp1_F * (Wtype_MAXp1_F / 2));
in the third case (where actually count == 0 only means the high part is
minimum). It should be:
/* No leading bits means u == minimum. */
if (count == 0)
return Wtype_MAXp1_F * (FSTYPE) (hi | ((UWtype) u != 0));
instead.
gcc/testsuite/
2019-01-23 H.J. Lu <hongjiu.lu@intel.com>
PR libgcc/88931
* gcc.dg/torture/fp-int-convert-timode-1.c: New test.
* gcc.dg/torture/fp-int-convert-timode-2.c: Likewise.
* gcc.dg/torture/fp-int-convert-timode-3.c: Likewise.
* gcc.dg/torture/fp-int-convert-timode-4.c: Likewise.
libgcc/
2019-01-23 Joseph Myers <joseph@codesourcery.com>
PR libgcc/88931
* libgcc2.c (FSTYPE FUNC (DWtype u)): Correct no leading bits
case.
---
.../gcc.dg/torture/fp-int-convert-timode-1.c | 25 +++++++++++++++++++
.../gcc.dg/torture/fp-int-convert-timode-2.c | 25 +++++++++++++++++++
.../gcc.dg/torture/fp-int-convert-timode-3.c | 25 +++++++++++++++++++
.../gcc.dg/torture/fp-int-convert-timode-4.c | 25 +++++++++++++++++++
libgcc/libgcc2.c | 2 +-
5 files changed, 101 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c
create mode 100644 gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
create mode 100644 gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
create mode 100644 gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c
new file mode 100644
index 00000000000..d6454fada72
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c
@@ -0,0 +1,25 @@
+/* Test for correct rounding of conversions from __int128 to
+ float. */
+/* { dg-do run } */
+/* { dg-require-effective-target int128 } */
+/* { dg-options "-frounding-math" } */
+
+#include <fenv.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+ volatile unsigned long long h = 0x8000000000000000LL;
+ volatile unsigned long long l = 0xdLL;
+ volatile unsigned __int128 u128 = (((unsigned __int128) h) << 64) | l;
+ volatile __int128 s128 = u128;
+ fesetround (FE_TONEAREST);
+ float fs = s128;
+ if (fs != -0x1p+127)
+ abort ();
+ double ds = s128;
+ if (ds != -0x1p+127)
+ abort ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
new file mode 100644
index 00000000000..8f831f7e98a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c
@@ -0,0 +1,25 @@
+/* Test for correct rounding of conversions from __int128 to
+ float. */
+/* { dg-do run } */
+/* { dg-require-effective-target int128 } */
+/* { dg-options "-frounding-math" } */
+
+#include <fenv.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+ volatile unsigned long long h = 0x8000000000000000LL;
+ volatile unsigned long long l = 0xdLL;
+ volatile unsigned __int128 u128 = (((unsigned __int128) h) << 64) | l;
+ volatile __int128 s128 = u128;
+ fesetround (FE_DOWNWARD);
+ float fs = s128;
+ if (fs != -0x1p+127)
+ abort ();
+ double ds = s128;
+ if (ds != -0x1p+127)
+ abort ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
new file mode 100644
index 00000000000..12cac66f39d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
@@ -0,0 +1,25 @@
+/* Test for correct rounding of conversions from __int128 to
+ float. */
+/* { dg-do run } */
+/* { dg-require-effective-target int128 } */
+/* { dg-options "-frounding-math" } */
+
+#include <fenv.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+ volatile unsigned long long h = 0x8000000000000000LL;
+ volatile unsigned long long l = 0xdLL;
+ volatile unsigned __int128 u128 = (((unsigned __int128) h) << 64) | l;
+ volatile __int128 s128 = u128;
+ fesetround (FE_UPWARD);
+ float fs = s128;
+ if (fs != -0x1.fffffep+126)
+ abort ();
+ double ds = s128;
+ if (ds != -0x1.fffffffffffffp+126)
+ abort ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
new file mode 100644
index 00000000000..b1d8b83eb50
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
@@ -0,0 +1,25 @@
+/* Test for correct rounding of conversions from __int128 to
+ float. */
+/* { dg-do run } */
+/* { dg-require-effective-target int128 } */
+/* { dg-options "-frounding-math" } */
+
+#include <fenv.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+ volatile unsigned long long h = 0x8000000000000000LL;
+ volatile unsigned long long l = 0xdLL;
+ volatile unsigned __int128 u128 = (((unsigned __int128) h) << 64) | l;
+ volatile __int128 s128 = u128;
+ fesetround (FE_TOWARDZERO);
+ float fs = s128;
+ if (fs != -0x1.fffffep+126)
+ abort ();
+ double ds = s128;
+ if (ds != -0x1.fffffffffffffp+126)
+ abort ();
+ exit (0);
+}
diff --git a/libgcc/libgcc2.c b/libgcc/libgcc2.c
index d84f25b0779..04d3185e805 100644
--- a/libgcc/libgcc2.c
+++ b/libgcc/libgcc2.c
@@ -1684,7 +1684,7 @@ FUNC (DWtype u)
/* No leading bits means u == minimum. */
if (count == 0)
- return -(Wtype_MAXp1_F * (Wtype_MAXp1_F / 2));
+ return Wtype_MAXp1_F * (FSTYPE) (hi | ((UWtype) u != 0));
shift = 1 + W_TYPE_SIZE - count;
--
2.20.1
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-01-24 20:38 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-24 19:16 [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions Dominique d'Humières
-- strict thread matches above, loose matches on Subject: below --
2019-01-23 12:50 H.J. Lu
2019-01-23 20:57 ` Joseph Myers
2019-01-23 21:22 ` H.J. Lu
2019-01-24 13:50 ` Christophe Lyon
2019-01-24 14:58 ` Joseph Myers
2019-01-24 15:42 ` Christophe Lyon
2019-01-24 20:39 ` Joseph Myers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).