This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/29347] i386 mode switching clobbers fp exception handling bits



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]