Search

A technology, a device or an article

Zero by policy: how FTZ and DAZ change CPU arithmetic

FTZ changes underflow handling; DAZ changes subnormal inputs. Their usefulness begins with the numerical behavior the application permits.

A thin black line breaks into marks beside several thick lines on pale paper
ITNWS AI-generated conceptual illustration. The fading line evokes the loss of tiny values; it is not a plot or CPU test result.ITNWS · image_gen · Original ITNWS AI-generated conceptual editorial illustration

"It’s such a small number that it could be considered zero." For an applied problem, such a solution is sometimes excellent. For the processor it needs an exact rule. Smallness in itself does not yet indicate whether it is possible to destroy a sign, stop fading, change branching, or lose the difference between neighboring results. Therefore, the FTZ and DAZ modes are interesting primarily as a choice of numerical semantics. The promise of speeding up a nasty rare case comes after deciding which values the program is allowed to stop discriminating. Reversing that order lets an optimization silently change the problem.

We are talking about subnormal numbers, which in old documentation are often called denormal. The floating-point format allocates a portion of the representation to values smaller than the minimum normal number. They are non-zero. Their existence makes it possible to approach zero gradually, with a decreasing number of significant digits, instead of immediately breaking off at the lower limit of the normal range. Supporting this behavior does not create infinite precision: the smallest positive representable number still exists. It changes the nature of the transition to this limit, maintaining an additional area of distinguishable results.

Binary32 has a minimum positive normal value of 2^-126 and a minimum positive subnormal value of 2^-149. These expressions describe the format; they are not measurements made by the editorial team. Between them there is a set of non-zero representations with a fixed small step. This range cannot be treated simply as a continuation of the same relative precision: as it approaches zero, there are fewer significant bits. However, the absolute difference between neighboring quantities continues to matter. If the algorithm relies on it, the convenient word "garbage" does not prove that deletion is permissible.

In regular SSE and AVX arithmetic, the corresponding rules are associated with the MXCSR register. FTZ, flush to zero, refers to the output of the result under underflow conditions; DAZ, denormals are zero, changes the handling of subnormal input operands of the corresponding instructions. The exact architectural behavior, including exception masks, is described in Intel SDM Volume 1, Historical December 2024 Revision. These long-standing mechanisms were checked against primary sources on October 31, 2026. Today’s document review does not mean the appearance of a new CPU property.

Input and output argue about different things

FTZ is not a universal pass through RAM with small number replacement. If the array already contains subnormal values, enabling the mode does not itself overwrite its bytes. It affects the calculation specified by the instruction. You can copy the saved representation as data and get the same bits. Therefore, the statement “there is no longer denormal in the program” is much stronger than setting a control flag. The values could come from a file, a network, a constant, or another function that was executed under different conditions.

DAZ is needed precisely for the other side of the contract: the corresponding arithmetic operand is interpreted as zero with the sign preserved. Here the value at the input of the operation changes, and not just the fate of the too small result. This is noticeable even in the hypothetical multiplication. A positive subnormal value, multiplied by a sufficiently large factor, with gradual underflow, can give a normal result. If you first treat the original value as zero, there is nothing to restore. The size of the expected response does not allow the input tail to be automatically declared unimportant.

FTZ has its own scope. In the architectural description, mode refers to the response to underflow under appropriate masking conditions; it cannot be unconditionally paraphrased as “any mathematically subnormal value is always reset to zero by all instructions.” Special conversion instructions and other sets of instructions may have their own rules. For a specific sequence, you need to read the description of the selected operation. The difference is important for reproducibility: the generic name of a mode does not change the conditions under which the architecture specifies its use. A set control bit is not proof that all formats behave the same.

MXCSR should also not be extended to older x87 arithmetic. It has a different organization of the state and its own management. A program with a similar source expression may end up with a different machine path depending on the architecture, compilation options, and library chosen. For the user, both results are called “computed on x86”, but this is too broad a description of the experiment. The actual instructions, the format of the intermediate values, and the state of the environment at the time of operation are significant. Without them, the dispute over the same processor leaves the arithmetic unsettled.

Amber glass beads of different sizes at the mouth of a clear vessel
ITNWS AI-generated conceptual illustration. Beads at the vessel’s threshold evoke changed input arithmetic, not a literal DAZ schematic. — ITNWS · image_gen · Original ITNWS AI-generated conceptual editorial illustration

Intel’s FTZ and DAZ Guide, dated October 31, 2024, explains how these modes relate to compiler tuning. This is a description of a specific toolkit, and not a permission to assign the same defaults to any GCC or Clang build. A main-program compiler option, startup code, and an explicitly modified environment can influence the state that the library receives. Therefore, the name of one source file or the list of flags only for it does not yet describe the resulting executable process as a whole.

For a fading signal, the mode can look reasonable. Let the internal state of the filter continue to decrease after the useful sound ends. An application contract may allow a very weak tail to be replaced with a zero to avoid wasting work on values beyond the required precision. This is a hypothetical motivation, not an audio test result. The decision must be based on the error limit of this particular algorithm. The fact that a person does not hear an individual tail does not imply the universal harmlessness of any change in the intermediate state throughout the entire application.

