[PATCH] D24512: AMDGPU: Fix target options fp32/64-denormals
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 13 10:45:41 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281357: AMDGPU: Fix target options fp32/64-denormals (authored by yaxunl).
Changed prior to commit:
https://reviews.llvm.org/D24512?vs=71183&id=71201#toc
Repository:
rL LLVM
https://reviews.llvm.org/D24512
Files:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl
Index: cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl
===================================================================
--- cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl
+++ cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl
@@ -1,13 +1,19 @@
// RUN: %clang_cc1 -S -cl-denorms-are-zero -o - %s 2>&1
// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s
// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s --check-prefix=CHECK-DENORM
+// RUN: %clang_cc1 -emit-llvm -target-feature +fp32-denormals -target-feature -fp64-denormals -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck --check-prefix=CHECK-FEATURE %s
// For non-amdgcn targets, this test just checks that the -cl-denorms-are-zero argument is accepted
// by clang. This option is currently a no-op, which is allowed by the
// OpenCL specification.
+// For amdgcn target cpu fiji, fp32 should be flushed since fiji does not support fp32 denormals, unless +fp32-denormals is
+// explicitly set. amdgcn target always do not flush fp64 denormals.
+
// CHECK-DENORM-LABEL: define void @f()
-// CHECK-DENORM: attributes #{{[0-9]*}} = {{{[^}]*}} "target-features"="{{[^"]*}}+fp32-denormals,+fp64-denormals{{[^"]*}}"
+// CHECK-DENORM: attributes #{{[0-9]*}} = {{{[^}]*}} "target-features"="{{[^"]*}}+fp64-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
// CHECK-LABEL: define void @f()
-// CHECK-NOT: attributes #{{[0-9]*}} = {{{[^}]*}} "target-features"="{{[^"]*}}+fp32-denormals,+fp64-denormals{{[^"]*}}"
+// CHECK: attributes #{{[0-9]*}} = {{{[^}]*}} "target-features"="{{[^"]*}}+fp64-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
+// CHECK-FEATURE-LABEL: define void @f()
+// CHECK-FEATURE: attributes #{{[0-9]*}} = {{{[^}]*}} "target-features"="{{[^"]*}}+fp32-denormals,{{[^"]*}}-fp64-denormals{{[^"]*}}"
void f() {}
Index: cfe/trunk/lib/Basic/Targets.cpp
===================================================================
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1965,7 +1965,7 @@
bool hasFP64:1;
bool hasFMAF:1;
bool hasLDEXPF:1;
- bool hasDenormSupport:1;
+ bool hasFullSpeedFP32Denorms:1;
static bool isAMDGCN(const llvm::Triple &TT) {
return TT.getArch() == llvm::Triple::amdgcn;
@@ -1978,14 +1978,12 @@
hasFP64(false),
hasFMAF(false),
hasLDEXPF(false),
- hasDenormSupport(false){
+ hasFullSpeedFP32Denorms(false){
if (getTriple().getArch() == llvm::Triple::amdgcn) {
hasFP64 = true;
hasFMAF = true;
hasLDEXPF = true;
}
- if (Opts.CPU == "fiji")
- hasDenormSupport = true;
resetDataLayout(getTriple().getArch() == llvm::Triple::amdgcn ?
DataLayoutStringSI : DataLayoutStringR600);
@@ -2040,8 +2038,6 @@
void adjustTargetOptions(const CodeGenOptions &CGOpts,
TargetOptions &TargetOpts) const override {
- if (!hasDenormSupport)
- return;
bool hasFP32Denormals = false;
bool hasFP64Denormals = false;
for (auto &I : TargetOpts.FeaturesAsWritten) {
@@ -2051,11 +2047,11 @@
hasFP64Denormals = true;
}
if (!hasFP32Denormals)
- TargetOpts.Features.push_back((Twine(CGOpts.FlushDenorm ? '-' : '+') +
- Twine("fp32-denormals")).str());
+ TargetOpts.Features.push_back((Twine(hasFullSpeedFP32Denorms &&
+ !CGOpts.FlushDenorm ? '+' : '-') + Twine("fp32-denormals")).str());
+ // Always do not flush fp64 denorms.
if (!hasFP64Denormals && hasFP64)
- TargetOpts.Features.push_back((Twine(CGOpts.FlushDenorm ? '-' : '+') +
- Twine("fp64-denormals")).str());
+ TargetOpts.Features.push_back("+fp64-denormals");
}
ArrayRef<Builtin::Info> getTargetBuiltins() const override {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24512.71201.patch
Type: text/x-patch
Size: 3914 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160913/d137a0ef/attachment.bin>
More information about the cfe-commits
mailing list