Index: include/llvm/CodeGen/CommandFlags.h =================================================================== --- include/llvm/CodeGen/CommandFlags.h +++ include/llvm/CodeGen/CommandFlags.h @@ -130,6 +130,23 @@ cl::desc("Force codegen to assume rounding mode can change dynamically"), cl::init(false)); +cl::opt +EnableFEnvAccessFPMath("enable-fenv-access-fp-math", + cl::desc("Disable optimizations that assume the default floating-point " + "environment or might change observable floating-point exceptions"), + cl::init(false)); + +cl::opt +EnableExceptAccessFPMath("enable-except-access-fp-math", + cl::desc("Disable FP math optimizations that affect FP exceptions"), + cl::init(false)); + +cl::opt +EnableControlAccessFPMath("enable-control-access-fp-math", + cl::desc("Disable optimizations that assume the default floating-point " + "environment, including rounding-mode"), + cl::init(false)); + cl::opt FloatABIForCalls("float-abi", cl::desc("Choose float ABI type"), @@ -268,6 +285,10 @@ Options.NoNaNsFPMath = EnableNoNaNsFPMath; Options.HonorSignDependentRoundingFPMathOption = EnableHonorSignDependentRoundingFPMath; + Options.AllowFPExceptAccess = EnableExceptAccessFPMath | + EnableFEnvAccessFPMath; + Options.AllowFPRoundAccess = EnableControlAccessFPMath | + EnableFEnvAccessFPMath; if (FloatABIForCalls != FloatABI::Default) Options.FloatABIType = FloatABIForCalls; Options.NoZerosInBSS = DontPlaceZerosInBSS; Index: include/llvm/Target/TargetOptions.h =================================================================== --- include/llvm/Target/TargetOptions.h +++ include/llvm/Target/TargetOptions.h @@ -71,6 +71,7 @@ TargetOptions() : PrintMachineCode(false), LessPreciseFPMADOption(false), UnsafeFPMath(false), NoInfsFPMath(false), NoNaNsFPMath(false), + AllowFPExceptAccess(false), AllowFPRoundAccess(false), HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false), GuaranteedTailCallOpt(false), StackAlignmentOverride(0), EnableFastISel(false), PositionIndependentExecutable(false), @@ -119,6 +120,20 @@ /// assume the FP arithmetic arguments and results are never NaNs. unsigned NoNaNsFPMath : 1; + /// AllowFPExceptAccess - This flag is enabled when the + /// -enable-except-access-fp-math or -enable-fenv-access-fp-math flag is + /// specified on the command line. When this flag is off (the default), the + /// code generator is allowed to assume the exceptions part of + /// floating-point environment is not accessed by the program. + unsigned AllowFPExceptAccess : 1; + + /// AllowFPRoundAccess - This flag is enabled when the + /// -enable-control-access-fp-math or -enable-fenv-access-fp-math flag is + /// specified on the command line. When this flag is off (the default), the + /// code generator is allowed to assume the rounding part of floating-point + /// environment is not accessed by the program. + unsigned AllowFPRoundAccess : 1; + /// HonorSignDependentRoundingFPMath - This returns true when the /// -enable-sign-dependent-rounding-fp-math is specified. If this returns /// false (the default), the code generator is allowed to assume that the