public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH] Fix __builtin_round{,f,l} ICE on x86 (PR target/84827)
  2018-03-13  8:35 [PATCH] Fix __builtin_round{,f,l} ICE on x86 (PR target/84827) Jakub Jelinek
@ 2018-03-13  7:51 ` Uros Bizjak
  0 siblings, 0 replies; 2+ messages in thread
From: Uros Bizjak @ 2018-03-13  7:51 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Joseph S. Myers, gcc-patches

On Mon, Mar 12, 2018 at 10:14 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> Since r237074 the 387 rounding insns are guarded with
> (flag_fp_int_builtin_inexact || !flag_trapping_math), and the
> round<mode>2 expander is enabled for 387 fancy math whenever
> flag_unsafe_math_optimizations; as the testcase shows, the latter
> doesn't imply the former, so this patch adds another guard.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2018-03-12  Jakub Jelinek  <jakub@redhat.com>
>
>         PR target/84827
>         * config/i386/i386.md (round<mode>2): For 387 fancy math, disable
>         pattern if -ftrapping-math -fno-fp-int-builtin-inexact.
>
>         * gcc.target/i386/pr84827.c: New test.

OK for trunk and backports.

Thanks,
Uros.

> --- gcc/config/i386/i386.md.jj  2018-03-05 16:59:42.881641832 +0100
> +++ gcc/config/i386/i386.md     2018-03-12 15:54:28.925304229 +0100
> @@ -16311,7 +16311,8 @@ (define_expand "round<mode>2"
>    "(TARGET_USE_FANCY_MATH_387
>      && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
>         || TARGET_MIX_SSE_I387)
> -    && flag_unsafe_math_optimizations)
> +    && flag_unsafe_math_optimizations
> +    && (flag_fp_int_builtin_inexact || !flag_trapping_math))
>     || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH
>         && !flag_trapping_math && !flag_rounding_math)"
>  {
> --- gcc/testsuite/gcc.target/i386/pr84827.c.jj  2018-03-12 16:04:20.195411779 +0100
> +++ gcc/testsuite/gcc.target/i386/pr84827.c     2018-03-12 15:54:58.041309098 +0100
> @@ -0,0 +1,21 @@
> +/* PR target/84827 */
> +/* { dg-do compile } */
> +/* { dg-options "-Ofast -fno-fp-int-builtin-inexact -ftrapping-math -fno-associative-math -mfpmath=387" } */
> +
> +double
> +f1 (double a)
> +{
> +  return __builtin_round (a);
> +}
> +
> +float
> +f2 (float a)
> +{
> +  return __builtin_roundf (a);
> +}
> +
> +long double
> +f3 (long double a)
> +{
> +  return __builtin_roundl (a);
> +}
>
>         Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] Fix __builtin_round{,f,l} ICE on x86 (PR target/84827)
@ 2018-03-13  8:35 Jakub Jelinek
  2018-03-13  7:51 ` Uros Bizjak
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2018-03-13  8:35 UTC (permalink / raw)
  To: Uros Bizjak, Joseph S. Myers; +Cc: gcc-patches

Hi!

Since r237074 the 387 rounding insns are guarded with
(flag_fp_int_builtin_inexact || !flag_trapping_math), and the
round<mode>2 expander is enabled for 387 fancy math whenever
flag_unsafe_math_optimizations; as the testcase shows, the latter
doesn't imply the former, so this patch adds another guard.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2018-03-12  Jakub Jelinek  <jakub@redhat.com>

	PR target/84827
	* config/i386/i386.md (round<mode>2): For 387 fancy math, disable
	pattern if -ftrapping-math -fno-fp-int-builtin-inexact.

	* gcc.target/i386/pr84827.c: New test.

--- gcc/config/i386/i386.md.jj	2018-03-05 16:59:42.881641832 +0100
+++ gcc/config/i386/i386.md	2018-03-12 15:54:28.925304229 +0100
@@ -16311,7 +16311,8 @@ (define_expand "round<mode>2"
   "(TARGET_USE_FANCY_MATH_387
     && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)
 	|| TARGET_MIX_SSE_I387)
-    && flag_unsafe_math_optimizations)
+    && flag_unsafe_math_optimizations
+    && (flag_fp_int_builtin_inexact || !flag_trapping_math))
    || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH
        && !flag_trapping_math && !flag_rounding_math)"
 {
--- gcc/testsuite/gcc.target/i386/pr84827.c.jj	2018-03-12 16:04:20.195411779 +0100
+++ gcc/testsuite/gcc.target/i386/pr84827.c	2018-03-12 15:54:58.041309098 +0100
@@ -0,0 +1,21 @@
+/* PR target/84827 */
+/* { dg-do compile } */
+/* { dg-options "-Ofast -fno-fp-int-builtin-inexact -ftrapping-math -fno-associative-math -mfpmath=387" } */
+
+double
+f1 (double a)
+{
+  return __builtin_round (a);
+}
+
+float
+f2 (float a)
+{
+  return __builtin_roundf (a);
+}
+
+long double
+f3 (long double a)
+{
+  return __builtin_roundl (a);
+}

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-13  8:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-13  8:35 [PATCH] Fix __builtin_round{,f,l} ICE on x86 (PR target/84827) Jakub Jelinek
2018-03-13  7:51 ` Uros Bizjak

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).