FPU Exceptions

FPU Exceptions


I want floating-point exceptions to raise if operation result was not-a-number or infinity. To make this happen I use 'fldcw' instruction with '0x360' argument and it works fine on FPU-unit instructions.

Would exceptions raise if compiler has generated SSE-unit instructions to perform floating point operations (instead of FPU-unit instructions)?

Kirill Prazdnikov

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

SSE/SSE2 opcodes use another control word than the legacy x87 CW for exceptions, rounding mode and such. Provided that there isn't a higher level call that set both x87 + SSE CW consistently (I'm not sure if such a call is available) you will have to set both CW independently. For the SSE/SSE2 code, have a look at the "_mm_setcsr" and "_mm_getcsr" intrinsics.

The code snippet below should do more or less what you want, clear all exceptions flags and mask all exceptions but INVALID and OVERFLOW. Have a look at the doc. to be real sure...


void Func()

// your code...

Leave a Comment

Please sign in to add a comment. Not a member? Join today