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/unittests/Frontend/CompilerInvocationTest.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/unittests/Frontend/CompilerInvocationTest.cpp')
-rw-r--r-- | clang/unittests/Frontend/CompilerInvocationTest.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp index d4c6981..06faec4 100644 --- a/clang/unittests/Frontend/CompilerInvocationTest.cpp +++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp @@ -705,7 +705,7 @@ TEST_F(CommandLineTest, WideIntegerHighValue) { // // * -cl-unsafe-math-optimizations // * -cl-mad-enable -// * -menable-unsafe-fp-math +// * -funsafe-math-optimizations // * -freciprocal-math TEST_F(CommandLineTest, ImpliedBoolOptionsNoFlagPresent) { @@ -723,7 +723,8 @@ TEST_F(CommandLineTest, ImpliedBoolOptionsNoFlagPresent) { ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-cl-unsafe-math-optimizations")))); ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-cl-mad-enable")))); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-menable-unsafe-fp-math")))); + ASSERT_THAT(GeneratedArgs, + Not(Contains(StrEq("-funsafe-math-optimizations")))); ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-freciprocal-math")))); } @@ -745,13 +746,14 @@ TEST_F(CommandLineTest, ImpliedBoolOptionsRootFlagPresent) { ASSERT_THAT(GeneratedArgs, Contains(StrEq("-cl-unsafe-math-optimizations"))); // Not generated - implied by the generated root flag. ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-cl-mad-enable")))); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-menable-unsafe-fp-math")))); + ASSERT_THAT(GeneratedArgs, + Not(Contains(StrEq("-funsafe-math-optimizations")))); ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-freciprocal-math")))); } TEST_F(CommandLineTest, ImpliedBoolOptionsAllFlagsPresent) { const char *Args[] = {"-cl-unsafe-math-optimizations", "-cl-mad-enable", - "-menable-unsafe-fp-math", "-freciprocal-math"}; + "-funsafe-math-optimizations", "-freciprocal-math"}; ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags)); ASSERT_TRUE(Invocation.getLangOpts()->CLUnsafeMath); @@ -765,12 +767,13 @@ TEST_F(CommandLineTest, ImpliedBoolOptionsAllFlagsPresent) { ASSERT_THAT(GeneratedArgs, Contains(StrEq("-cl-unsafe-math-optimizations"))); // Not generated - implied by their generated parent. ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-cl-mad-enable")))); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-menable-unsafe-fp-math")))); + ASSERT_THAT(GeneratedArgs, + Not(Contains(StrEq("-funsafe-math-optimizations")))); ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-freciprocal-math")))); } TEST_F(CommandLineTest, ImpliedBoolOptionsImpliedFlagsPresent) { - const char *Args[] = {"-cl-mad-enable", "-menable-unsafe-fp-math", + const char *Args[] = {"-cl-mad-enable", "-funsafe-math-optimizations", "-freciprocal-math"}; ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags)); @@ -785,13 +788,13 @@ TEST_F(CommandLineTest, ImpliedBoolOptionsImpliedFlagsPresent) { Not(Contains(StrEq("-cl-unsafe-math-optimizations")))); // Generated - explicitly provided. ASSERT_THAT(GeneratedArgs, Contains(StrEq("-cl-mad-enable"))); - ASSERT_THAT(GeneratedArgs, Contains(StrEq("-menable-unsafe-fp-math"))); + ASSERT_THAT(GeneratedArgs, Contains(StrEq("-funsafe-math-optimizations"))); // Not generated - implied by its generated parent. ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-freciprocal-math")))); } TEST_F(CommandLineTest, PresentAndNotImpliedGenerated) { - const char *Args[] = {"-cl-mad-enable", "-menable-unsafe-fp-math"}; + const char *Args[] = {"-cl-mad-enable", "-funsafe-math-optimizations"}; ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags)); @@ -799,7 +802,7 @@ TEST_F(CommandLineTest, PresentAndNotImpliedGenerated) { // Present options that were not implied are generated. ASSERT_THAT(GeneratedArgs, Contains(StrEq("-cl-mad-enable"))); - ASSERT_THAT(GeneratedArgs, Contains(StrEq("-menable-unsafe-fp-math"))); + ASSERT_THAT(GeneratedArgs, Contains(StrEq("-funsafe-math-optimizations"))); } // Diagnostic option. |