HP-UX Floating-Point Guide

80 Chapter 3
Factors that Affect the Results of Floating-Point Computations
Other System-Related Factors that Affect Application Results
For example, by default the compiler orders the expression
a+b*c+d
as
(a+(b*c))+d
But if you use +Onofltacc, it may change the ordering to
a+d+(b*c)
As we showed in “How Basic Operations Affect Application Results” on
page 71, this kind of reordering has an effect on rounding errors and
consequently on the final result.
The +Ovectorize option may also reorder operations on arrays and
thus cause differences in results. See “Optimizing Your Program” on
page 171 for details.
NOTE Optimization affects the ordering of operations around calls to the
fenv(5) suite of functions. See “Run-Time Mode Control: The fenv(5)
Suite” on page 127.
Architecture Type of Run-Time System
PA2.0 systems use two instructions known collectively as FMA (fused
multiply-add) instructions. These instructions, FMPYFADD and
FMPYNFADD, combine a multiplication and an addition (or subtraction)
into a single operation. Use the +DA2.0 compiler option (the default on
PA2.0 systems) or the +DA2.0W option to generate code that uses these
instructions.
For example, in the statement
d = a * c + b
the multiplication of a and c, and the addition of the product to b, may
all be accomplished by a single FMPYFADD instruction. When the
instruction is executed, the product of a and c is computed to infinite
precision and added to b. The result is then rounded according to the
current rounding mode.
This means, for example, that a code sequence that might be expected to
incur two rounding errors may instead incur only one. Therefore, the use
of FMA instructions may change the results of your application.