This code sample demonstrates how to use compiler macros to read the FTZ and DAZ flags in the MXCSR control register.
-ftz, /Qftz compiler option-ftz, /Qftz compiler option
/*
* [Description]
* This code sample demonstrates how to use the
* _MM_GET_FLUSH_ZERO_MODE() and _MM_GET_DENORMALS_ZERO_MODE()
* macros to read the FTZ and DAZ flags in the control register.
*
* [Compile]
* icc ftz_daz.c (linux) | icl ftz_daz.c (windows)
*
* Turning off optimization changes the state of the registers
* icc -O0 ftz_daz.c (linux) | icl /Od ftz_daz.c (windows)
*
* [Output]
* Shows the state of the FTZ and DAZ registers.
*/
#include <stdio.h>
#include <xmmintrin.h>
#include <pmmintrin.h>
int main(void){
/* Test the control register for flush to zero mode */
if ( _MM_GET_FLUSH_ZERO_MODE() )
printf("FTZ is set.\n");
else
printf("FTZ is not set.\n");
/* Test the control register for denormals mode */
if ( _MM_GET_DENORMALS_ZERO_MODE() )
printf("DAZ is set.\n");
else
printf("DAZ is not set.\n");
return (0);
}