On Linux, about FPU, exception signals are masked by default, but I can enable exception signal by setting control word in fpu, such as:
------------------------------
#include
#include
unsigned short fpucw;
unsigned short fpucw_save;
float f;
main(){
__asm__("
fstcw %0;"
:"=m"(fpucw)
);
printf("fpu control word = %04x ", fpucw);
fpucw_save = fpucw;
fpucw &= 0xfff0; // unmask exception control flags.
printf("new fpu control word = %04x ", fpucw);
__asm__("
fldcw %0;"
:
: "m"(fpucw)
);
printf("input f ");
scanf("%f", &f);
printf("sqrt(f) = %f ", sqrt(f));
fpucw_save = 0x037f;
}
----------
If this code is compiled w/o any of -xK/-xW/ or any others, and if f < 0, then sqrt(f) will send exception signal and this program aborts because it uses x87 fpu instead of SSE/SSE2. however it is compiled with -xK -xW..etc. to utilize sse/sse2, it doesn't send exceptional signal. So how can I unmask those equivalent flags for simd instructions?


