[PATCH] D69979: clang: Guess at some platform FTZ/DAZ default settings
Matt Arsenault via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 7 17:50:40 PST 2019
arsenm created this revision.
arsenm added reviewers: spatel, craig.topper, RKSimon, hfinkel, probinson.
Herald added a subscriber: wdng.
arsenm added a parent revision: D69978: Separately track input and output denormal mode.
This is to avoid performance regressions when the default attribute
behavior is fixed to assume ieee.
I tested the default on x86_64 ubuntu, which seems to default to
FTZ/DAZ, but am guessing for x86 and PS4.
https://reviews.llvm.org/D69979
Files:
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/Linux.h
clang/lib/Driver/ToolChains/PS4CPU.h
clang/test/Driver/default-denormal-fp-math.c
Index: clang/test/Driver/default-denormal-fp-math.c
===================================================================
--- /dev/null
+++ clang/test/Driver/default-denormal-fp-math.c
@@ -0,0 +1,7 @@
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+// RUN: %clang -### -target i386-unknown-linux-gnu -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-ZEROSIGN %s
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-ZEROSIGN %s
+// RUN: %clang -### -target x86_64-scei-ps4 -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-ZEROSIGN %s
+
+// CHECK-IEEE: -fdenormal-fp-math=ieee,ieee
+// CHECK-ZEROSIGN: -fdenormal-fp-math=preserve-sign,preserve-sign
Index: clang/lib/Driver/ToolChains/PS4CPU.h
===================================================================
--- clang/lib/Driver/ToolChains/PS4CPU.h
+++ clang/lib/Driver/ToolChains/PS4CPU.h
@@ -88,6 +88,14 @@
// capable of unit splitting.
bool canSplitThinLTOUnit() const override { return false; }
+ llvm::DenormalMode getDefaultDenormalModeForType(
+ const llvm::opt::ArgList &DriverArgs,
+ Action::OffloadKind DeviceOffloadKind,
+ const llvm::fltSemantics *FPType) const override {
+ // DAZ and FTZ are on by default.
+ return llvm::DenormalMode::getPreserveSign();
+ }
+
protected:
Tool *buildAssembler() const override;
Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/Linux.h
===================================================================
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -49,6 +49,11 @@
std::vector<std::string> ExtraOpts;
+ llvm::DenormalMode getDefaultDenormalModeForType(
+ const llvm::opt::ArgList &DriverArgs,
+ Action::OffloadKind DeviceOffloadKind,
+ const llvm::fltSemantics *FPType = nullptr) const override;
+
protected:
Tool *buildAssembler() const override;
Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -1044,3 +1044,17 @@
Twine("-u", llvm::getInstrProfRuntimeHookVarName())));
ToolChain::addProfileRTLibs(Args, CmdArgs);
}
+
+llvm::DenormalMode Linux::getDefaultDenormalModeForType(
+ const llvm::opt::ArgList &DriverArgs,
+ Action::OffloadKind DeviceOffloadKind,
+ const llvm::fltSemantics *FPType) const {
+ switch (getTriple().getArch()) {
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ // DAZ and FTZ are on by default.
+ return llvm::DenormalMode::getPreserveSign();
+ default:
+ return llvm::DenormalMode::getIEEE();
+ }
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69979.228347.patch
Type: text/x-patch
Size: 2761 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191108/02d3e451/attachment-0001.bin>
More information about the cfe-commits
mailing list