Author: Andy Kaylor Date: 2024-08-20T07:11:29-07:00 New Revision: 27e5f505e5eee3da27c1515d6ed95d66fbe543ea
URL: https://github.com/llvm/llvm-project/commit/27e5f505e5eee3da27c1515d6ed95d66fbe543ea DIFF: https://github.com/llvm/llvm-project/commit/27e5f505e5eee3da27c1515d6ed95d66fbe543ea.diff LOG: [Driver] Make ffp-model=fast honor non-finite-values, introduce ffp-model=aggressive (#100453) This change modifies -ffp-model=fast to select options that more closely match -funsafe-math-optimizations, and introduces a new model, -ffp-model=aggressive which matches the existing behavior (except for a minor change in the fp-contract behavior). The primary motivation for this change is to make -ffp-model=fast more user friendly, particularly in light of LLVM's aggressive optimizations when -fno-honor-nans and -fno-honor-infinites are used. This was previously proposed here: https://discourse.llvm.org/t/making-ffp-model-fast-more-user-friendly/78402 Added: Modified: clang/docs/ReleaseNotes.rst clang/docs/UsersManual.rst clang/lib/Driver/ToolChain.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/test/CodeGen/ffp-model.c clang/test/Driver/fp-model.c Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 249249971dec7..e3fac712de466 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -176,6 +176,14 @@ Modified Compiler Flags - The compiler flag `-fbracket-depth` default value is increased from 256 to 2048. +- The ``-ffp-model`` option has been updated to enable a more limited set of + optimizations when the ``fast`` argument is used and to accept a new argument, + ``aggressive``. The behavior of ``-ffp-model=aggressive`` is equivalent + to the previous behavior of ``-ffp-model=fast``. The updated + ``-ffp-model=fast`` behavior no longer assumes finite math only and uses + the ``promoted`` algorithm for complex division when possible rather than the + less basic (limited range) algorithm. + Removed Compiler Flags ------------------------- diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index 64e991451bf70..d19b77ae40b0d 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -1452,28 +1452,30 @@ describes the various floating point semantic modes and the corresponding option "fhonor-infinities", "{on, off}" "fsigned-zeros", "{on, off}" "freciprocal-math", "{on, off}" - "allow_approximate_fns", "{on, off}" + "fallow-approximate-fns", "{on, off}" "fassociative-math", "{on, off}" + "fcomplex-arithmetic", "{basic, improved, full, promoted}" This table describes the option settings that correspond to the three floating point semantic models: precise (the default), strict, and fast. .. csv-table:: Floating Point Models - :header: "Mode", "Precise", "Strict", "Fast" - :widths: 25, 15, 15, 15 - - "except_behavior", "ignore", "strict", "ignore" - "fenv_access", "off", "on", "off" - "rounding_mode", "tonearest", "dynamic", "tonearest" - "contract", "on", "off", "fast" - "support_math_errno", "on", "on", "off" - "no_honor_nans", "off", "off", "on" - "no_honor_infinities", "off", "off", "on" - "no_signed_zeros", "off", "off", "on" - "allow_reciprocal", "off", "off", "on" - "allow_approximate_fns", "off", "off", "on" - "allow_reassociation", "off", "off", "on" + :header: "Mode", "Precise", "Strict", "Fast", "Aggressive" + :widths: 25, 25, 25, 25, 25 + + "except_behavior", "ignore", "strict", "ignore", "ignore" + "fenv_access", "off", "on", "off", "off" + "rounding_mode", "tonearest", "dynamic", "tonearest", "tonearest" + "contract", "on", "off", "fast", "fast" + "support_math_errno", "on", "on", "off", "off" + "no_honor_nans", "off", "off", "off", "on" + "no_honor_infinities", "off", "off", "off", "on" + "no_signed_zeros", "off", "off", "on", "on" + "allow_reciprocal", "off", "off", "on", "on" + "allow_approximate_fns", "off", "off", "on", "on" + "allow_reassociation", "off", "off", "on", "on" + "complex_arithmetic", "full", "full", "promoted", "basic" The ``-ffp-model`` option does not modify the ``fdenormal-fp-math`` setting, but it does have an impact on whether ``crtfastmath.o`` is @@ -1492,9 +1494,9 @@ for more details. * Floating-point math obeys regular algebraic rules for real numbers (e.g. ``+`` and ``*`` are associative, ``x/y == x * (1/y)``, and ``(a + b) * c == a * c + b * c``), - * Operands to floating-point operations are not equal to ``NaN`` and - ``Inf``, and - * ``+0`` and ``-0`` are interchangeable. + * No ``NaN`` or infinite values will be operands or results of + floating-point operations, + * ``+0`` and ``-0`` may be treated as interchangeable. ``-ffast-math`` also defines the ``__FAST_MATH__`` preprocessor macro. Some math libraries recognize this macro and change their behavior. @@ -1753,7 +1755,7 @@ for more details. Specify floating point behavior. ``-ffp-model`` is an umbrella option that encompasses functionality provided by other, single purpose, floating point options. Valid values are: ``precise``, ``strict``, - and ``fast``. + ``fast``, and ``aggressive``. Details: * ``precise`` Disables optimizations that are not value-safe on @@ -1766,7 +1768,10 @@ for more details. ``STDC FENV_ACCESS``: by default ``FENV_ACCESS`` is disabled. This option setting behaves as though ``#pragma STDC FENV_ACCESS ON`` appeared at the top of the source file. - * ``fast`` Behaves identically to specifying both ``-ffast-math`` and + * ``fast`` Behaves identically to specifying ``-funsafe-math-optimizations``, + ``-fno-math-errno`` and ``-fcomplex-arithmetic=promoted`` + ``ffp-contract=fast`` + * ``aggressive`` Behaves identically to specifying both ``-ffast-math`` and ``ffp-contract=fast`` Note: If your command line specifies multiple instances diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 0e8577b1115e3..c93c97146b610 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -1366,7 +1366,7 @@ bool ToolChain::isFastMathRuntimeAvailable(const ArgList &Args, Default = false; if (A && A->getOption().getID() == options::OPT_ffp_model_EQ) { StringRef Model = A->getValue(); - if (Model != "fast") + if (Model != "fast" && Model != "aggressive") Default = false; } } diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index a8606a866bdff..6180c6eeb6f07 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2885,10 +2885,29 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D, std::string ComplexRangeStr = ""; std::string GccRangeComplexOption = ""; + auto setComplexRange = [&](LangOptions::ComplexRangeKind NewRange) { + // Warn if user expects to perform full implementation of complex + // multiplication or division in the presence of nnan or ninf flags. + if (Range != NewRange) + EmitComplexRangeDiag(D, + !GccRangeComplexOption.empty() + ? GccRangeComplexOption + : ComplexArithmeticStr(Range), + ComplexArithmeticStr(NewRange)); + Range = NewRange; + }; + // Lambda to set fast-math options. This is also used by -ffp-model=fast - auto applyFastMath = [&]() { - HonorINFs = false; - HonorNaNs = false; + auto applyFastMath = [&](bool Aggressive) { + if (Aggressive) { + HonorINFs = false; + HonorNaNs = false; + setComplexRange(LangOptions::ComplexRangeKind::CX_Basic); + } else { + HonorINFs = true; + HonorNaNs = true; + setComplexRange(LangOptions::ComplexRangeKind::CX_Promoted); + } MathErrno = false; AssociativeMath = true; ReciprocalMath = true; @@ -2897,21 +2916,7 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D, TrappingMath = false; RoundingFPMath = false; FPExceptionBehavior = ""; - // If fast-math is set then set the fp-contract mode to fast. FPContract = "fast"; - // ffast-math enables basic range rules for complex multiplication and - // division. - // Warn if user expects to perform full implementation of complex - // multiplication or division in the presence of nan or ninf flags. - if (Range == LangOptions::ComplexRangeKind::CX_Full || - Range == LangOptions::ComplexRangeKind::CX_Improved || - Range == LangOptions::ComplexRangeKind::CX_Promoted) - EmitComplexRangeDiag( - D, ComplexArithmeticStr(Range), - !GccRangeComplexOption.empty() - ? GccRangeComplexOption - : ComplexArithmeticStr(LangOptions::ComplexRangeKind::CX_Basic)); - Range = LangOptions::ComplexRangeKind::CX_Basic; SeenUnsafeMathModeOption = true; }; @@ -3039,8 +3044,8 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D, SignedZeros = true; StringRef Val = A->getValue(); - if (OFastEnabled && Val != "fast") { - // Only -ffp-model=fast is compatible with OFast, ignore. + if (OFastEnabled && Val != "aggressive") { + // Only -ffp-model=aggressive is compatible with -OFast, ignore. D.Diag(clang::diag::warn_drv_overriding_option) << Args.MakeArgString("-ffp-model=" + Val) << "-Ofast"; break; @@ -3052,13 +3057,19 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D, << Args.MakeArgString("-ffp-model=" + Val); if (Val == "fast") { FPModel = Val; - applyFastMath(); + applyFastMath(false); // applyFastMath sets fp-contract="fast" LastFpContractOverrideOption = "-ffp-model=fast"; + } else if (Val == "aggressive") { + FPModel = Val; + applyFastMath(true); + // applyFastMath sets fp-contract="fast" + LastFpContractOverrideOption = "-ffp-model=aggressive"; } else if (Val == "precise") { FPModel = Val; FPContract = "on"; LastFpContractOverrideOption = "-ffp-model=precise"; + setComplexRange(LangOptions::ComplexRangeKind::CX_Full); } else if (Val == "strict") { StrictFPModel = true; FPExceptionBehavior = "strict"; @@ -3067,6 +3078,7 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D, LastFpContractOverrideOption = "-ffp-model=strict"; TrappingMath = true; RoundingFPMath = true; + setComplexRange(LangOptions::ComplexRangeKind::CX_Full); } else D.Diag(diag::err_drv_unsupported_option_argument) << A->getSpelling() << Val; @@ -3247,7 +3259,7 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D, continue; [[fallthrough]]; case options::OPT_ffast_math: - applyFastMath(); + applyFastMath(true); if (A->getOption().getID() == options::OPT_Ofast) LastFpContractOverrideOption = "-Ofast"; else diff --git a/clang/test/CodeGen/ffp-model.c b/clang/test/CodeGen/ffp-model.c index 4ed9b9dc0a780..5516ccb218b03 100644 --- a/clang/test/CodeGen/ffp-model.c +++ b/clang/test/CodeGen/ffp-model.c @@ -3,6 +3,9 @@ // RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=fast %s -o - \ // RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-FAST +// RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=aggressive %s -o - \ +// RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-AGGRESSIVE + // RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=precise %s -o - \ // RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-PRECISE @@ -20,9 +23,13 @@ float mymuladd(float x, float y, float z) { // CHECK: define{{.*}} float @mymuladd return x * y + z; - // CHECK-FAST: fmul fast float + // CHECK-AGGRESSIVE: fmul fast float + // CHECK-AGGRESSIVE: load float, ptr + // CHECK-AGGRESSIVE: fadd fast float + + // CHECK-FAST: fmul reassoc nsz arcp contract afn float // CHECK-FAST: load float, ptr - // CHECK-FAST: fadd fast float + // CHECK-FAST: fadd reassoc nsz arcp contract afn float // CHECK-PRECISE: load float, ptr // CHECK-PRECISE: load float, ptr @@ -54,9 +61,13 @@ void my_vec_muladd(v2f x, float y, v2f z, v2f *res) { // CHECK: define{{.*}}@my_vec_muladd *res = x * y + z; - // CHECK-FAST: fmul fast <2 x float> + // CHECK-AGGRESSIVE: fmul fast <2 x float> + // CHECK-AGGRESSIVE: load <2 x float>, ptr + // CHECK-AGGRESSIVE: fadd fast <2 x float> + + // CHECK-FAST: fmul reassoc nsz arcp contract afn <2 x float> // CHECK-FAST: load <2 x float>, ptr - // CHECK-FAST: fadd fast <2 x float> + // CHECK-FAST: fadd reassoc nsz arcp contract afn <2 x float> // CHECK-PRECISE: load <2 x float>, ptr // CHECK-PRECISE: load float, ptr @@ -88,9 +99,13 @@ void my_m21_muladd(m21f x, float y, m21f z, m21f *res) { // CHECK: define{{.*}}@my_m21_muladd *res = x * y + z; - // CHECK-FAST: fmul fast <2 x float> + // CHECK-AGGRESSIVE: fmul fast <2 x float> + // CHECK-AGGRESSIVE: load <2 x float>, ptr + // CHECK-AGGRESSIVE: fadd fast <2 x float> + + // CHECK-FAST: fmul reassoc nsz arcp contract afn <2 x float> // CHECK-FAST: load <2 x float>, ptr - // CHECK-FAST: fadd fast <2 x float> + // CHECK-FAST: fadd reassoc nsz arcp contract afn <2 x float> // CHECK-PRECISE: load <2 x float>, ptr // CHECK-PRECISE: load float, ptr @@ -122,9 +137,13 @@ void my_m22_muladd(m22f x, float y, m22f z, m22f *res) { // CHECK: define{{.*}}@my_m22_muladd *res = x * y + z; - // CHECK-FAST: fmul fast <4 x float> + // CHECK-AGGRESSIVE: fmul fast <4 x float> + // CHECK-AGGRESSIVE: load <4 x float>, ptr + // CHECK-AGGRESSIVE: fadd fast <4 x float> + + // CHECK-FAST: fmul reassoc nsz arcp contract afn <4 x float> // CHECK-FAST: load <4 x float>, ptr - // CHECK-FAST: fadd fast <4 x float> + // CHECK-FAST: fadd reassoc nsz arcp contract afn <4 x float> // CHECK-PRECISE: load <4 x float>, ptr // CHECK-PRECISE: load float, ptr diff --git a/clang/test/Driver/fp-model.c b/clang/test/Driver/fp-model.c index 2348d4b41f43a..6f17d4aeb1ef5 100644 --- a/clang/test/Driver/fp-model.c +++ b/clang/test/Driver/fp-model.c @@ -2,13 +2,17 @@ // and other floating point options get a warning diagnostic. // -// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \ +// RUN: %clang -### -ffp-model=aggressive -ffp-contract=off -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=WARN %s -// WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-option] +// WARN: warning: overriding '-ffp-model=aggressive' option with '-ffp-contract=off' [-Woverriding-option] + +// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=WARN0 %s +// WARN0: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-option] -// RUN: %clang -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \ +// RUN: %clang -### -ffp-model=aggressive -ffp-contract=on -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=WARN1 %s -// WARN1: warning: overriding '-ffp-model=fast' option with '-ffp-contract=on' [-Woverriding-option] +// WARN1: warning: overriding '-ffp-model=aggressive' option with '-ffp-contract=on' [-Woverriding-option] // RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=WARN2 %s @@ -74,9 +78,12 @@ // RUN: %clang -### -Ofast -ffp-model=strict -c %s 2>&1 | FileCheck \ // RUN: --check-prefix=WARN12 %s -// RUN: %clang -### -Werror -ffast-math -ffp-model=strict -c %s // WARN12: warning: overriding '-ffp-model=strict' option with '-Ofast' +// RUN: %clang -### -ffast-math -ffp-model=strict -c %s 2>&1 | FileCheck \ +// RUN: --check-prefix=WARN-CX-BASIC-TO-FULL %s +// WARN-CX-BASIC-TO-FULL: warning: overriding '-fcomplex-arithmetic=basic' option with '-fcomplex-arithmetic=full' + // RUN: %clang -### -ffp-model=strict -fapprox-func -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=WARN13 %s // WARN13: warning: overriding '-ffp-model=strict' option with '-fapprox-func' [-Woverriding-option] @@ -97,44 +104,61 @@ // RUN: %clang -### -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NOROUND %s // CHECK-NOROUND: "-cc1" -// CHECK-NOROUND: "-fno-rounding-math" +// CHECK-NOROUND-SAME: "-fno-rounding-math" // RUN: %clang -### -frounding-math -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-ROUND --implicit-check-not ffp-exception-behavior=strict %s // CHECK-ROUND: "-cc1" -// CHECK-ROUND: "-frounding-math" +// CHECK-ROUND-SAME: "-frounding-math" // RUN: %clang -### -ftrapping-math -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-TRAP %s // CHECK-TRAP: "-cc1" -// CHECK-TRAP: "-ffp-exception-behavior=strict" +// CHECK-TRAP-SAME: "-ffp-exception-behavior=strict" + +// RUN: %clang -### -nostdinc -ffp-model=aggressive -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-FPM-AGGR %s +// CHECK-FPM-AGGR: "-cc1" +// CHECK-FPM-AGGR-SAME: "-menable-no-infs" +// CHECK-FPM-AGGR-SAME: "-menable-no-nans" +// CHECK-FPM-AGGR-SAME: "-fapprox-func" +// CHECK-FPM-AGGR-SAME: "-funsafe-math-optimizations" +// CHECK-FPM-AGGR-SAME: "-fno-signed-zeros" +// CHECK-FPM-AGGR-SAME: "-mreassociate" +// CHECK-FPM-AGGR-SAME: "-freciprocal-math" +// CHECK-FPM-AGGR-SAME: "-ffp-contract=fast" +// CHECK-FPM-AGGR-SAME: "-fno-rounding-math" +// CHECK-FPM-AGGR-SAME: "-ffast-math" +// CHECK-FPM-AGGR-SAME: "-ffinite-math-only" +// CHECK-FPM-AGGR-SAME: "-complex-range=basic" // RUN: %clang -### -nostdinc -ffp-model=fast -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FPM-FAST %s // CHECK-FPM-FAST: "-cc1" -// CHECK-FPM-FAST: "-menable-no-infs" -// CHECK-FPM-FAST: "-menable-no-nans" -// CHECK-FPM-FAST: "-fapprox-func" -// CHECK-FPM-FAST: "-funsafe-math-optimizations" -// CHECK-FPM-FAST: "-fno-signed-zeros" -// CHECK-FPM-FAST: "-mreassociate" -// CHECK-FPM-FAST: "-freciprocal-math" -// CHECK-FPM-FAST: "-ffp-contract=fast" -// CHECK-FPM-FAST: "-fno-rounding-math" -// CHECK-FPM-FAST: "-ffast-math" -// CHECK-FPM-FAST: "-ffinite-math-only" +// CHECK-FPM-FAST-NOT: "-menable-no-infs" +// CHECK-FPM-FAST-NOT: "-menable-no-nans" +// CHECK-FPM-FAST-SAME: "-fapprox-func" +// CHECK-FPM-FAST-SAME: "-funsafe-math-optimizations" +// CHECK-FPM-FAST-SAME: "-fno-signed-zeros" +// CHECK-FPM-FAST-SAME: "-mreassociate" +// CHECK-FPM-FAST-SAME: "-freciprocal-math" +// CHECK-FPM-FAST-SAME: "-ffp-contract=fast" +// CHECK-FPM-FAST-SAME: "-fno-rounding-math" +// CHECK-FPM-FAST-NOT: "-ffast-math" +// CHECK-FPM-FAST-NOT: "-ffinite-math-only" +// CHECK-FPM-FAST-SAME: "-complex-range=promoted" // RUN: %clang -### -nostdinc -ffp-model=precise -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FPM-PRECISE %s // CHECK-FPM-PRECISE: "-cc1" -// CHECK-FPM-PRECISE: "-ffp-contract=on" -// CHECK-FPM-PRECISE: "-fno-rounding-math" +// CHECK-FPM-PRECISE-SAME: "-ffp-contract=on" +// CHECK-FPM-PRECISE-SAME: "-fno-rounding-math" // RUN: %clang -### -nostdinc -ffp-model=strict -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FPM-STRICT %s // CHECK-FPM-STRICT: "-cc1" -// CHECK-FPM-STRICT: "-frounding-math" -// CHECK-FPM-STRICT: "-ffp-exception-behavior=strict" +// CHECK-FPM-STRICT-SAME: "-frounding-math" +// CHECK-FPM-STRICT-SAME: "-ffp-exception-behavior=strict" // RUN: %clang -### -nostdinc -ffp-model=strict -ffp-model=fast -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NO-EXCEPT %s @@ -148,14 +172,14 @@ // RUN: %clang -### -nostdinc -ffp-exception-behavior=strict -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FEB-STRICT %s // CHECK-FEB-STRICT: "-cc1" -// CHECK-FEB-STRICT: "-fno-rounding-math" -// CHECK-FEB-STRICT: "-ffp-exception-behavior=strict" +// CHECK-FEB-STRICT-SAME: "-fno-rounding-math" +// CHECK-FEB-STRICT-SAME: "-ffp-exception-behavior=strict" // RUN: %clang -### -nostdinc -ffp-exception-behavior=maytrap -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FEB-MAYTRAP %s // CHECK-FEB-MAYTRAP: "-cc1" -// CHECK-FEB-MAYTRAP: "-fno-rounding-math" -// CHECK-FEB-MAYTRAP: "-ffp-exception-behavior=maytrap" +// CHECK-FEB-MAYTRAP-SAME: "-fno-rounding-math" +// CHECK-FEB-MAYTRAP-SAME: "-ffp-exception-behavior=maytrap" // RUN: %clang -### -nostdinc -ffp-exception-behavior=ignore -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FEB-IGNORE %s @@ -163,23 +187,41 @@ // CHECK-FEB-IGNORE: "-fno-rounding-math" // CHECK-FEB-IGNORE: "-ffp-exception-behavior=ignore" -// RUN: %clang -### -nostdinc -Werror -ffast-math -ffp-model=fast -c %s 2>&1 \ +// RUN: %clang -### -nostdinc -Werror -ffast-math -ffp-model=aggressive -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-FASTMATH-FPM-AGGR %s +// CHECK-FASTMATH-FPM-AGGR: "-cc1" +// CHECK-FASTMATH-FPM-AGGR-SAME: "-menable-no-infs" +// CHECK-FASTMATH-FPM-AGGR-SAME: "-menable-no-nans" +// CHECK-FASTMATH-FPM-AGGR-SAME: "-fapprox-func" +// CHECK-FASTMATH-FPM-AGGR-SAME: "-funsafe-math-optimizations" +// CHECK-FASTMATH-FPM-AGGR-SAME: "-fno-signed-zeros" +// CHECK-FASTMATH-FPM-AGGR-SAME: "-mreassociate" +// CHECK-FASTMATH-FPM-AGGR-SAME: "-freciprocal-math" +// CHECK-FASTMATH-FPM-AGGR-SAME: "-ffp-contract=fast" +// CHECK-FASTMATH-FPM-AGGR-SAME: "-fno-rounding-math" +// CHECK-FASTMATH-FPM-AGGR-SAME: "-ffast-math" +// CHECK-FASTMATH-FPM-AGGR-SAME: "-ffinite-math-only" +// CHECK-FASTMATH-FPM-AGGR-SAME: "-complex-range=basic" + +// RUN: %clang -### -nostdinc -ffast-math -ffp-model=fast -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FASTMATH-FPM-FAST %s +// CHECK-FASTMATH-FPM-FAST: warning: overriding '-fcomplex-arithmetic=basic' option with '-fcomplex-arithmetic=promoted' // CHECK-FASTMATH-FPM-FAST: "-cc1" -// CHECK-FASTMATH-FPM-FAST: "-menable-no-infs" -// CHECK-FASTMATH-FPM-FAST: "-menable-no-nans" -// CHECK-FASTMATH-FPM-FAST: "-fapprox-func" -// CHECK-FASTMATH-FPM-FAST: "-funsafe-math-optimizations" -// CHECK-FASTMATH-FPM-FAST: "-fno-signed-zeros" -// CHECK-FASTMATH-FPM-FAST: "-mreassociate" -// CHECK-FASTMATH-FPM-FAST: "-freciprocal-math" -// CHECK-FASTMATH-FPM-FAST: "-ffp-contract=fast" -// CHECK-FASTMATH-FPM-FAST: "-fno-rounding-math" -// CHECK-FASTMATH-FPM-FAST: "-ffast-math" -// CHECK-FASTMATH-FPM-FAST: "-ffinite-math-only" - -// RUN: %clang -### -nostdinc -Werror -ffast-math -ffp-model=precise -c %s 2>&1 \ -// RUN: | FileCheck --check-prefix=CHECK-FASTMATH-FPM-PRECISE %s +// CHECK-FASTMATH-FPM-FAST-NOT: "-menable-no-infs" +// CHECK-FASTMATH-FPM-FAST-NOT: "-menable-no-nans" +// CHECK-FASTMATH-FPM-FAST-SAME: "-fapprox-func" +// CHECK-FASTMATH-FPM-FAST-SAME: "-funsafe-math-optimizations" +// CHECK-FASTMATH-FPM-FAST-SAME: "-fno-signed-zeros" +// CHECK-FASTMATH-FPM-FAST-SAME: "-mreassociate" +// CHECK-FASTMATH-FPM-FAST-SAME: "-freciprocal-math" +// CHECK-FASTMATH-FPM-FAST-SAME: "-ffp-contract=fast" +// CHECK-FASTMATH-FPM-FAST-SAME: "-fno-rounding-math" +// CHECK-FASTMATH-FPM-FAST-NOT: "-ffast-math" +// CHECK-FASTMATH-FPM-FAST-NOT: "-ffinite-math-only" +// CHECK-FASTMATH-FPM-FAST-SAME: "-complex-range=promoted" + +// RUN: %clang -### -nostdinc -ffast-math -ffp-model=precise -c %s 2>&1 \ +// RUN: | FileCheck --check-prefixes=CHECK-FASTMATH-FPM-PRECISE,WARN-CX-BASIC-TO-FULL %s // CHECK-FASTMATH-FPM-PRECISE: "-cc1" // CHECK-FASTMATH-FPM-PRECISE-NOT: "-menable-no-infs" // CHECK-FASTMATH-FPM-PRECISE-NOT: "-menable-no-nans" @@ -188,13 +230,14 @@ // CHECK-FASTMATH-FPM-PRECISE-NOT: "-fno-signed-zeros" // CHECK-FASTMATH-FPM-PRECISE-NOT: "-mreassociate" // CHECK-FASTMATH-FPM-PRECISE-NOT: "-freciprocal-math" -// CHECK-FASTMATH-FPM-PRECISE: "-ffp-contract=on" -// CHECK-FASTMATH-FPM-PRECISE: "-fno-rounding-math" +// CHECK-FASTMATH-FPM-PRECISE-SAME: "-ffp-contract=on" +// CHECK-FASTMATH-FPM-PRECISE-SAME: "-fno-rounding-math" // CHECK-FASTMATH-FPM-PRECISE-NOT: "-ffast-math" // CHECK-FASTMATH-FPM-PRECISE-NOT: "-ffinite-math-only" +// CHECK-FASTMATH-FPM-PRECISE-SAME: "-complex-range=full" -// RUN: %clang -### -nostdinc -Werror -ffast-math -ffp-model=strict -c %s 2>&1 \ -// RUN: | FileCheck --check-prefix=CHECK-FASTMATH-FPM-STRICT %s +// RUN: %clang -### -nostdinc -ffast-math -ffp-model=strict -c %s 2>&1 \ +// RUN: | FileCheck --check-prefixes=CHECK-FASTMATH-FPM-STRICT,WARN-CX-BASIC-TO-FULL %s // CHECK-FASTMATH-FPM-STRICT: "-cc1" // CHECK-FASTMATH-FPM-STRICT-NOT: "-menable-no-infs" // CHECK-FASTMATH-FPM-STRICT-NOT: "-menable-no-nans" @@ -203,7 +246,8 @@ // CHECK-FASTMATH-FPM-STRICT-NOT: "-fno-signed-zeros" // CHECK-FASTMATH-FPM-STRICT-NOT: "-mreassociate" // CHECK-FASTMATH-FPM-STRICT-NOT: "-freciprocal-math" -// CHECK-FASTMATH-FPM-STRICT: "-ffp-contract=off" +// CHECK-FASTMATH-FPM-STRICT-SAME: "-ffp-contract=off" // CHECK-FASTMATH-FPM-STRICT-NOT: "-fno-rounding-math" // CHECK-FASTMATH-FPM-STRICT-NOT: "-ffast-math" // CHECK-FASTMATH-FPM-STRICT-NOT: "-ffinite-math-only" +// CHECK-FASTMATH-FPM-STRICT-SAME: "-complex-range=full" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits