[Bug libfortran/78314] New: [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

classic Classic list List threaded Threaded
36 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] New: [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

            Bug ID: 78314
           Summary: [aarch64] ieee_support_halting does not report
                    unsupported fpu traps correctly
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nsz at gcc dot gnu.org
  Target Milestone: ---

on aarch64 trapping fpu exceptions are optional, but
ieee_support_halting(except_flag) does not report this
correctly, so fortran tests that depend on trap bit
changes would fail:

Program aborted. Backtrace:
#0  0x20000472D3
FAIL: gfortran.dg/ieee/ieee_6.f90   -Os  execution test
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
No wonder that one fails on thunderx.
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

Richard Earnshaw <rearnsha at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-11-11
     Ever confirmed|0                           |1

--- Comment #2 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
current code has

int
support_fpu_trap (int flag)
{
  return support_fpu_flag (flag);
}


In other words, it assumes that if there is a flag for noting that an exception
has occurred, then it is also possible to trap on that flag being changed.
That's not a valid assumption for AArch64.
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

--- Comment #3 from nsz at gcc dot gnu.org ---
Author: nsz
Date: Wed Nov 16 17:27:04 2016
New Revision: 242505

URL: https://gcc.gnu.org/viewcvs?rev=242505&root=gcc&view=rev
Log:
[PR libgfortran/78314] Fix ieee_support_halting

ieee_support_halting only checked the availability of status
flags, not trapping support.  On some targets the later can
only be checked at runtime: feenableexcept reports if
enabling traps failed.

So check trapping support by enabling/disabling it.

Updated the test that enabled trapping to check if it is
supported.

gcc/testsuite/

        PR libgfortran/78314
        * gfortran.dg/ieee/ieee_6.f90: Use ieee_support_halting.

libgfortran/

        PR libgfortran/78314
        * config/fpu-glibc.h (support_fpu_trap): Use feenableexcept.


Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/ieee/ieee_6.f90
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/config/fpu-glibc.h
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

nsz at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |7.0
      Known to fail|                            |5.4.0, 6.2.0
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Any plan to back-port the fix? If no, could you please close the PR?
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

--- Comment #5 from nsz at gcc dot gnu.org ---
i plan to backport the fix, but it seems my fix is not correct and broke the
ieee_8.fp90 test.
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

nsz at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

--- Comment #6 from nsz at gcc dot gnu.org ---
waiting with the backport for bug 78449.
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|7.0                         |7.2

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 7.1 has been released.
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|7.2                         |7.3

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 7.2 is being released, adjusting target milestone.

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 7.2 is being released, adjusting target milestone.
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|7.2                         |7.3

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 7.2 is being released, adjusting target milestone.

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 7.2 is being released, adjusting target milestone.
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|7.2                         |7.3
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|7.3                         |7.4

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 7.3 is being released, adjusting target milestone.
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #9 from Martin Liška <marxin at gcc dot gnu.org> ---
nsz: Can the bug be marked as resolved?
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

--- Comment #10 from nsz at gcc dot gnu.org ---
it turns out the ieee_* functions are allowed in const expressions so they need
to work at compile time too (see bug 78449), which of course won't work if they
need runtime detection.

so now compile-time and runtime behaviour of ieee_support_halting is different.

so far no fortran expert clarified what is the expected semantics when you can
only decide this at runtime (e.g. it might be better to always return false on
targets that may not implement trapping, rather than report things
inconsistently compile- vs runtime).

(i think this bug can be closed, but then the other one has to be reopened).
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

--- Comment #11 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
(In reply to nsz from comment #10)

> it turns out the ieee_* functions are allowed in const expressions so they
> need to work at compile time too (see bug 78449), which of course won't work
> if they need runtime detection.
>
> so now compile-time and runtime behaviour of ieee_support_halting is
> different.
>
> so far no fortran expert clarified what is the expected semantics when you
> can only decide this at runtime (e.g. it might be better to always return
> false on targets that may not implement trapping, rather than report things
> inconsistently compile- vs runtime).
>
> (i think this bug can be closed, but then the other one has to be reopened).

Well the 'safe' answer in this case, when you can't be sure whether or not
run-time traps will occur is surely to say 'no, they can't'.  You might then
get redundant code in the app that can't be reached, but at least it will still
execute correctly.
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|7.4                         |7.5
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

--- Comment #12 from nsz at gcc dot gnu.org ---
this got reverted because of bug 88678

and because compile time and runtime support_halting are different.

the compile time value is unconditionally true, which is wrong for
aarch64 and arm:

gcc/fortran/simplify.c:
gfc_expr *
simplify_ieee_support (gfc_expr *expr)
{
  /* We consider that if the IEEE modules are loaded, we have full support
     for flags, halting and rounding, which are the three functions
     (IEEE_SUPPORT_{FLAG,HALTING,ROUNDING}) allowed in constant
     expressions. One day, we will need libgfortran to detect support and
     communicate it back to us, allowing for partial support.  */

  return gfc_get_logical_expr (gfc_default_logical_kind, &expr->where,
                               true);
}

i don't know how to change this to false for IEEE_SUPPORT_HALTING
on aarch64 and arm targets, but that would be a possible fix.
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

--- Comment #13 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to nsz from comment #12)
> i don't know how to change this to false for IEEE_SUPPORT_HALTING
> on aarch64 and arm targets, but that would be a possible fix.

--cut here--
Index: libgfortran/config/fpu-glibc.h
===================================================================
--- libgfortran/config/fpu-glibc.h      (revision 268424)
+++ libgfortran/config/fpu-glibc.h      (working copy)
@@ -129,6 +129,10 @@
 int
 support_fpu_trap (int flag)
 {
+#if defined(__arm__) || defined(__aarch64__)
+  return 0;
+#endif
+
   return support_fpu_flag (flag);
 }

--cut here--
Reply | Threaded
Open this post in threaded view
|

[Bug libfortran/78314] [aarch64] ieee_support_halting does not report unsupported fpu traps correctly

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78314

--- Comment #14 from nsz at gcc dot gnu.org ---
(In reply to Uroš Bizjak from comment #13)
> (In reply to nsz from comment #12)
> > i don't know how to change this to false for IEEE_SUPPORT_HALTING
> > on aarch64 and arm targets, but that would be a possible fix.
>
> --cut here--
> Index: libgfortran/config/fpu-glibc.h

that only turns the runtime check into "always false"

but the compile time check is still "always true".

which is still broken.
12