Mac Intel

David Hopwood david.nospam.hopwood@REDACTED
Mon Aug 14 18:51:25 CEST 2006


Joel Reymont wrote:
> The part that baffles me is this:
> 
> double a = 3.23e133;
> double b = 3.57e257;
> double res;
> 
> void do_fmul(void)
> {
>   res = a * b;
> }
> 
> Running the above results in the following output. Note that FPU 
> instruction pointer is 0. The SSE2 exception reported is overflow.
> 
> mxcsr & 0x000F = 8
> fpu ip = 0
> fpu cs = 0
> fpu opcode = 0
> 
> Now if a and b are set using atof("3.23e133") and atof("3.57e257")  then
> I get this:
> 
> mxcsr & 0x000F = 8
> fpu ip = 1ec1
> fpu cs = 27
> fpu opcode = 518
> 
> I can't figure this out. Of course it does not solve the issue of 
> advancing over SSE2 instructions either.

Just a guess: maybe in the first case, gcc is doing the multiplication
at compile-time, seeing that it causes an SSE2 exception, and generating
code that only causes the exception.

(Why is that a useful optimization? I don't know. Not doing constant
folding for expressions that cause an exception would be more sensible.)

If there are ways to generate an SSE2 exception that don't set the
ip, cs, and opcode fields, then these fields are inherently unreliable
for the purpose they're being used for here (to skip over whatever
caused the exception). This could be classed as a gcc bug, I suppose,
but that doesn't really help you. Sorry.

-- 
David Hopwood <david.nospam.hopwood@REDACTED>





More information about the erlang-questions mailing list