Skip to content

Commit bf1e013

Browse files
author
Andy Kaylor
committed
Update FP option rendering to leave denormal-fp-math alone
1 parent 8ab931c commit bf1e013

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,13 +2743,11 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
27432743
StringRef FPExceptionBehavior = "";
27442744
// -ffp-eval-method options: double, extended, source
27452745
StringRef FPEvalMethod = "";
2746-
const llvm::DenormalMode DefaultDenormalFPMath =
2746+
llvm::DenormalMode DenormalFPMath =
27472747
TC.getDefaultDenormalModeForType(Args, JA);
2748-
const llvm::DenormalMode DefaultDenormalFP32Math =
2748+
llvm::DenormalMode DenormalFP32Math =
27492749
TC.getDefaultDenormalModeForType(Args, JA, &llvm::APFloat::IEEEsingle());
27502750

2751-
llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
2752-
llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
27532751
// CUDA and HIP don't rely on the frontend to pass an ffp-contract option.
27542752
// If one wasn't given by the user, don't pass it here.
27552753
StringRef FPContract;
@@ -2899,11 +2897,6 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
28992897
SignedZeros = true;
29002898
// -fno_fast_math restores default denormal and fpcontract handling
29012899
FPContract = "on";
2902-
DenormalFPMath = llvm::DenormalMode::getIEEE();
2903-
2904-
// FIXME: The target may have picked a non-IEEE default mode here based on
2905-
// -cl-denorms-are-zero. Should the target consider -fp-model interaction?
2906-
DenormalFP32Math = llvm::DenormalMode::getIEEE();
29072900

29082901
StringRef Val = A->getValue();
29092902
if (OFastEnabled && !Val.equals("fast")) {
@@ -2924,10 +2917,6 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
29242917
if (Val.equals("fast")) {
29252918
FPModel = Val;
29262919
applyFastMath();
2927-
// The target-specific getDefaultDenormalModeForType handler should
2928-
// account for -ffp-model=fast and choose its behavior
2929-
DenormalFPMath = DefaultDenormalFPMath;
2930-
DenormalFP32Math = DefaultDenormalFP32Math;
29312920
} else if (Val.equals("precise")) {
29322921
optID = options::OPT_ffp_contract;
29332922
FPModel = Val;
@@ -3126,9 +3115,6 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
31263115
TrappingMath = true;
31273116
FPExceptionBehavior = "strict";
31283117

3129-
// The target may have opted to flush by default, so force IEEE.
3130-
DenormalFPMath = llvm::DenormalMode::getIEEE();
3131-
DenormalFP32Math = llvm::DenormalMode::getIEEE();
31323118
if (!JA.isDeviceOffloading(Action::OFK_Cuda) &&
31333119
!JA.isOffloading(Action::OFK_HIP)) {
31343120
if (LastSeenFfpContractOption != "") {
@@ -3158,9 +3144,7 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
31583144
ReciprocalMath = false;
31593145
ApproxFunc = false;
31603146
SignedZeros = true;
3161-
// -fno_fast_math restores default denormal and fpcontract handling
3162-
DenormalFPMath = DefaultDenormalFPMath;
3163-
DenormalFP32Math = llvm::DenormalMode::getIEEE();
3147+
// -fno_fast_math restores default fpcontract handling
31643148
if (!JA.isDeviceOffloading(Action::OFK_Cuda) &&
31653149
!JA.isOffloading(Action::OFK_HIP)) {
31663150
if (LastSeenFfpContractOption != "") {
@@ -3175,8 +3159,6 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
31753159
// subsequent options conflict then emit warning diagnostic.
31763160
if (HonorINFs && HonorNaNs && !AssociativeMath && !ReciprocalMath &&
31773161
SignedZeros && TrappingMath && RoundingFPMath && !ApproxFunc &&
3178-
DenormalFPMath == llvm::DenormalMode::getIEEE() &&
3179-
DenormalFP32Math == llvm::DenormalMode::getIEEE() &&
31803162
FPContract.equals("off"))
31813163
// OK: Current Arg doesn't conflict with -ffp-model=strict
31823164
;

0 commit comments

Comments
 (0)