[all-commits] [llvm/llvm-project] 84a9ec: Remove redundant option -menable-unsafe-fp-math.

Zahira Ammarguellat via All-commits all-commits at lists.llvm.org
Fri Oct 14 07:55:49 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 84a9ec2ff1ee97fd7e8ed988f5e7b197aab84a7b
      https://github.com/llvm/llvm-project/commit/84a9ec2ff1ee97fd7e8ed988f5e7b197aab84a7b
  Author: Zahira Ammarguellat <zahira.ammarguellat at intel.com>
  Date:   2022-10-14 (Fri, 14 Oct 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Driver/Options.td
    M clang/lib/CodeGen/CGCall.cpp
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/test/CodeGen/fp-options-to-fast-math-flags.c
    A clang/test/CodeGen/func-attr.c
    M clang/test/CodeGen/libcalls.c
    M clang/test/CodeGenCUDA/propagate-metadata.cu
    M clang/test/Driver/cl-options.c
    M clang/test/Driver/fast-math.c
    M clang/test/Driver/fp-model.c
    M clang/test/Parser/fp-floatcontrol-syntax.cpp
    M clang/unittests/Frontend/CompilerInvocationTest.cpp

  Log Message:
  -----------
  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




More information about the All-commits mailing list