From 80235d508e5f7a9603ef43ba6625984173ff0323 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Tue, 23 May 2006 18:18:46 +0000 Subject: [PATCH] -enable-unsafe-fp-math implies -enable-finite-only-fp-math git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28437 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetOptions.h | 11 ++++++----- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 3 +-- lib/Target/TargetMachine.cpp | 12 ++++++++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/llvm/Target/TargetOptions.h b/include/llvm/Target/TargetOptions.h index 2131ecaf3d8..ea391b77bb6 100644 --- a/include/llvm/Target/TargetOptions.h +++ b/include/llvm/Target/TargetOptions.h @@ -39,14 +39,15 @@ namespace llvm { /// this flag is off (the default), the code generator is not allowed to /// produce results that are "less precise" than IEEE allows. This includes /// use of X86 instructions like FSIN and FCOS instead of libcalls. + /// UnsafeFPMath implies FiniteOnlyFPMath. extern bool UnsafeFPMath; - /// FiniteOnlyFPMath - This is enabled when the -enable-finite-only-fp-math - /// flag is specified on the command line. When this flag is off (default), + /// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math + /// option is specified on the command line. If this returns false (default), /// the code generator is not allowed to assume that FP arithmetic arguments - /// and results are never NaNs or +-Infs. This includes ignoring parity flag - /// (PF) when checking for FP equality. - extern bool FiniteOnlyFPMath; + /// and results are never NaNs or +-Infs. + extern bool FiniteOnlyFPMathOption; + extern bool FiniteOnlyFPMath(); } // End llvm namespace #endif diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 2e1f872c8a9..cae696354fd 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -1105,8 +1105,7 @@ void SelectionDAGLowering::visitSetCC(User &I,ISD::CondCode SignedOpcode, SDOperand Op1 = getValue(I.getOperand(0)); SDOperand Op2 = getValue(I.getOperand(1)); ISD::CondCode Opcode = SignedOpcode; - if ((!UnsafeFPMath && !FiniteOnlyFPMath) && - I.getOperand(0)->getType()->isFloatingPoint()) + if (!FiniteOnlyFPMath() && I.getOperand(0)->getType()->isFloatingPoint()) Opcode = FPOpcode; else if (I.getOperand(0)->getType()->isUnsigned()) Opcode = UnsignedOpcode; diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp index 28f3ae88a72..bf70d12a6b8 100644 --- a/lib/Target/TargetMachine.cpp +++ b/lib/Target/TargetMachine.cpp @@ -26,7 +26,7 @@ namespace llvm { bool NoFramePointerElim; bool NoExcessFPPrecision; bool UnsafeFPMath; - bool FiniteOnlyFPMath; + bool FiniteOnlyFPMathOption; Reloc::Model RelocationModel; }; namespace { @@ -52,7 +52,7 @@ namespace { cl::opt EnableFiniteOnltFPMath("enable-finite-only-fp-math", cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"), - cl::location(FiniteOnlyFPMath), + cl::location(FiniteOnlyFPMathOption), cl::init(false)); cl::opt DefRelocationModel( @@ -93,3 +93,11 @@ Reloc::Model TargetMachine::getRelocationModel() { void TargetMachine::setRelocationModel(Reloc::Model Model) { RelocationModel = Model; } + +namespace llvm { + /// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math + /// option is specified on the command line. If this returns false (default), + /// the code generator is not allowed to assume that FP arithmetic arguments + /// and results are never NaNs or +-Infs. + bool FiniteOnlyFPMath() { return UnsafeFPMath || FiniteOnlyFPMathOption; } +}; -- 2.34.1