Remove redundant option -menable-unsafe-fp-math.
authorZahira Ammarguellat <zahira.ammarguellat@intel.com>
Mon, 3 Oct 2022 19:15:48 +0000 (15:15 -0400)
committerZahira Ammarguellat <zahira.ammarguellat@intel.com>
Fri, 14 Oct 2022 14:55:29 +0000 (10:55 -0400)
commit84a9ec2ff1ee97fd7e8ed988f5e7b197aab84a7b
tree90565e2220c889f5dcf340fc148a59627a8723f7
parent6ce87272487711c9f0ff408a037f5ca2e1ff5c5d
Remove redundant option -menable-unsafe-fp-math.

There are currently two options that are used to tell the compiler to perform
unsafe floating-point optimizations:
'-ffast-math' and '-funsafe-math-optimizations'.

'-ffast-math' is enabled by default. It automatically enables the driver option
'-menable-unsafe-fp-math'.
Below is a table illustrating the special operations enabled automatically by
'-ffast-math', '-funsafe-math-optimizations' and '-menable-unsafe-fp-math'
respectively.

Special Operations -ffast-math -funsafe-math-optimizations -menable-unsafe-fp-math
MathErrno        0          1                     1
FiniteMathOnly         1           0                          0
AllowFPReassoc        1           1                          1
NoSignedZero        1                 1                          1
AllowRecip             1                 1                          1
ApproxFunc             1                 1                          1
RoundingMath        0                 0                          0
UnsafeFPMath        1                 0                          1
FPContract        fast          on                     on

'-ffast-math' enables '-fno-math-errno', '-ffinite-math-only',
'-funsafe-math-optimzations' and sets 'FpContract' to 'fast'. The driver option
'-menable-unsafe-fp-math' enables the same special options than
'-funsafe-math-optimizations'. This is redundant.
We propose to remove the driver option '-menable-unsafe-fp-math' and use
instead, the setting of the special operations to set the function attribute
'unsafe-fp-math'. This attribute will be enabled only if those special
operations are enabled and if 'FPContract' is either 'fast' or set to the
default value.

Differential Revision: https://reviews.llvm.org/D135097
13 files changed:
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGCall.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/fp-options-to-fast-math-flags.c
clang/test/CodeGen/func-attr.c [new file with mode: 0644]
clang/test/CodeGen/libcalls.c
clang/test/CodeGenCUDA/propagate-metadata.cu
clang/test/Driver/cl-options.c
clang/test/Driver/fast-math.c
clang/test/Driver/fp-model.c
clang/test/Parser/fp-floatcontrol-syntax.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp