[PATCH] D31482: [AMDGPU][GFX9] Set +fp32-denormals for >=gfx900 unless -cl-denorms-are-zero is set
Konstantin Zhuravlyov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 29 15:51:07 PDT 2017
kzhuravl created this revision.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, wdng.
https://reviews.llvm.org/D31482
Files:
llvm/tools/clang/lib/Basic/Targets.cpp
llvm/tools/clang/test/CodeGenOpenCL/gfx9-fp32-denorms.cl
Index: llvm/tools/clang/test/CodeGenOpenCL/gfx9-fp32-denorms.cl
===================================================================
--- llvm/tools/clang/test/CodeGenOpenCL/gfx9-fp32-denorms.cl
+++ llvm/tools/clang/test/CodeGenOpenCL/gfx9-fp32-denorms.cl
@@ -0,0 +1,13 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx900 -S -emit-llvm -o - %s | FileCheck --check-prefix=DEFAULT %s
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx900 -S -emit-llvm -o - -target-feature +fp32-denormals %s | FileCheck --check-prefix=FEATURE_FP32_DENORMALS_ON %s
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx900 -S -emit-llvm -o - -target-feature -fp32-denormals %s | FileCheck --check-prefix=FEATURE_FP32_DENORMALS_OFF %s
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx900 -S -emit-llvm -o - -cl-denorms-are-zero %s | FileCheck --check-prefix=OPT_DENORMS_ARE_ZERO %s
+
+// DEFAULT: +fp32-denormals
+// FEATURE_FP32_DENORMALS_ON: +fp32-denormals
+// FEATURE_FP32_DENORMALS_OFF: -fp32-denormals
+// OPT_DENORMS_ARE_ZERO: -fp32-denormals
+
+kernel void gfx9_fp32_denorms() {}
Index: llvm/tools/clang/lib/Basic/Targets.cpp
===================================================================
--- llvm/tools/clang/lib/Basic/Targets.cpp
+++ llvm/tools/clang/lib/Basic/Targets.cpp
@@ -2109,9 +2109,12 @@
bool hasFP64:1;
bool hasFMAF:1;
bool hasLDEXPF:1;
- bool hasFullSpeedFP32Denorms:1;
const AddrSpace AS;
+ static bool hasFullSpeedFP32Denorms(StringRef GPUName) {
+ return parseAMDGCNName(GPUName) >= GK_GFX9;
+ }
+
static bool isAMDGCN(const llvm::Triple &TT) {
return TT.getArch() == llvm::Triple::amdgcn;
}
@@ -2127,7 +2130,6 @@
hasFP64(false),
hasFMAF(false),
hasLDEXPF(false),
- hasFullSpeedFP32Denorms(false),
AS(isGenericZero(Triple)){
if (getTriple().getArch() == llvm::Triple::amdgcn) {
hasFP64 = true;
@@ -2196,7 +2198,8 @@
hasFP64Denormals = true;
}
if (!hasFP32Denormals)
- TargetOpts.Features.push_back((Twine(hasFullSpeedFP32Denorms &&
+ TargetOpts.Features.push_back(
+ (Twine(hasFullSpeedFP32Denorms(TargetOpts.CPU) &&
!CGOpts.FlushDenorm ? '+' : '-') + Twine("fp32-denormals")).str());
// Always do not flush fp64 or fp16 denorms.
if (!hasFP64Denormals && hasFP64)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31482.93420.patch
Type: text/x-patch
Size: 2412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170329/421493ac/attachment.bin>
More information about the cfe-commits
mailing list