diff options
author | Zahira Ammarguellat <zahira.ammarguellat@intel.com> | 2022-10-03 15:15:48 -0400 |
---|---|---|
committer | Zahira Ammarguellat <zahira.ammarguellat@intel.com> | 2022-10-14 10:55:29 -0400 |
commit | 84a9ec2ff1ee97fd7e8ed988f5e7b197aab84a7b (patch) | |
tree | 90565e2220c889f5dcf340fc148a59627a8723f7 /clang/lib/CodeGen/CGCall.cpp | |
parent | 6ce87272487711c9f0ff408a037f5ca2e1ff5c5d (diff) | |
download | llvm-84a9ec2ff1ee97fd7e8ed988f5e7b197aab84a7b.zip llvm-84a9ec2ff1ee97fd7e8ed988f5e7b197aab84a7b.tar.gz llvm-84a9ec2ff1ee97fd7e8ed988f5e7b197aab84a7b.tar.bz2 |
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
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 1df9c6b..146271f 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1862,7 +1862,11 @@ void CodeGenModule::getDefaultFunctionAttributes(StringRef Name, FuncAttrs.addAttribute("no-nans-fp-math", "true"); if (LangOpts.ApproxFunc) FuncAttrs.addAttribute("approx-func-fp-math", "true"); - if (LangOpts.UnsafeFPMath) + if ((LangOpts.FastMath || + !LangOpts.FastMath && LangOpts.AllowFPReassoc && LangOpts.AllowRecip && + !LangOpts.FiniteMathOnly && LangOpts.NoSignedZero && + LangOpts.ApproxFunc) && + LangOpts.getDefaultFPContractMode() != LangOptions::FPModeKind::FPM_Off) FuncAttrs.addAttribute("unsafe-fp-math", "true"); if (CodeGenOpts.SoftFloat) FuncAttrs.addAttribute("use-soft-float", "true"); |