public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/102783] New: [powerpc] FPSCR manipulations cannot be relied upon
@ 2021-10-15 16:15 pc at us dot ibm.com
  2021-10-15 16:37 ` [Bug target/102783] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: pc at us dot ibm.com @ 2021-10-15 16:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102783

            Bug ID: 102783
           Summary: [powerpc] FPSCR manipulations cannot be relied upon
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pc at us dot ibm.com
  Target Milestone: ---

On all Power targets which support hardware floating-point, there are a few
manipulations of the Floating-Point Status and Control Register (FPSCR) that
have side-effects for subsequent floating-point computation. For example,
changing the floating-point rounding mode, or changing whether floating-point
exceptions are enabled.

There are many ways to effect those manipulations:
- The set of fenv(1) calls
- A handful of builtins:
  __builtin_fpscr_set_rn
  __builtin_mtfsf
  __builtin_mtfsb{0,1}
- Inline asm using the appropriate instructions (mffsce, mffscdrn{i},
mffscrn{i}, mtfsf{i}, mtfsb{0,1})

The problem is that if any of the above methods are not effected in an
out-of-line function, there is no way at present to restrict instruction
scheduling such that nearby floating-point computations are prevented from
moving before or after the FPSCR changes. (Possibly resulting in computation
using a wrong rounding mode, or unexpected FP exceptions.)

With asm statements, one could add artificial read and write dependencies to
the  input or output (if any) of the FPSCR manipulations and
previous/subsequent FP computations, but this is not always practicable.
(Current glibc is an example.)

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

end of thread, other threads:[~2023-01-07 21:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15 16:15 [Bug target/102783] New: [powerpc] FPSCR manipulations cannot be relied upon pc at us dot ibm.com
2021-10-15 16:37 ` [Bug target/102783] " pinskia at gcc dot gnu.org
2021-10-15 19:27 ` pthaugen at gcc dot gnu.org
2021-10-15 19:31 ` segher at gcc dot gnu.org
2021-10-15 19:53 ` pinskia at gcc dot gnu.org
2021-10-18  6:27 ` rguenth at gcc dot gnu.org
2021-10-18 21:52 ` joseph at codesourcery dot com
2021-10-19 10:28 ` segher at gcc dot gnu.org
2021-10-19 10:41 ` segher at gcc dot gnu.org
2021-10-19 15:30 ` joseph at codesourcery dot com
2021-10-28 14:07 ` rguenth at gcc dot gnu.org
2022-08-26 12:11 ` glisse at gcc dot gnu.org
2023-01-07 21:14 ` glisse at gcc dot gnu.org

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