On Mon, Mar 12, 2018 at 10:14 PM, Jakub Jelinek <ja...@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  <ja...@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

Reply via email to