public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/29347]  New: i386 mode switching clobbers fp exception handling bits
@ 2006-10-04 15:29 amylaar at gcc dot gnu dot org
  2006-10-04 16:50 ` [Bug target/29347] " amylaar at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2006-10-04 15:29 UTC (permalink / raw)
  To: gcc-bugs

The mode switching for floating point rounding that the i386 backend does
does not actually place mode switches, but rather the calculation of values
used for mode switches.  Not only does that defeat the purpose of doing
lazy code motion of the mode switches themselves (this problem could easily
be remedied by handling the actual mode switches as a separate entity),
it also leads to information in the floating point control register being
clobbered if the user changes it (e.g. with feenableexcept:
http://www.gnu.org/software/libc/manual/html_node/Control-Functions.html)
between the calculation of the value used for a mode switch, and the point
where a mode switch actually takes place.


-- 
           Summary: i386 mode switching clobbers fp exception handling bits
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: amylaar at gcc dot gnu dot org
GCC target triplet: i386-*-*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29347


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

* [Bug target/29347] i386 mode switching clobbers fp exception handling bits
  2006-10-04 15:29 [Bug target/29347] New: i386 mode switching clobbers fp exception handling bits amylaar at gcc dot gnu dot org
@ 2006-10-04 16:50 ` amylaar at gcc dot gnu dot org
  2006-10-05  7:51 ` uros at kss-loka dot si
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2006-10-04 16:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from amylaar at gcc dot gnu dot org  2006-10-04 16:50 -------
One way to handle this problem would be to consider every function call
and asm as requiring another mode for the mode switching value entities;
no code would be emittied to actually 'set' this mode, but the mode switching
code would consider the mode switching value now to be in a different mode,
and thus insert new code to calculate the mode switching value when it is
needed again.  (Instead, MODE_AFTER could be used, if someone wanted to make
it work.)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29347


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

* [Bug target/29347] i386 mode switching clobbers fp exception handling bits
  2006-10-04 15:29 [Bug target/29347] New: i386 mode switching clobbers fp exception handling bits amylaar at gcc dot gnu dot org
  2006-10-04 16:50 ` [Bug target/29347] " amylaar at gcc dot gnu dot org
@ 2006-10-05  7:51 ` uros at kss-loka dot si
  2006-10-09 10:28 ` rguenth at gcc dot gnu dot org
  2006-10-23 12:10 ` amylaar at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: uros at kss-loka dot si @ 2006-10-05  7:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from uros at kss-loka dot si  2006-10-05 07:51 -------
(In reply to comment #0)
> The mode switching for floating point rounding that the i386 backend does
> does not actually place mode switches, but rather the calculation of values
> used for mode switches.  Not only does that defeat the purpose of doing
> lazy code motion of the mode switches themselves (this problem could easily
> be remedied by handling the actual mode switches as a separate entity),
> it also leads to information in the floating point control register being
> clobbered if the user changes it (e.g. with feenableexcept:
> http://www.gnu.org/software/libc/manual/html_node/Control-Functions.html)
> between the calculation of the value used for a mode switch, and the point
> where a mode switch actually takes place.
> 

Please note, that gcc i386 description is missing FP control register
definition, so x86_fnstcw_1 and x86_fldcw_1 patterns are totally wrong - they
handle control register, not status register. After that, we can add correct
clobber to x87 FP->int instructions.

Regarding mode-switching values calculation: please note that x87 arithmetic
instructions depend on control word. Currently, this is "solved" by setting and
restoring control word just before/after "fist" instruction, otherwise (use
(reg:HI FPCW_REG)) has to be added to all affected instructions. I think that
it has to be added anyway, if fesetround() is to be used.

Some time ago, I had a patch that added FPCW_REG to i386.h, I'll look if I can
still found it.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29347


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

* [Bug target/29347] i386 mode switching clobbers fp exception handling bits
  2006-10-04 15:29 [Bug target/29347] New: i386 mode switching clobbers fp exception handling bits amylaar at gcc dot gnu dot org
  2006-10-04 16:50 ` [Bug target/29347] " amylaar at gcc dot gnu dot org
  2006-10-05  7:51 ` uros at kss-loka dot si
@ 2006-10-09 10:28 ` rguenth at gcc dot gnu dot org
  2006-10-23 12:10 ` amylaar at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-10-09 10:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2006-10-09 10:28 -------
Can you provide a testcase where something goes wrong?


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29347


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

* [Bug target/29347] i386 mode switching clobbers fp exception handling bits
  2006-10-04 15:29 [Bug target/29347] New: i386 mode switching clobbers fp exception handling bits amylaar at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-10-09 10:28 ` rguenth at gcc dot gnu dot org
@ 2006-10-23 12:10 ` amylaar at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2006-10-23 12:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from amylaar at gcc dot gnu dot org  2006-10-23 12:10 -------
(In reply to comment #3)
> Can you provide a testcase where something goes wrong?
> 

I was merely documenting a problem that I found while reading the code;
I don't have time to write a testcase now.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29347


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

end of thread, other threads:[~2006-10-23 12:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-04 15:29 [Bug target/29347] New: i386 mode switching clobbers fp exception handling bits amylaar at gcc dot gnu dot org
2006-10-04 16:50 ` [Bug target/29347] " amylaar at gcc dot gnu dot org
2006-10-05  7:51 ` uros at kss-loka dot si
2006-10-09 10:28 ` rguenth at gcc dot gnu dot org
2006-10-23 12:10 ` amylaar at gcc dot gnu dot 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).