Exception synchronization on x86

James R Reinders uunet!ccm.jf.intel.com!James_R_Reinders
Thu May 9 23:48:00 PDT 1996


If you don't care about anything before i486 processors, then
your compiler need not worry about FWAIT instructions (in practice).

The reason is that once the math coprocessor (Intel 8087, 80287,
80387) was brought onto the same die as the main processor
(i486, i487, Pentium, Pentium Pro) the FWAIT instruction became
important only for context switch code (in the OS).  The instruction
was an explicit syncronization necessary in the coprocessor (seperate
chip) configurations in order to not hardwire the processor to
assume certain latencies in the math coprocessor.  There are some
good reasons for this, but this became an unneeded annoyance
starting with the i486.

Compilers which produce code which may run on pre-i486 parts
do need to produce FWAIT instructions.  But this will slow
down your FP code because it takes up instruction
code space (thereby causing I-cache misses and consuming extra
decode and execute bandwidth),  Other than the slow down, the
code will still produce the correct answers with FWAIT instructions
included.

Thus, in practice, you don't want to produce FWAIT instructions
from a compiler.

The Intel Reference Compiler (to my knowledge the best compiler for
producing FP code for i486, Pentium and Pentium Pro processors)
never generates FWAIT instructions.  This compiler, like many
on the market, specifically no longer targets pre-i486 processors.

If you are putting together a high performance FP compiler,
you'll not want to issue FWAITs... in practice your customers won't be
using pre-i486 parts anyways.

I hope this addressed your question.  If not, let me know.

- james

P.S.  The manual is correct in that compilers for Intel machines
do the FWAIT scheduling automatically.  Based on your question,
I think the manual could be a little clearer on this point...
and I'll let the right people know and I'll see if I can help
add come clarifications there.  I've glossed over the exception
issue - the manual is correct in that FWAIT will improve the
ability to isolate the faulting instruction - but in practice
that is not important, nor does it highlight the primary reason
FWAIT existed for pre-i486 processors.  IMHO


James R. Reinders
Staff Engineer
Intel Microcomputer Software Labs
Compiler & Debugger Lab

______________________________ Reply Separator _________________________________
Subject: Exception synchronization on x86
Author:  validgh!validgh.com!majorauunet.uu.net at SMTPGATE
Date:    5/9/96 9:46 AM


Sections 6.4.1.6-6.4.1.8 of the Pentium Processor User's Manual, Vol- 
ume 3, briefly describe the need for a compiler to issue floating point 
instructions in the correct sequence relative to other instructions and 
to insert fwait instructions as need be to ensure that floating point 
exceptions are properly synchronized (i.e., recoverable).  They also 
state that the Intel compilers perform correct synchronization.

I would be grateful if someone can refer me to a description of the 
algorithm Intel's compilers use to determine the correct sequencing 
of floating point and non-floating point instructions and the loca- 
tions at which fwait instructions must be issued.

Douglas M. Priest
SunSoft Floating Point Group
Sun Microsystems, Inc.
(but only speaking for myself)


<PRE>


More information about the Numeric-interest mailing list