# Set the FTZ and DAZ Flags

In Intel® processors, the flush-to-zero (`FTZ`) and denormals-are-zero (`DAZ`) flags in the MXCSR register are used to control floating-point calculations. Intel® Streaming SIMD Extensions (Intel® SSE) and Intel® Advanced Vector Extensions (Intel® AVX) instructions, including scalar and vector instructions, benefit from enabling the `FTZ` and `DAZ` flags. Floating-point computations using the Intel® SSE and Intel® AVX instructions are accelerated when the `FTZ` and `DAZ` flags are enabled. This improves the application's performance.

Use the [Q]ftz option to flush denormal results to zero when the application is in the gradual underflow mode. This option may improve performance if the denormal values are not critical to the application's behavior. The [Q]ftz option, when applied to the main program, sets the `FTZ` and the `DAZ` hardware flags. The negative forms of the [Q]ftz option (-no-ftz for Linux* and macOS*, and /Qftz- for Windows*) leave the flags as they are.

The following table describes how the compiler processes denormal values based on the status of the `FTZ` and `DAZ` flags:

Flag | When set to ON, the compiler... | When set to OFF, the compiler... | Supported on
--- | --- | --- | ---
`FTZ` | ...sets denormal results from floating-point calculations to zero. | ...does not change the denormal results. | Intel® 64 and some IA-32 architectures
`DAZ` | ...treats denormal values used as input to floating-point instructions as zero. | ...does not change the denormal instruction inputs. | Intel® 64 and some IA-32 architectures

- `FTZ` and `DAZ` are not supported on all IA-32 architectures. The `FTZ` flag is supported only on IA-32 architectures that support Intel® SSE instructions.
- On systems based on the IA-32 and Intel® 64 architectures, `FTZ` only applies to Intel® SSE and Intel® AVX instructions. If the application generates denormals using x87 instructions, `FTZ` does not apply.

- `DAZ` and `FTZ` flags are not compatible with the IEEE 754 standard, and should only be enabled when compliance to the IEEE standard is not required.

Options for [Q]ftz are performance options. Setting these options does not guarantee that all denormals in a program are flushed to zero. They only cause denormals generated at run-time to be flushed to zero.

On Intel® 64 and IA-32 systems, the compiler, by default, inserts code into the main routine to set the `FTZ` and `DAZ` flags. When the [Q]ftz option is used on IA-32 systems with the option –msse2 or /arch:sse2, the compiler inserts code to that conditionally sets the `FTZ`/`DAZ` flags based on a run-time processor check. Using the negative form of [Q]ftz prevents the compiler from inserting any code that sets `FTZ` or `DAZ` flags.

When the [Q]ftz option is used in combination with an Intel® SSE-enabling option on systems based on the IA-32 architecture (for example, -msse2 or /arch:sse2), the compiler inserts code in the main routine to set `FTZ` and `DAZ`. When the option [Q]ftz is used without an Intel® SSE-enabling option, the compiler inserts code that conditionally sets `FTZ` or `DAZ` based on a run-time processor check. The negative form of [Q]ftz prevents the compiler from inserting any code that might set `FTZ` or `DAZ`.

The [Q]ftz option only has an effect when the main program is being compiled. It sets the `FTZ`/`DAZ` mode for the process. The initial thread, and any subsequently created threads, operate in the `FTZ`/`DAZ` mode.

On systems based on Intel® 64 and IA-32 architectures, every optimization option O level, except O0, sets [Q]ftz.

If this option produces undesirable results of the numerical behavior of the program, turn the `FTZ`/`DAZ` mode off by using the negative form of [Q]ftz in the command line while still benefitting from the O3 optimizations.

Manually set the `FTZ` flags with the following macros:

`_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON)`

Manually set the `DAZ` flags with the following macros:

`_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON)`

The prototypes for these macros are in xmmintrin.h (`FTZ`) and pmmintrin.h (`DAZ`).

Parent topic: Floating-Point Operations

## See Also

ftz, Qftz compiler option