Currently the control of the eval-method is mixed with fast-math.
authorZahira Ammarguellat <zahira.ammarguellat@intel.com>
Mon, 7 Mar 2022 15:28:45 +0000 (07:28 -0800)
committerZahira Ammarguellat <zahira.ammarguellat@intel.com>
Thu, 17 Mar 2022 18:48:03 +0000 (11:48 -0700)
commitbbf0d1932a3c1be970ed8a580e51edf571b80fd5
tree234d00e03cad005c9dd49538f5bf23b33ee36062
parent27e1931508115f9a2a942845a2df0ee11be3332a
Currently the control of the eval-method is mixed with fast-math.
FLT_EVAL_METHOD tells the user the precision at which, temporary results
are evaluated but when fast-math is enabled, the numeric values are not
guaranteed to match the source semantics, so the eval-method is
meaningless.
For example, the expression `x + y + z` has as source semantics `(x + y)
+ z`. FLT_EVAL_METHOD is telling the user at which precision `(x + y)`
is evaluated. With fast-math enable the compiler can choose to
evaluate the expression as `(y + z) + x`.
The correct behavior is to set the FLT_EVAL_METHOD to `-1` to tell the
user that the precision of the intermediate values is unknow. This
patch is doing that.

Differential Revision: https://reviews.llvm.org/D121122
clang/include/clang/Lex/Preprocessor.h
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaAttr.cpp
clang/test/CodeGen/eval-method-fast-math.cpp [new file with mode: 0644]