[PATCH] AMDGPU/SI: add a test for "undef" behavior with unsafe-fp-math
Marek Olšák via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 14 11:31:39 PDT 2015
From: Marek Olšák <marek.olsak at amd.com>
I wonder if this should be fixed in LLVM or if it's a bug at all.
---
test/CodeGen/AMDGPU/undef.ll | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
create mode 100644 test/CodeGen/AMDGPU/undef.ll
diff --git a/test/CodeGen/AMDGPU/undef.ll b/test/CodeGen/AMDGPU/undef.ll
new file mode 100644
index 0000000..6b4ff75
--- /dev/null
+++ b/test/CodeGen/AMDGPU/undef.ll
@@ -0,0 +1,26 @@
+; RUN: llc -march=amdgcn -mcpu=verde -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
+
+; unsafe-fp-math optimizes (fmul %x, undef) too aggressively.
+; This is not desirable for DX9 apps, which may emulate conditional assignments
+; with fmul.
+;
+; The preferred behavior is to replace (fmul %x, undef) with 0 if NaNs are disabled.
+; The current behavior is that the whole shader is eliminated, leading to
+; a no-op shader or shader that exports undef.
+
+; FUNC-LABEL: {{^}}xundef:
+;
+; GCN: {{.*}} 0x3dcccccd
+define void @xundef(float %src) #0 {
+main_body:
+ %zero = fmul float %src, undef
+ %r = fadd float %zero, 0x3FB99999A0000000
+ call void @llvm.SI.export(i32 15, i32 1, i32 1, i32 0, i32 1, float %r, float %r, float %r, float %r)
+ ret void
+}
+
+declare void @llvm.SI.export(i32, i32, i32, i32, i32, float, float, float, float)
+
+attributes #0 = { "ShaderType"="0" "no-nans-fp-math"="true" "unsafe-fp-math"="true" }
+
+!0 = !{!"const", null, i32 1}
--
2.1.4
More information about the llvm-commits
mailing list