[clang] 66ddac2 - [CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and extend #pragma float_control similarly

Melanie Blower via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 28 07:51:14 PDT 2021


Author: Melanie Blower
Date: 2021-07-28T10:50:32-04:00
New Revision: 66ddac22e2a7f268e91c26d694112970dfa607ae

URL: https://github.com/llvm/llvm-project/commit/66ddac22e2a7f268e91c26d694112970dfa607ae
DIFF: https://github.com/llvm/llvm-project/commit/66ddac22e2a7f268e91c26d694112970dfa607ae.diff

LOG: [CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and extend #pragma float_control similarly

The Intel compiler ICC supports the option "-fp-model=(source|double|extended)"
which causes the compiler to use a wider type for intermediate floating point
calculations. Also supported is a way to embed this effect in the source
program with #pragma float_control(source|double|extended).
This patch extends pragma float_control syntax, and also adds support
for a new floating point option "-ffp-eval-method=(source|double|extended)".
source: intermediate results use source precision
double: intermediate results use double precision
extended: intermediate results use extended precision

Reviewed By: Aaron Ballman

Differential Revision: https://reviews.llvm.org/D93769

Added: 
    

Modified: 
    clang/docs/LanguageExtensions.rst
    clang/docs/UsersManual.rst
    clang/include/clang/Basic/FPOptions.def
    clang/include/clang/Basic/LangOptions.def
    clang/include/clang/Basic/LangOptions.h
    clang/include/clang/Basic/PragmaKinds.h
    clang/include/clang/Basic/TargetInfo.h
    clang/include/clang/Driver/Options.td
    clang/include/clang/Lex/Preprocessor.h
    clang/include/clang/Lex/PreprocessorOptions.h
    clang/include/clang/Sema/Sema.h
    clang/lib/Basic/Targets/OSTargets.h
    clang/lib/Basic/Targets/X86.h
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/lib/Frontend/CompilerInvocation.cpp
    clang/lib/Frontend/InitPreprocessor.cpp
    clang/lib/Lex/PPMacroExpansion.cpp
    clang/lib/Parse/ParsePragma.cpp
    clang/lib/Sema/Sema.cpp
    clang/lib/Sema/SemaAttr.cpp
    clang/lib/Sema/SemaExpr.cpp
    clang/test/CodeGen/fp-floatcontrol-pragma.cpp
    clang/test/Preprocessor/init-aarch64.c
    clang/test/Preprocessor/init-arm.c
    clang/test/Preprocessor/init-mips.c
    clang/test/Preprocessor/init-ppc.c
    clang/test/Preprocessor/init-ppc64.c
    clang/test/Preprocessor/init-s390x.c
    clang/test/Preprocessor/init-v7k-compat.c
    clang/test/Preprocessor/init-x86.c
    clang/test/Preprocessor/init.c

Removed: 
    


################################################################################
diff  --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst
index 8090aedb573b..462aa89ea789 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3554,7 +3554,7 @@ specification, a stack is supported so that the ``pragma float_control``
 settings can be pushed or popped.
 
 When ``pragma float_control(precise, on)`` is enabled, the section of code
-governed by the pragma uses precise floating point semantics, effectively
+governed by the pragma uses precise floating-point semantics, effectively
 ``-ffast-math`` is disabled and ``-ffp-contract=on``
 (fused multiply add) is enabled.
 
@@ -3565,8 +3565,29 @@ when ``pragma float_control(precise, off)`` is enabled, the section of code
 governed by the pragma behaves as though the command-line option
 ``-ffp-exception-behavior=ignore`` is enabled.
 
+When ``pragma float_control(source, on)`` is enabled, the section of code governed
+by the pragma behaves as though the command-line option
+``-ffp-eval-method=source`` is enabled. Note: The default
+floating-point evaluation method is target-specific, typically ``source``.
+
+When ``pragma float_control(double, on)`` is enabled, the section of code governed
+by the pragma behaves as though the command-line option
+``-ffp-eval-method=double`` is enabled.
+
+When ``pragma float_control(extended, on)`` is enabled, the section of code governed
+by the pragma behaves as though the command-line option
+``-ffp-eval-method=extended`` is enabled.
+
+When ``pragma float_control(source, off)`` or
+``pragma float_control(double, off)`` or
+``pragma float_control(extended, off)`` is enabled,
+the section of code governed
+by the pragma behaves as though the command-line option
+``-ffp-eval-method=source`` is enabled, returning floating-point evaluation
+method to the default setting.
+
 The full syntax this pragma supports is
-``float_control(except|precise, on|off [, push])`` and
+``float_control(except|precise|source|double|extended, on|off [, push])`` and
 ``float_control(push|pop)``.
 The ``push`` and ``pop`` forms, including using ``push`` as the optional
 third argument, can only occur at file scope.

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index aecd28e5e12a..63056e09ac57 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1520,6 +1520,17 @@ Note that floating-point operations performed as part of constant initialization
    * ``maytrap`` The compiler avoids transformations that may raise exceptions that would not have been raised by the original code. Constant folding performed by the compiler is exempt from this option.
    * ``strict`` The compiler ensures that all transformations strictly preserve the floating point exception semantics of the original code.
 
+.. option:: -ffp-eval-method=<value>
+
+   Specify the floating-point evaluation method.
+
+   Valid values are: ``source``, ``double``, and ``extended``.
+   The default value is target-specific, typically ``source``.  Details:
+
+   * ``source`` The compiler uses the floating-point type declared in the source program as the evaluation method.
+   * ``double`` The compiler uses ``double`` as the floating-point evaluation method for all float expressions of type that is narrower than ``double``.
+   * ``extended`` The compiler uses ``long double`` as the floating-point evaluation method for all float expressions of type that is narrower than ``long double``.
+
 .. option:: -f[no-]protect-parens:
 
    This option pertains to floating-point types, complex types with

diff  --git a/clang/include/clang/Basic/FPOptions.def b/clang/include/clang/Basic/FPOptions.def
index a93fa475cd5f..224c1827144f 100644
--- a/clang/include/clang/Basic/FPOptions.def
+++ b/clang/include/clang/Basic/FPOptions.def
@@ -23,4 +23,5 @@ OPTION(NoHonorInfs, bool, 1, NoHonorNaNs)
 OPTION(NoSignedZero, bool, 1, NoHonorInfs)
 OPTION(AllowReciprocal, bool, 1, NoSignedZero)
 OPTION(AllowApproxFunc, bool, 1, AllowReciprocal)
+OPTION(FPEvalMethod, LangOptions::FPEvalMethodKind, 2, AllowApproxFunc)
 #undef OPTION

diff  --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def
index 08b8d8851afa..5c3d534c9b11 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -296,6 +296,7 @@ BENIGN_ENUM_LANGOPT(DefaultFPContractMode, FPModeKind, 2, FPM_Off, "FP contracti
 COMPATIBLE_LANGOPT(ExpStrictFP, 1, false, "Enable experimental strict floating point")
 BENIGN_ENUM_LANGOPT(FPRoundingMode, RoundingMode, 3, RoundingMode::NearestTiesToEven, "FP Rounding Mode type")
 BENIGN_ENUM_LANGOPT(FPExceptionMode, FPExceptionModeKind, 2, FPE_Ignore, "FP Exception Behavior Mode type")
+BENIGN_ENUM_LANGOPT(FPEvalMethod, FPEvalMethodKind, 2, FEM_TargetDefault, "FP type used for floating point arithmetic")
 LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment")
 LANGOPT(HexagonQdsp6Compat , 1, 0, "hexagon-qdsp6 backward compatibility")
 LANGOPT(ObjCAutoRefCount , 1, 0, "Objective-C automated reference counting")

diff  --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h
index 71cf0c65e692..97766e059c04 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -233,6 +233,19 @@ class LangOptions : public LangOptionsBase {
   /// Possible exception handling behavior.
   enum class ExceptionHandlingKind { None, SjLj, WinEH, DwarfCFI, Wasm };
 
+  /// Possible float expression evaluation method choices.
+  enum FPEvalMethodKind {
+    /// Use the declared type for fp arithmetic.
+    FEM_Source,
+    /// Use the type double for fp arithmetic.
+    FEM_Double,
+    /// Use extended type for fp arithmetic.
+    FEM_Extended,
+    /// Use the default float eval method specified by Target:
+    //  most targets are defined with evaluation method FEM_Source.
+    FEM_TargetDefault
+  };
+
   enum class LaxVectorConversionKind {
     /// Permit no implicit vector bitcasts.
     None,
@@ -524,6 +537,7 @@ class FPOptions {
       setAllowFEnvAccess(true);
     else
       setAllowFEnvAccess(LangOptions::FPM_Off);
+    setFPEvalMethod(LO.getFPEvalMethod());
   }
 
   bool allowFPContractWithinStatement() const {

diff  --git a/clang/include/clang/Basic/PragmaKinds.h b/clang/include/clang/Basic/PragmaKinds.h
index 82c0d5f0a551..24b6858e8c23 100644
--- a/clang/include/clang/Basic/PragmaKinds.h
+++ b/clang/include/clang/Basic/PragmaKinds.h
@@ -32,7 +32,10 @@ enum PragmaFloatControlKind {
   PFC_Except,    // #pragma float_control(except [,on])
   PFC_NoExcept,  // #pragma float_control(except, off)
   PFC_Push,      // #pragma float_control(push)
-  PFC_Pop        // #pragma float_control(pop)
+  PFC_Pop,       // #pragma float_control(pop)
+  PFC_Source,    // #pragma float_control(source, {on|off} [,push])
+  PFC_Double,    // #pragma float_control(double, {on|off} [,push])
+  PFC_Extended,  // #pragma float_control(extended, {on|off} [,push])
 };
 }
 

diff  --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index 4f0cbf986b31..c7a57a7dba9a 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -687,7 +687,8 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   }
 
   /// Return the value for the C99 FLT_EVAL_METHOD macro.
-  virtual unsigned getFloatEvalMethod() const { return 0; }
+  //  Note: implementation defined values may be negative.
+  virtual int getFPEvalMethod() const { return 0; }
 
   // getLargeArrayMinWidth/Align - Return the minimum array size that is
   // 'large' and its alignment.

diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 5a9fd078390e..4efb4786f908 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1434,6 +1434,11 @@ def : Flag<["-"], "fextended-identifiers">, Group<clang_ignored_f_Group>;
 def : Flag<["-"], "fno-extended-identifiers">, Group<f_Group>, Flags<[Unsupported]>;
 def fhosted : Flag<["-"], "fhosted">, Group<f_Group>;
 def fdenormal_fp_math_EQ : Joined<["-"], "fdenormal-fp-math=">, Group<f_Group>, Flags<[CC1Option]>;
+def ffp_eval_method_EQ : Joined<["-"], "ffp-eval-method=">, Group<f_Group>, Flags<[CC1Option]>,
+  HelpText<"Specifies the evaluation method to use for floating-point arithmetic.">,
+  Values<"source,double,extended">, NormalizedValuesScope<"LangOptions">,
+  NormalizedValues<["FEM_Source", "FEM_Double", "FEM_Extended"]>,
+  MarshallingInfoEnum<LangOpts<"FPEvalMethod">, "FEM_TargetDefault">;
 def ffp_model_EQ : Joined<["-"], "ffp-model=">, Group<f_Group>, Flags<[NoXarchOption]>,
   HelpText<"Controls the semantics of floating-point calculations.">;
 def ffp_exception_behavior_EQ : Joined<["-"], "ffp-exception-behavior=">, Group<f_Group>, Flags<[CC1Option]>,

diff  --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index 7ab13640ce2c..a089d166caaa 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -178,12 +178,17 @@ class Preprocessor {
   IdentifierInfo *Ident__is_target_vendor;         // __is_target_vendor
   IdentifierInfo *Ident__is_target_os;             // __is_target_os
   IdentifierInfo *Ident__is_target_environment;    // __is_target_environment
+  IdentifierInfo *Ident__FLT_EVAL_METHOD__ = nullptr; // __FLT_EVAL_METHOD__
 
   // Weak, only valid (and set) while InMacroArgs is true.
   Token* ArgMacro;
 
   SourceLocation DATELoc, TIMELoc;
 
+  // Corresponding to __FLT_EVAL_METHOD__. Initialized from TargetInfo
+  // or the command line. Implementation-defined values can be negative.
+  int CurrentFPEvalMethod = 0;
+
   // Next __COUNTER__ value, starts at 0.
   unsigned CounterValue = 0;
 
@@ -1988,6 +1993,8 @@ class Preprocessor {
   }
   unsigned getCounterValue() const { return CounterValue; }
   void setCounterValue(unsigned V) { CounterValue = V; }
+  int getCurrentFPEvalMethod() const { return CurrentFPEvalMethod; }
+  void setCurrentFPEvalMethod(int V) { CurrentFPEvalMethod = V; }
 
   /// Retrieves the module that we're currently building, if any.
   Module *getCurrentModule();

diff  --git a/clang/include/clang/Lex/PreprocessorOptions.h b/clang/include/clang/Lex/PreprocessorOptions.h
index 99085b98fc7a..4ad7305e3b39 100644
--- a/clang/include/clang/Lex/PreprocessorOptions.h
+++ b/clang/include/clang/Lex/PreprocessorOptions.h
@@ -146,6 +146,9 @@ class PreprocessorOptions {
   /// When enabled, the preprocessor will construct editor placeholder tokens.
   bool LexEditorPlaceholders = true;
 
+  /// When enabled, the preprocessor will expand special builtin macros.
+  bool LexExpandSpecialBuiltins = true;
+
   /// True if the SourceManager should report the original file name for
   /// contents of files that were remapped to other files. Defaults to true.
   bool RemappedFilesKeepOriginalName = true;
@@ -249,6 +252,7 @@ class PreprocessorOptions {
     ImplicitPCHInclude.clear();
     SingleFileParseMode = false;
     LexEditorPlaceholders = true;
+    LexExpandSpecialBuiltins = true;
     RetainRemappedFileBuffers = true;
     PrecompiledPreambleBytes.first = 0;
     PrecompiledPreambleBytes.second = false;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 83a2d132bf6a..375b650b8ecb 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -1502,19 +1502,15 @@ class Sema final {
   /// statements.
   class FPFeaturesStateRAII {
   public:
-    FPFeaturesStateRAII(Sema &S) : S(S), OldFPFeaturesState(S.CurFPFeatures) {
-      OldOverrides = S.FpPragmaStack.CurrentValue;
-    }
-    ~FPFeaturesStateRAII() {
-      S.CurFPFeatures = OldFPFeaturesState;
-      S.FpPragmaStack.CurrentValue = OldOverrides;
-    }
+    FPFeaturesStateRAII(Sema &S);
+    ~FPFeaturesStateRAII();
     FPOptionsOverride getOverrides() { return OldOverrides; }
 
   private:
     Sema& S;
     FPOptions OldFPFeaturesState;
     FPOptionsOverride OldOverrides;
+    int OldEvalMethod;
   };
 
   void addImplicitTypedef(StringRef Name, QualType T);

diff  --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h
index e24fb5cf082d..6329acf75683 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -735,7 +735,7 @@ class AIXTargetInfo : public OSTargetInfo<Target> {
   }
 
   // AIX sets FLT_EVAL_METHOD to be 1.
-  unsigned getFloatEvalMethod() const override { return 1; }
+  int getFPEvalMethod() const override { return 1; }
   bool hasInt128Type() const override { return false; }
 
   bool defaultsToAIXPowerAlignment() const override { return true; }

diff  --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index fcaaf50624e9..c5ddd0067235 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -165,7 +165,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo {
     return LongDoubleFormat == &llvm::APFloat::IEEEquad() ? "g" : "e";
   }
 
-  unsigned getFloatEvalMethod() const override {
+  int getFPEvalMethod() const override {
     // X87 evaluates with 80 bits "long double" precision.
     return SSELevel == NoSSE ? 2 : 0;
   }
@@ -468,12 +468,12 @@ class LLVM_LIBRARY_VISIBILITY NetBSDI386TargetInfo
   NetBSDI386TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
       : NetBSDTargetInfo<X86_32TargetInfo>(Triple, Opts) {}
 
-  unsigned getFloatEvalMethod() const override {
+  int getFPEvalMethod() const override {
     unsigned Major, Minor, Micro;
     getTriple().getOSVersion(Major, Minor, Micro);
     // New NetBSD uses the default rounding mode.
     if (Major >= 7 || (Major == 6 && Minor == 99 && Micro >= 26) || Major == 0)
-      return X86_32TargetInfo::getFloatEvalMethod();
+      return X86_32TargetInfo::getFPEvalMethod();
     // NetBSD before 6.99.26 defaults to "double" rounding.
     return 1;
   }

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index a4b53a640ab5..e13302528cbd 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2631,6 +2631,8 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
   StringRef FPModel = "";
   // -ffp-exception-behavior options: strict, maytrap, ignore
   StringRef FPExceptionBehavior = "";
+  // -ffp-eval-method options: double, extended, source
+  StringRef FPEvalMethod = "";
   const llvm::DenormalMode DefaultDenormalFPMath =
       TC.getDefaultDenormalModeForType(Args, JA);
   const llvm::DenormalMode DefaultDenormalFP32Math =
@@ -2822,6 +2824,18 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
       break;
     }
 
+    // Validate and pass through -ffp-eval-method option.
+    case options::OPT_ffp_eval_method_EQ: {
+      StringRef Val = A->getValue();
+      if (Val.equals("double") || Val.equals("extended") ||
+          Val.equals("source"))
+        FPEvalMethod = Val;
+      else
+        D.Diag(diag::err_drv_unsupported_option_argument)
+            << A->getOption().getName() << Val;
+      break;
+    }
+
     case options::OPT_ffinite_math_only:
       HonorINFs = false;
       HonorNaNs = false;
@@ -2965,6 +2979,9 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
     CmdArgs.push_back(Args.MakeArgString("-ffp-exception-behavior=" +
                       FPExceptionBehavior));
 
+  if (!FPEvalMethod.empty())
+    CmdArgs.push_back(Args.MakeArgString("-ffp-eval-method=" + FPEvalMethod));
+
   ParseMRecip(D, Args, CmdArgs);
 
   // -ffast-math enables the __FAST_MATH__ preprocessor macro, but check for the

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index d545e9358f04..63436b7aebe1 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4242,8 +4242,13 @@ static bool ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
   // Always avoid lexing editor placeholders when we're just running the
   // preprocessor as we never want to emit the
   // "editor placeholder in source file" error in PP only mode.
-  if (isStrictlyPreprocessorAction(Action))
+  // Certain predefined macros which depend upon semantic processing,
+  // for example __FLT_EVAL_METHOD__, are not expanded in PP mode, they
+  // appear in the preprocessed output as an unexpanded macro name.
+  if (isStrictlyPreprocessorAction(Action)) {
     Opts.LexEditorPlaceholders = false;
+    Opts.LexExpandSpecialBuiltins = false;
+  }
 
   return Diags.getNumErrors() == NumErrorsBefore;
 }

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index bca0bb4ada67..6904b82e2b43 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -1077,7 +1077,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
   }
 
   // Macros to control C99 numerics and <float.h>
-  Builder.defineMacro("__FLT_EVAL_METHOD__", Twine(TI.getFloatEvalMethod()));
+  // Note: __FLT_EVAL_METHOD__ is not defined here since it is a special
+  // builtin macro, its value may fluctuate during compilation.
   Builder.defineMacro("__FLT_RADIX__", "2");
   Builder.defineMacro("__DECIMAL_DIG__", "__LDBL_DECIMAL_DIG__");
 

diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index 8728ac9e2166..589d3c335885 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -345,6 +345,11 @@ void Preprocessor::RegisterBuiltinMacros() {
   Ident__TIME__ = RegisterBuiltinMacro(*this, "__TIME__");
   Ident__COUNTER__ = RegisterBuiltinMacro(*this, "__COUNTER__");
   Ident_Pragma  = RegisterBuiltinMacro(*this, "_Pragma");
+  if (PPOpts->LexExpandSpecialBuiltins)
+    // Suppress macro expansion if compiler stops before semantic analysis,
+    // the macro identifier will appear in the preprocessed output.
+    Ident__FLT_EVAL_METHOD__ =
+        RegisterBuiltinMacro(*this, "__FLT_EVAL_METHOD__");
 
   // C++ Standing Document Extensions.
   if (getLangOpts().CPlusPlus)
@@ -1607,6 +1612,10 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
     // Surround the string with " and strip the trailing newline.
     OS << '"' << StringRef(Result).drop_back() << '"';
     Tok.setKind(tok::string_literal);
+  } else if (II == Ident__FLT_EVAL_METHOD__) {
+    // __FLT_EVAL_METHOD__ expands to a simple numeric value.
+    OS << getCurrentFPEvalMethod();
+    Tok.setKind(tok::numeric_constant);
   } else if (II == Ident__COUNTER__) {
     // __COUNTER__ expands to a simple numeric value.
     OS << CounterValue++;
@@ -1704,8 +1713,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
 
         return false;
       });
-  } else if (II == Ident__has_cpp_attribute ||
-             II == Ident__has_c_attribute) {
+  } else if (II == Ident__has_cpp_attribute || II == Ident__has_c_attribute) {
     bool IsCXX = II == Ident__has_cpp_attribute;
     EvaluateFeatureLikeBuiltinMacro(
         OS, Tok, II, *this, [&](Token &Tok, bool &HasLexedNextToken) -> int {
@@ -1732,8 +1740,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
                                    getLangOpts())
                     : 0;
         });
-  } else if (II == Ident__has_include ||
-             II == Ident__has_include_next) {
+  } else if (II == Ident__has_include || II == Ident__has_include_next) {
     // The argument to these two builtins should be a parenthesized
     // file name string literal using angle brackets (<>) or
     // double-quotes ("").

diff  --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index 42072fe63fc8..58bfb0870abf 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -2667,21 +2667,27 @@ void PragmaFloatControlHandler::HandlePragma(Preprocessor &PP,
 
   // Read the identifier.
   PP.Lex(Tok);
-  if (Tok.isNot(tok::identifier)) {
-    PP.Diag(Tok.getLocation(), diag::err_pragma_float_control_malformed);
-    return;
-  }
+  PragmaFloatControlKind Kind;
+  if (Tok.is(tok::kw_double)) {
+    Kind = PFC_Double;
+  } else {
+    if (Tok.isNot(tok::identifier)) {
+      PP.Diag(Tok.getLocation(), diag::err_pragma_float_control_malformed);
+      return;
+    }
 
-  // Verify that this is one of the float control options.
-  IdentifierInfo *II = Tok.getIdentifierInfo();
-  PragmaFloatControlKind Kind =
-      llvm::StringSwitch<PragmaFloatControlKind>(II->getName())
-          .Case("precise", PFC_Precise)
-          .Case("except", PFC_Except)
-          .Case("push", PFC_Push)
-          .Case("pop", PFC_Pop)
-          .Default(PFC_Unknown);
-  PP.Lex(Tok); // the identifier
+    // Verify that this is one of the float control options.
+    IdentifierInfo *II = Tok.getIdentifierInfo();
+    Kind = llvm::StringSwitch<PragmaFloatControlKind>(II->getName())
+               .Case("precise", PFC_Precise)
+               .Case("except", PFC_Except)
+               .Case("push", PFC_Push)
+               .Case("pop", PFC_Pop)
+               .Case("source", PFC_Source)
+               .Case("extended", PFC_Extended)
+               .Default(PFC_Unknown);
+  }
+  PP.Lex(Tok); // the first pragma token
   if (Kind == PFC_Unknown) {
     PP.Diag(Tok.getLocation(), diag::err_pragma_float_control_malformed);
     return;
@@ -2710,10 +2716,21 @@ void PragmaFloatControlHandler::HandlePragma(Preprocessor &PP,
         // Kind is set correctly
         ;
       else if (PushOnOff == "off") {
-        if (Kind == PFC_Precise)
+        switch (Kind) {
+        default:
+          break;
+        case PFC_Precise:
           Kind = PFC_NoPrecise;
-        if (Kind == PFC_Except)
+          break;
+        case PFC_Except:
           Kind = PFC_NoExcept;
+          break;
+        case PFC_Double:
+        case PFC_Extended:
+          // Reset eval mode to 'source'
+          Kind = PFC_Source;
+          break;
+        }
       } else if (PushOnOff == "push") {
         Action = Sema::PSK_Push_Set;
       } else {

diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 5d3de06e9576..d9761893ec59 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -234,6 +234,12 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
   SemaPPCallbackHandler = Callbacks.get();
   PP.addPPCallbacks(std::move(Callbacks));
   SemaPPCallbackHandler->set(*this);
+  if (getLangOpts().getFPEvalMethod() == LangOptions::FEM_TargetDefault)
+    // Use setting from TargetInfo.
+    PP.setCurrentFPEvalMethod(ctxt.getTargetInfo().getFPEvalMethod());
+  else
+    // Set initial value of __FLT_EVAL_METHOD__ from the command line.
+    PP.setCurrentFPEvalMethod(getLangOpts().getFPEvalMethod());
 }
 
 // Anchor Sema's type info to this TU.
@@ -2535,3 +2541,14 @@ const llvm::MapVector<FieldDecl *, Sema::DeleteLocs> &
 Sema::getMismatchingDeleteExpressions() const {
   return DeleteExprs;
 }
+
+Sema::FPFeaturesStateRAII::FPFeaturesStateRAII(Sema &S)
+    : S(S), OldFPFeaturesState(S.CurFPFeatures),
+      OldOverrides(S.FpPragmaStack.CurrentValue),
+      OldEvalMethod(S.PP.getCurrentFPEvalMethod()) {}
+
+Sema::FPFeaturesStateRAII::~FPFeaturesStateRAII() {
+  S.CurFPFeatures = OldFPFeaturesState;
+  S.FpPragmaStack.CurrentValue = OldOverrides;
+  S.PP.setCurrentFPEvalMethod(OldEvalMethod);
+}

diff  --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index 4a209166c4ff..b58c092f21e0 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -485,6 +485,21 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc,
   switch (Value) {
   default:
     llvm_unreachable("invalid pragma float_control kind");
+  case PFC_Source:
+    PP.setCurrentFPEvalMethod(LangOptions::FEM_Source);
+    NewFPFeatures.setFPEvalMethodOverride(LangOptions::FEM_Source);
+    FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
+    break;
+  case PFC_Double:
+    PP.setCurrentFPEvalMethod(LangOptions::FEM_Double);
+    NewFPFeatures.setFPEvalMethodOverride(LangOptions::FEM_Double);
+    FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
+    break;
+  case PFC_Extended:
+    PP.setCurrentFPEvalMethod(LangOptions::FEM_Extended);
+    NewFPFeatures.setFPEvalMethodOverride(LangOptions::FEM_Extended);
+    FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
+    break;
   case PFC_Precise:
     NewFPFeatures.setFPPreciseEnabled(true);
     FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 0e6c933cd4f3..a15d222377d6 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -772,6 +772,37 @@ ExprResult Sema::UsualUnaryConversions(Expr *E) {
   QualType Ty = E->getType();
   assert(!Ty.isNull() && "UsualUnaryConversions - missing type");
 
+  LangOptions::FPEvalMethodKind EvalMethod = CurFPFeatures.getFPEvalMethod();
+  if (EvalMethod != LangOptions::FEM_Source && Ty->isFloatingType()) {
+    switch (EvalMethod) {
+    default:
+      llvm_unreachable("Unrecognized float evaluation method");
+      break;
+    case LangOptions::FEM_TargetDefault:
+      // Float evaluation method not defined, use FEM_Source.
+      break;
+    case LangOptions::FEM_Double:
+      if (Context.getFloatingTypeOrder(Context.DoubleTy, Ty) > 0)
+        // Widen the expression to double.
+        return Ty->isComplexType()
+                   ? ImpCastExprToType(E,
+                                       Context.getComplexType(Context.DoubleTy),
+                                       CK_FloatingComplexCast)
+                   : ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast);
+      break;
+    case LangOptions::FEM_Extended:
+      if (Context.getFloatingTypeOrder(Context.LongDoubleTy, Ty) > 0)
+        // Widen the expression to long double.
+        return Ty->isComplexType()
+                   ? ImpCastExprToType(
+                         E, Context.getComplexType(Context.LongDoubleTy),
+                         CK_FloatingComplexCast)
+                   : ImpCastExprToType(E, Context.LongDoubleTy,
+                                       CK_FloatingCast);
+      break;
+    }
+  }
+
   // Half FP have to be promoted to float unless it is natively supported
   if (Ty->isHalfType() && !getLangOpts().NativeHalfType)
     return ImpCastExprToType(Res.get(), Context.FloatTy, CK_FloatingCast);

diff  --git a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
index ef29d24de1db..92a2378e59e2 100644
--- a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
@@ -1,7 +1,14 @@
 // RUN: %clang_cc1 -fexperimental-strict-floating-point -DEXCEPT=1 -fcxx-exceptions -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NS %s
-// RUN: %clang_cc1 -fexperimental-strict-floating-point -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DEFAULT
 // RUN: %clang_cc1 -fexperimental-strict-floating-point -DFENV_ON=1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-FENV %s
-// RUN: %clang_cc1 -fexperimental-strict-floating-point -triple %itanium_abi_triple -O3 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-O3 %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -DNF128 -triple %itanium_abi_triple -O3 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-O3 %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -triple x86_64-linux-gnu -emit-llvm -o - %s -ffp-eval-method=source | FileCheck %s -check-prefix=CHECK-SOURCE
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -triple x86_64-linux-gnu -emit-llvm -o - %s -ffp-eval-method=double | FileCheck %s -check-prefix=CHECK-DOUBLE
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -triple x86_64-linux-gnu -emit-llvm -o - %s -ffp-eval-method=extended -mlong-double-80 | FileCheck %s -check-prefix=CHECK-EXTENDED
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -triple i386-linux-gnu -emit-llvm -o - %s -ffp-eval-method=source | FileCheck %s -check-prefix=CHECK-SOURCE
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -triple i386-linux-gnu -emit-llvm -o - %s -ffp-eval-method=double | FileCheck %s -check-prefix=CHECK-DOUBLE
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -triple i386-linux-gnu -emit-llvm -o - %s -ffp-eval-method=extended -mlong-double-80 | FileCheck %s -check-prefix=CHECK-EXTENDED
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -DNF128 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-AIX
 
 // Verify float_control(precise, off) enables fast math flags on fp operations.
 float fp_precise_1(float a, float b, float c) {
@@ -229,3 +236,86 @@ float try_lam(float x, unsigned n) {
   result = x + t;
   return result;
 }
+
+float mySub(float x, float y) {
+  // CHECK: define {{.*}}float {{.*}}mySub{{.*}}
+  // CHECK-NS: fsub float
+  // CHECK-SOURCE: fsub float
+  // CHECK-DOUBLE: fpext float
+  // CHECK-DOUBLE: fpext float
+  // CHECK-DOUBLE: fsub double
+  // CHECK-DOUBLE: fptrunc double {{.*}} to float
+  // CHECK-EXTENDED: fpext float
+  // CHECK-EXTENDED: fpext float
+  // CHECK-EXTENDED: fsub double
+  // CHECK-EXTENDED: fptrunc double {{.*}} to float
+  return x - y;
+}
+
+float mySubSource(float x, float y) {
+// CHECK: define {{.*}}float {{.*}}mySubSource{{.*}}
+#pragma float_control(source)
+  return x - y;
+  // CHECK: fsub float
+}
+
+float mySubExtended(float x, float y) {
+// CHECK: define {{.*}}float {{.*}}mySubExtended{{.*}}
+#pragma float_control(extended)
+  return x - y;
+  // CHECK: fpext float
+  // CHECK: fpext float
+  // CHECK: fsub x86_fp80
+  // CHECK: fptrunc x86_fp80 {{.*}} to float
+}
+
+float mySubDouble(float x, float y) {
+// CHECK: define {{.*}}float {{.*}}mySubDouble{{.*}}
+#pragma float_control(double)
+  return x - y;
+  // CHECK: fpext float
+  // CHECK: fpext float
+  // CHECK: fsub double
+  // CHECK: fptrunc double {{.*}} to float
+}
+
+#ifndef NF128
+__float128 mySub128(__float128 x, __float128 y) {
+  // CHECK: define {{.*}}mySub128{{.*}}
+  // Expect no fpext since fp128 is already widest
+  // CHECK: load fp128
+  // CHECK-NEXT: load fp128
+  // CHECK-NEXT: fsub fp128
+  // CHECK-NEXT: ret fp128
+  return x - y;
+}
+#endif
+
+void mySubfp16(__fp16 *res, __fp16 *x, __fp16 *y) {
+  // CHECK: define {{.*}}mySubfp16{{.*}}
+  *res = *x - *y;
+  // CHECK: load half
+  // CHECK-NEXT: load half
+  // CHECK-NEXT: fpext half{{.*}}
+  // CHECK-NEXT: load half
+  // CHECK-NEXT: load half
+  // CHECK-NS: fpext half{{.*}} to float
+  // CHECK-DEFAULT: fpext half{{.*}} to float
+  // CHECK-DOUBLE: fpext half{{.*}} to double
+  // CHECK-EXTENDED: fpext half{{.*}} to x86_fp80
+  // CHECK-NEXT: fsub
+  // CHECK-NEXT: fptrunc {{.*}}to half
+  // CHECK-NS: fptrunc float {{.*}} to half
+  // CHECK-DOUBLE: fptrunc double {{.*}} to half
+  // CHECK-EXTENDED: fptrunc x86_fp80 {{.*}} to half
+}
+
+int getFEM() {
+  // CHECK: define {{.*}}getFEM{{.*}}
+  return __FLT_EVAL_METHOD__;
+  // CHECK-NS: ret {{.*}} 0
+  // CHECK-AIX: ret {{.*}} 1
+  // CHECK-SOURCE: ret {{.*}} 0
+  // CHECK-DOUBLE: ret {{.*}} 1
+  // CHECK-EXTENDED: ret {{.*}} 2
+}

diff  --git a/clang/test/Preprocessor/init-aarch64.c b/clang/test/Preprocessor/init-aarch64.c
index 3b6f4ddaabde..b38319c9b2ff 100644
--- a/clang/test/Preprocessor/init-aarch64.c
+++ b/clang/test/Preprocessor/init-aarch64.c
@@ -91,7 +91,6 @@
 // AARCH64-NEXT: #define __FLT_DENORM_MIN__ 1.40129846e-45F
 // AARCH64-NEXT: #define __FLT_DIG__ 6
 // AARCH64-NEXT: #define __FLT_EPSILON__ 1.19209290e-7F
-// AARCH64-NEXT: #define __FLT_EVAL_METHOD__ 0
 // AARCH64-NEXT: #define __FLT_HAS_DENORM__ 1
 // AARCH64-NEXT: #define __FLT_HAS_INFINITY__ 1
 // AARCH64-NEXT: #define __FLT_HAS_QUIET_NAN__ 1
@@ -373,7 +372,6 @@
 // AARCH64-DARWIN: #define __FLT_DENORM_MIN__ 1.40129846e-45F
 // AARCH64-DARWIN: #define __FLT_DIG__ 6
 // AARCH64-DARWIN: #define __FLT_EPSILON__ 1.19209290e-7F
-// AARCH64-DARWIN: #define __FLT_EVAL_METHOD__ 0
 // AARCH64-DARWIN: #define __FLT_HAS_DENORM__ 1
 // AARCH64-DARWIN: #define __FLT_HAS_INFINITY__ 1
 // AARCH64-DARWIN: #define __FLT_HAS_QUIET_NAN__ 1
@@ -589,7 +587,6 @@
 // AARCH64-MSVC: #define __FLT_DENORM_MIN__ 1.40129846e-45F
 // AARCH64-MSVC: #define __FLT_DIG__ 6
 // AARCH64-MSVC: #define __FLT_EPSILON__ 1.19209290e-7F
-// AARCH64-MSVC: #define __FLT_EVAL_METHOD__ 0
 // AARCH64-MSVC: #define __FLT_HAS_DENORM__ 1
 // AARCH64-MSVC: #define __FLT_HAS_INFINITY__ 1
 // AARCH64-MSVC: #define __FLT_HAS_QUIET_NAN__ 1

diff  --git a/clang/test/Preprocessor/init-arm.c b/clang/test/Preprocessor/init-arm.c
index 32eb2c513f8b..2d1503c18560 100644
--- a/clang/test/Preprocessor/init-arm.c
+++ b/clang/test/Preprocessor/init-arm.c
@@ -35,7 +35,6 @@
 // ARM:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // ARM:#define __FLT_DIG__ 6
 // ARM:#define __FLT_EPSILON__ 1.19209290e-7F
-// ARM:#define __FLT_EVAL_METHOD__ 0
 // ARM:#define __FLT_HAS_DENORM__ 1
 // ARM:#define __FLT_HAS_INFINITY__ 1
 // ARM:#define __FLT_HAS_QUIET_NAN__ 1
@@ -235,7 +234,6 @@
 // ARM-BE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // ARM-BE:#define __FLT_DIG__ 6
 // ARM-BE:#define __FLT_EPSILON__ 1.19209290e-7F
-// ARM-BE:#define __FLT_EVAL_METHOD__ 0
 // ARM-BE:#define __FLT_HAS_DENORM__ 1
 // ARM-BE:#define __FLT_HAS_INFINITY__ 1
 // ARM-BE:#define __FLT_HAS_QUIET_NAN__ 1
@@ -428,7 +426,6 @@
 // ARMEABISOFTFP:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // ARMEABISOFTFP:#define __FLT_DIG__ 6
 // ARMEABISOFTFP:#define __FLT_EPSILON__ 1.19209290e-7F
-// ARMEABISOFTFP:#define __FLT_EVAL_METHOD__ 0
 // ARMEABISOFTFP:#define __FLT_HAS_DENORM__ 1
 // ARMEABISOFTFP:#define __FLT_HAS_INFINITY__ 1
 // ARMEABISOFTFP:#define __FLT_HAS_QUIET_NAN__ 1
@@ -623,7 +620,6 @@
 // ARMEABIHARDFP:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // ARMEABIHARDFP:#define __FLT_DIG__ 6
 // ARMEABIHARDFP:#define __FLT_EPSILON__ 1.19209290e-7F
-// ARMEABIHARDFP:#define __FLT_EVAL_METHOD__ 0
 // ARMEABIHARDFP:#define __FLT_HAS_DENORM__ 1
 // ARMEABIHARDFP:#define __FLT_HAS_INFINITY__ 1
 // ARMEABIHARDFP:#define __FLT_HAS_QUIET_NAN__ 1
@@ -821,7 +817,6 @@
 // ARM-NETBSD:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // ARM-NETBSD:#define __FLT_DIG__ 6
 // ARM-NETBSD:#define __FLT_EPSILON__ 1.19209290e-7F
-// ARM-NETBSD:#define __FLT_EVAL_METHOD__ 0
 // ARM-NETBSD:#define __FLT_HAS_DENORM__ 1
 // ARM-NETBSD:#define __FLT_HAS_INFINITY__ 1
 // ARM-NETBSD:#define __FLT_HAS_QUIET_NAN__ 1

diff  --git a/clang/test/Preprocessor/init-mips.c b/clang/test/Preprocessor/init-mips.c
index d76396aa35c9..a07cee64e684 100644
--- a/clang/test/Preprocessor/init-mips.c
+++ b/clang/test/Preprocessor/init-mips.c
@@ -37,7 +37,6 @@
 // MIPS32BE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // MIPS32BE:#define __FLT_DIG__ 6
 // MIPS32BE:#define __FLT_EPSILON__ 1.19209290e-7F
-// MIPS32BE:#define __FLT_EVAL_METHOD__ 0
 // MIPS32BE:#define __FLT_HAS_DENORM__ 1
 // MIPS32BE:#define __FLT_HAS_INFINITY__ 1
 // MIPS32BE:#define __FLT_HAS_QUIET_NAN__ 1
@@ -247,7 +246,6 @@
 // MIPS32EL:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // MIPS32EL:#define __FLT_DIG__ 6
 // MIPS32EL:#define __FLT_EPSILON__ 1.19209290e-7F
-// MIPS32EL:#define __FLT_EVAL_METHOD__ 0
 // MIPS32EL:#define __FLT_HAS_DENORM__ 1
 // MIPS32EL:#define __FLT_HAS_INFINITY__ 1
 // MIPS32EL:#define __FLT_HAS_QUIET_NAN__ 1
@@ -467,7 +465,6 @@
 // MIPSN32BE: #define __FLT_DENORM_MIN__ 1.40129846e-45F
 // MIPSN32BE: #define __FLT_DIG__ 6
 // MIPSN32BE: #define __FLT_EPSILON__ 1.19209290e-7F
-// MIPSN32BE: #define __FLT_EVAL_METHOD__ 0
 // MIPSN32BE: #define __FLT_HAS_DENORM__ 1
 // MIPSN32BE: #define __FLT_HAS_INFINITY__ 1
 // MIPSN32BE: #define __FLT_HAS_QUIET_NAN__ 1
@@ -774,7 +771,6 @@
 // MIPSN32EL: #define __FLT_DENORM_MIN__ 1.40129846e-45F
 // MIPSN32EL: #define __FLT_DIG__ 6
 // MIPSN32EL: #define __FLT_EPSILON__ 1.19209290e-7F
-// MIPSN32EL: #define __FLT_EVAL_METHOD__ 0
 // MIPSN32EL: #define __FLT_HAS_DENORM__ 1
 // MIPSN32EL: #define __FLT_HAS_INFINITY__ 1
 // MIPSN32EL: #define __FLT_HAS_QUIET_NAN__ 1
@@ -1074,7 +1070,6 @@
 // MIPS64BE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // MIPS64BE:#define __FLT_DIG__ 6
 // MIPS64BE:#define __FLT_EPSILON__ 1.19209290e-7F
-// MIPS64BE:#define __FLT_EVAL_METHOD__ 0
 // MIPS64BE:#define __FLT_HAS_DENORM__ 1
 // MIPS64BE:#define __FLT_HAS_INFINITY__ 1
 // MIPS64BE:#define __FLT_HAS_QUIET_NAN__ 1
@@ -1284,7 +1279,6 @@
 // MIPS64EL:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // MIPS64EL:#define __FLT_DIG__ 6
 // MIPS64EL:#define __FLT_EPSILON__ 1.19209290e-7F
-// MIPS64EL:#define __FLT_EVAL_METHOD__ 0
 // MIPS64EL:#define __FLT_HAS_DENORM__ 1
 // MIPS64EL:#define __FLT_HAS_INFINITY__ 1
 // MIPS64EL:#define __FLT_HAS_QUIET_NAN__ 1

diff  --git a/clang/test/Preprocessor/init-ppc.c b/clang/test/Preprocessor/init-ppc.c
index cbcd10fa1ae5..6ebc80717dbc 100644
--- a/clang/test/Preprocessor/init-ppc.c
+++ b/clang/test/Preprocessor/init-ppc.c
@@ -30,7 +30,6 @@
 // PPC603E:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // PPC603E:#define __FLT_DIG__ 6
 // PPC603E:#define __FLT_EPSILON__ 1.19209290e-7F
-// PPC603E:#define __FLT_EVAL_METHOD__ 0
 // PPC603E:#define __FLT_HAS_DENORM__ 1
 // PPC603E:#define __FLT_HAS_INFINITY__ 1
 // PPC603E:#define __FLT_HAS_QUIET_NAN__ 1
@@ -224,7 +223,6 @@
 // PPC:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // PPC:#define __FLT_DIG__ 6
 // PPC:#define __FLT_EPSILON__ 1.19209290e-7F
-// PPC:#define __FLT_EVAL_METHOD__ 0
 // PPC:#define __FLT_HAS_DENORM__ 1
 // PPC:#define __FLT_HAS_INFINITY__ 1
 // PPC:#define __FLT_HAS_QUIET_NAN__ 1
@@ -422,7 +420,6 @@
 // PPC-AIX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // PPC-AIX:#define __FLT_DIG__ 6
 // PPC-AIX:#define __FLT_EPSILON__ 1.19209290e-7F
-// PPC-AIX:#define __FLT_EVAL_METHOD__ 1
 // PPC-AIX:#define __FLT_HAS_DENORM__ 1
 // PPC-AIX:#define __FLT_HAS_INFINITY__ 1
 // PPC-AIX:#define __FLT_HAS_QUIET_NAN__ 1
@@ -790,7 +787,6 @@
 // PPC-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // PPC-LINUX:#define __FLT_DIG__ 6
 // PPC-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F
-// PPC-LINUX:#define __FLT_EVAL_METHOD__ 0
 // PPC-LINUX:#define __FLT_HAS_DENORM__ 1
 // PPC-LINUX:#define __FLT_HAS_INFINITY__ 1
 // PPC-LINUX:#define __FLT_HAS_QUIET_NAN__ 1
@@ -998,7 +994,6 @@
 // PPC-DARWIN:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // PPC-DARWIN:#define __FLT_DIG__ 6
 // PPC-DARWIN:#define __FLT_EPSILON__ 1.19209290e-7F
-// PPC-DARWIN:#define __FLT_EVAL_METHOD__ 0
 // PPC-DARWIN:#define __FLT_HAS_DENORM__ 1
 // PPC-DARWIN:#define __FLT_HAS_INFINITY__ 1
 // PPC-DARWIN:#define __FLT_HAS_QUIET_NAN__ 1

diff  --git a/clang/test/Preprocessor/init-ppc64.c b/clang/test/Preprocessor/init-ppc64.c
index 6aed0e7daa96..45a43b6328d9 100644
--- a/clang/test/Preprocessor/init-ppc64.c
+++ b/clang/test/Preprocessor/init-ppc64.c
@@ -35,7 +35,6 @@
 // PPC64:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // PPC64:#define __FLT_DIG__ 6
 // PPC64:#define __FLT_EPSILON__ 1.19209290e-7F
-// PPC64:#define __FLT_EVAL_METHOD__ 0
 // PPC64:#define __FLT_HAS_DENORM__ 1
 // PPC64:#define __FLT_HAS_INFINITY__ 1
 // PPC64:#define __FLT_HAS_QUIET_NAN__ 1
@@ -240,7 +239,6 @@
 // PPC64LE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // PPC64LE:#define __FLT_DIG__ 6
 // PPC64LE:#define __FLT_EPSILON__ 1.19209290e-7F
-// PPC64LE:#define __FLT_EVAL_METHOD__ 0
 // PPC64LE:#define __FLT_HAS_DENORM__ 1
 // PPC64LE:#define __FLT_HAS_INFINITY__ 1
 // PPC64LE:#define __FLT_HAS_QUIET_NAN__ 1
@@ -714,7 +712,6 @@
 // PPC64-AIX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // PPC64-AIX:#define __FLT_DIG__ 6
 // PPC64-AIX:#define __FLT_EPSILON__ 1.19209290e-7F
-// PPC64-AIX:#define __FLT_EVAL_METHOD__ 1
 // PPC64-AIX:#define __FLT_HAS_DENORM__ 1
 // PPC64-AIX:#define __FLT_HAS_INFINITY__ 1
 // PPC64-AIX:#define __FLT_HAS_QUIET_NAN__ 1
@@ -912,7 +909,6 @@
 // PPC64-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // PPC64-LINUX:#define __FLT_DIG__ 6
 // PPC64-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F
-// PPC64-LINUX:#define __FLT_EVAL_METHOD__ 0
 // PPC64-LINUX:#define __FLT_HAS_DENORM__ 1
 // PPC64-LINUX:#define __FLT_HAS_INFINITY__ 1
 // PPC64-LINUX:#define __FLT_HAS_QUIET_NAN__ 1

diff  --git a/clang/test/Preprocessor/init-s390x.c b/clang/test/Preprocessor/init-s390x.c
index b0e45b5348ce..6c646527f50f 100644
--- a/clang/test/Preprocessor/init-s390x.c
+++ b/clang/test/Preprocessor/init-s390x.c
@@ -23,7 +23,6 @@
 // S390X:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // S390X:#define __FLT_DIG__ 6
 // S390X:#define __FLT_EPSILON__ 1.19209290e-7F
-// S390X:#define __FLT_EVAL_METHOD__ 0
 // S390X:#define __FLT_HAS_DENORM__ 1
 // S390X:#define __FLT_HAS_INFINITY__ 1
 // S390X:#define __FLT_HAS_QUIET_NAN__ 1

diff  --git a/clang/test/Preprocessor/init-v7k-compat.c b/clang/test/Preprocessor/init-v7k-compat.c
index 482c7ad6ff68..ff5d4bbdea53 100644
--- a/clang/test/Preprocessor/init-v7k-compat.c
+++ b/clang/test/Preprocessor/init-v7k-compat.c
@@ -28,7 +28,6 @@
 // CHECK: #define __FLT_DENORM_MIN__ 1.40129846e-45F
 // CHECK: #define __FLT_DIG__ 6
 // CHECK: #define __FLT_EPSILON__ 1.19209290e-7F
-// CHECK: #define __FLT_EVAL_METHOD__ 0
 // CHECK: #define __FLT_HAS_DENORM__ 1
 // CHECK: #define __FLT_HAS_INFINITY__ 1
 // CHECK: #define __FLT_HAS_QUIET_NAN__ 1

diff  --git a/clang/test/Preprocessor/init-x86.c b/clang/test/Preprocessor/init-x86.c
index 527cd3950888..287de8d90937 100644
--- a/clang/test/Preprocessor/init-x86.c
+++ b/clang/test/Preprocessor/init-x86.c
@@ -24,7 +24,6 @@
 // I386:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // I386:#define __FLT_DIG__ 6
 // I386:#define __FLT_EPSILON__ 1.19209290e-7F
-// I386:#define __FLT_EVAL_METHOD__ 2
 // I386:#define __FLT_HAS_DENORM__ 1
 // I386:#define __FLT_HAS_INFINITY__ 1
 // I386:#define __FLT_HAS_QUIET_NAN__ 1
@@ -213,7 +212,6 @@
 // I386-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // I386-LINUX:#define __FLT_DIG__ 6
 // I386-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F
-// I386-LINUX:#define __FLT_EVAL_METHOD__ 0
 // I386-LINUX:#define __FLT_HAS_DENORM__ 1
 // I386-LINUX:#define __FLT_HAS_INFINITY__ 1
 // I386-LINUX:#define __FLT_HAS_QUIET_NAN__ 1
@@ -416,7 +414,6 @@
 // I386-NETBSD:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // I386-NETBSD:#define __FLT_DIG__ 6
 // I386-NETBSD:#define __FLT_EPSILON__ 1.19209290e-7F
-// I386-NETBSD:#define __FLT_EVAL_METHOD__ 2
 // I386-NETBSD:#define __FLT_HAS_DENORM__ 1
 // I386-NETBSD:#define __FLT_HAS_INFINITY__ 1
 // I386-NETBSD:#define __FLT_HAS_QUIET_NAN__ 1
@@ -590,12 +587,6 @@
 // I386-NETBSD:#define __i386__ 1
 // I386-NETBSD:#define i386 1
 
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-netbsd -target-feature +sse2 < /dev/null | FileCheck -match-full-lines -check-prefix I386-NETBSD-SSE %s
-// I386-NETBSD-SSE:#define __FLT_EVAL_METHOD__ 0
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-netbsd6  < /dev/null | FileCheck -match-full-lines -check-prefix I386-NETBSD6 %s
-// I386-NETBSD6:#define __FLT_EVAL_METHOD__ 1
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-netbsd6 -target-feature +sse2 < /dev/null | FileCheck -match-full-lines -check-prefix I386-NETBSD6-SSE %s
-// I386-NETBSD6-SSE:#define __FLT_EVAL_METHOD__ 1
 
 // RUN: %clang_cc1 -E -dM -triple=i686-pc-mingw32 < /dev/null | FileCheck -match-full-lines -check-prefix I386-DECLSPEC %s
 // RUN: %clang_cc1 -E -dM -fms-extensions -triple=i686-pc-mingw32 < /dev/null | FileCheck -match-full-lines -check-prefix I386-DECLSPEC %s
@@ -631,7 +622,6 @@
 // X86_64:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // X86_64:#define __FLT_DIG__ 6
 // X86_64:#define __FLT_EPSILON__ 1.19209290e-7F
-// X86_64:#define __FLT_EVAL_METHOD__ 0
 // X86_64:#define __FLT_HAS_DENORM__ 1
 // X86_64:#define __FLT_HAS_INFINITY__ 1
 // X86_64:#define __FLT_HAS_QUIET_NAN__ 1
@@ -839,7 +829,6 @@
 // X32:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // X32:#define __FLT_DIG__ 6
 // X32:#define __FLT_EPSILON__ 1.19209290e-7F
-// X32:#define __FLT_EVAL_METHOD__ 0
 // X32:#define __FLT_HAS_DENORM__ 1
 // X32:#define __FLT_HAS_INFINITY__ 1
 // X32:#define __FLT_HAS_QUIET_NAN__ 1
@@ -1046,7 +1035,6 @@
 // X86_64-CLOUDABI:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // X86_64-CLOUDABI:#define __FLT_DIG__ 6
 // X86_64-CLOUDABI:#define __FLT_EPSILON__ 1.19209290e-7F
-// X86_64-CLOUDABI:#define __FLT_EVAL_METHOD__ 0
 // X86_64-CLOUDABI:#define __FLT_HAS_DENORM__ 1
 // X86_64-CLOUDABI:#define __FLT_HAS_INFINITY__ 1
 // X86_64-CLOUDABI:#define __FLT_HAS_QUIET_NAN__ 1
@@ -1341,7 +1329,6 @@
 // X86_64-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // X86_64-LINUX:#define __FLT_DIG__ 6
 // X86_64-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F
-// X86_64-LINUX:#define __FLT_EVAL_METHOD__ 0
 // X86_64-LINUX:#define __FLT_HAS_DENORM__ 1
 // X86_64-LINUX:#define __FLT_HAS_INFINITY__ 1
 // X86_64-LINUX:#define __FLT_HAS_QUIET_NAN__ 1
@@ -1554,7 +1541,6 @@
 // X86_64-NETBSD:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // X86_64-NETBSD:#define __FLT_DIG__ 6
 // X86_64-NETBSD:#define __FLT_EPSILON__ 1.19209290e-7F
-// X86_64-NETBSD:#define __FLT_EVAL_METHOD__ 0
 // X86_64-NETBSD:#define __FLT_HAS_DENORM__ 1
 // X86_64-NETBSD:#define __FLT_HAS_INFINITY__ 1
 // X86_64-NETBSD:#define __FLT_HAS_QUIET_NAN__ 1

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 20ab2c05596b..65d737352cad 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -323,7 +323,6 @@
 // MSP430:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // MSP430:#define __FLT_DIG__ 6
 // MSP430:#define __FLT_EPSILON__ 1.19209290e-7F
-// MSP430:#define __FLT_EVAL_METHOD__ 0
 // MSP430:#define __FLT_HAS_DENORM__ 1
 // MSP430:#define __FLT_HAS_INFINITY__ 1
 // MSP430:#define __FLT_HAS_QUIET_NAN__ 1
@@ -511,7 +510,6 @@
 // NVPTX32:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // NVPTX32:#define __FLT_DIG__ 6
 // NVPTX32:#define __FLT_EPSILON__ 1.19209290e-7F
-// NVPTX32:#define __FLT_EVAL_METHOD__ 0
 // NVPTX32:#define __FLT_HAS_DENORM__ 1
 // NVPTX32:#define __FLT_HAS_INFINITY__ 1
 // NVPTX32:#define __FLT_HAS_QUIET_NAN__ 1
@@ -700,7 +698,6 @@
 // NVPTX64:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // NVPTX64:#define __FLT_DIG__ 6
 // NVPTX64:#define __FLT_EPSILON__ 1.19209290e-7F
-// NVPTX64:#define __FLT_EVAL_METHOD__ 0
 // NVPTX64:#define __FLT_HAS_DENORM__ 1
 // NVPTX64:#define __FLT_HAS_INFINITY__ 1
 // NVPTX64:#define __FLT_HAS_QUIET_NAN__ 1
@@ -904,7 +901,6 @@
 // SPARC:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // SPARC:#define __FLT_DIG__ 6
 // SPARC:#define __FLT_EPSILON__ 1.19209290e-7F
-// SPARC:#define __FLT_EVAL_METHOD__ 0
 // SPARC:#define __FLT_HAS_DENORM__ 1
 // SPARC:#define __FLT_HAS_INFINITY__ 1
 // SPARC:#define __FLT_HAS_QUIET_NAN__ 1
@@ -1105,7 +1101,6 @@
 // TCE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // TCE:#define __FLT_DIG__ 6
 // TCE:#define __FLT_EPSILON__ 1.19209290e-7F
-// TCE:#define __FLT_EVAL_METHOD__ 0
 // TCE:#define __FLT_HAS_DENORM__ 1
 // TCE:#define __FLT_HAS_INFINITY__ 1
 // TCE:#define __FLT_HAS_QUIET_NAN__ 1
@@ -1272,7 +1267,6 @@
 // PS4:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // PS4:#define __FLT_DIG__ 6
 // PS4:#define __FLT_EPSILON__ 1.19209290e-7F
-// PS4:#define __FLT_EVAL_METHOD__ 0
 // PS4:#define __FLT_HAS_DENORM__ 1
 // PS4:#define __FLT_HAS_INFINITY__ 1
 // PS4:#define __FLT_HAS_QUIET_NAN__ 1
@@ -1564,7 +1558,6 @@
 // WEBASSEMBLY-NEXT:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // WEBASSEMBLY-NEXT:#define __FLT_DIG__ 6
 // WEBASSEMBLY-NEXT:#define __FLT_EPSILON__ 1.19209290e-7F
-// WEBASSEMBLY-NEXT:#define __FLT_EVAL_METHOD__ 0
 // WEBASSEMBLY-NEXT:#define __FLT_HAS_DENORM__ 1
 // WEBASSEMBLY-NEXT:#define __FLT_HAS_INFINITY__ 1
 // WEBASSEMBLY-NEXT:#define __FLT_HAS_QUIET_NAN__ 1
@@ -1916,7 +1909,6 @@
 // AVR:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // AVR:#define __FLT_DIG__ 6
 // AVR:#define __FLT_EPSILON__ 1.19209290e-7F
-// AVR:#define __FLT_EVAL_METHOD__ 0
 // AVR:#define __FLT_HAS_DENORM__ 1
 // AVR:#define __FLT_HAS_INFINITY__ 1
 // AVR:#define __FLT_HAS_QUIET_NAN__ 1
@@ -2199,7 +2191,6 @@
 // RISCV32: #define __FLT_DENORM_MIN__ 1.40129846e-45F
 // RISCV32: #define __FLT_DIG__ 6
 // RISCV32: #define __FLT_EPSILON__ 1.19209290e-7F
-// RISCV32: #define __FLT_EVAL_METHOD__ 0
 // RISCV32: #define __FLT_HAS_DENORM__ 1
 // RISCV32: #define __FLT_HAS_INFINITY__ 1
 // RISCV32: #define __FLT_HAS_QUIET_NAN__ 1
@@ -2407,7 +2398,6 @@
 // RISCV64: #define __FLT_DENORM_MIN__ 1.40129846e-45F
 // RISCV64: #define __FLT_DIG__ 6
 // RISCV64: #define __FLT_EPSILON__ 1.19209290e-7F
-// RISCV64: #define __FLT_EVAL_METHOD__ 0
 // RISCV64: #define __FLT_HAS_DENORM__ 1
 // RISCV64: #define __FLT_HAS_INFINITY__ 1
 // RISCV64: #define __FLT_HAS_QUIET_NAN__ 1


        


More information about the cfe-commits mailing list