In an iterative calculation, the same break can change the stopping point. If the termination check uses the difference between zero and a small non-zero value, the new policy changes the flow of control. This is not necessarily an error: the author has the right to define such semantics. But it is no longer possible to compare the speed of two options as computing a completely identical task without checking the acceptability of the results. The same final number on a convenient set of inputs does not prove the preservation of all promises. Rare branches, exception indications, and further processing of the response can differ.

The argument from a small absolute error without the scale of the problem is especially unsuccessful. With subsequent division by a small value or normalization, the relative impact of the dropped value may increase. A correct assessment links the deletion boundary to further operations. It does not require that subnormal numbers be considered sacred, but it does require knowing where a quantity ceases to have practical meaning. If no one has formulated such a boundary, the hardware mode takes upon itself a solution that the problem model has not yet accepted. Speed of execution does not replace missing proof.

Who has the right to change the arithmetic environment

In library code, the issue becomes contractual. The caller may expect one environment and the function may temporarily prefer another. If a function modifies the MXCSR and returns leaving the modified state, subsequent independent computations receive the new mode without explicit consent. If the entire register value is saved and restored, another question arises: what to do with the exception status flags accumulated inside. Control bits and evidence of completed arithmetic are adjacent in the same state. A correct wrapper should understand both meanings, and not just remember a convenient integer.

The executing thread matters too. MXCSR is part of the saved thread state; making a change to one running thread is not a reliable way to simultaneously reconfigure all of the application’s existing worker threads. Thread creation rules and environment conventions require special attention. Setting a mode at the beginning of one function does not prove that every worker has been computing with it since launch. For discussing reproducibility, it is more helpful to identify where the mode was set and which threads use it than to use the vague expression “computer mode.”

The compiler participates in the same contract. It can transform an expression in advance, fold constants, or select operations that are allowed additional assumptions. GCC optimization documentation shows that fast-math involves a set of relaxations, rather than one magical denormal hardware switch. Therefore, disabling FTZ after a build does not undo transformations already applied. Conversely, strict source formulas do not themselves guarantee that an external library will not change the environment. Static assumptions and runtime state need to be reconciled.

The LLVM Language Reference also describes the environment for working with subnormal values explicitly. This is a useful reminder: it is not enough for the optimizer to know just the float type. The assumptions allowed about the operands and results determine which transformations preserve the meaning of the program. If the machine environment diverges from the stated intermediate representation model, reasoning from one visible source expression becomes unreliable. The actual build must be inspected; the same multiplication sign in source code does not guarantee the same arithmetic environment.

Changing the mode has a cost that cannot be stated in advance to be the same for all processors and contexts. There is also a cost for processing subnormal operands, depending on the microarchitecture, the specific instruction, and the data. The historical reference to the slow path does not necessarily mean that a modern application will speed up. This article reports no measured cycle counts, speedups or model rankings. Such a conclusion would require comparing the same useful work, checking the results, and separating the change in the algorithm from the change in the cost of the machine operation. A convenient micro-example can establish the possibility, but not the prevalence, of an effect.

Even the choice of test data needs explanation. If there are no values at all in the input that affect the selected policy, a quick run tells you little about it. If the entire array is artificially filled with subnormal numbers, it examines the edge case without showing its contribution to the real load. Both experiments are acceptable if the question is formulated correctly. It is unacceptable to quietly transfer an answer from one to another. Application benefits arise where the modified behavior actually occurs and where the new numerical semantics remain permitted.

The difference between zeros should also not be lost in the retelling. The sign of zero may affect some further operations and observations of the environment. Architectural preservation of the sign with corresponding zeroing does not mean preservation of the original non-zero value. These properties are compatible: the code retains the sign but loses the magnitude. When assessing correctness, it is important to ask which ones the algorithm uses. The phrase “everything has become zero” is convenient for the title and insufficient for the interface of a function that promises certain behavior at the boundaries of the range.

The move to a wider format changes the location of the border, rather than abolishing the issue itself. A value that is subnormal for binary32 may be normal in another representation; subsequent narrowing will again create its own edge. So the promise to "just use double" requires an assessment of intermediate formats, conversions, and storage costs. Sometimes this is a reasonable choice for accuracy. Sometimes a task deliberately works with narrower data. No type name frees the author from defining acceptable error and how to handle small values.

On a CPU, FTZ and DAZ determine what happens to tiny values in the operations they cover. Assessing their usefulness begins with the promised result. You can deliberately choose to interrupt a weak signal, you can require a gradual underflow, you can select a section with separate rules. In all cases, the selection must have a named owner. A small non-zero number becomes unnecessary due to the requirements of the problem. The processor only executes the policy that the program should have formulated before calling it acceleration.

Sources & documentation

  1. Intel Set the FTZ and DAZ Flags, 2025.0 guide, historical31October2024 ↗
  2. Intel SDM Volume1, historicalDecember2024 ↗
  3. GCC Optimize Options ↗
  4. LLVM floating point environment ↗