9747464
From 95b15b3d2f180b15267032e16c947c0f9b8a112d Mon Sep 17 00:00:00 2001
9747464
From: Dave Airlie <airlied@redhat.com>
9747464
Date: Wed, 1 Mar 2017 13:02:38 +1000
9747464
Subject: [PATCH] Revert "Merging r280589:"
9747464
9747464
This reverts commit 25e2616626caafb896517e18cd8aa724fba2b200.
9747464
---
9747464
 lib/Target/AMDGPU/SIInstructions.td   |  1 -
9747464
 lib/Target/AMDGPU/SIWholeQuadMode.cpp |  7 +++++
9747464
 test/CodeGen/AMDGPU/wqm.ll            | 49 +++--------------------------------
9747464
 3 files changed, 11 insertions(+), 46 deletions(-)
9747464
9747464
diff --git a/lib/Target/AMDGPU/SIInstructions.td b/lib/Target/AMDGPU/SIInstructions.td
9747464
index dde5f2f..18b7d5d 100644
9747464
--- a/lib/Target/AMDGPU/SIInstructions.td
9747464
+++ b/lib/Target/AMDGPU/SIInstructions.td
9747464
@@ -2029,7 +2029,6 @@ def SI_RETURN : PseudoInstSI <
9747464
   let hasSideEffects = 1;
9747464
   let SALU = 1;
9747464
   let hasNoSchedulingInfo = 1;
9747464
-  let DisableWQM = 1;
9747464
 }
9747464
 
9747464
 let Uses = [EXEC], Defs = [EXEC, VCC, M0],
9747464
diff --git a/lib/Target/AMDGPU/SIWholeQuadMode.cpp b/lib/Target/AMDGPU/SIWholeQuadMode.cpp
9747464
index 1534d58..b200c15 100644
9747464
--- a/lib/Target/AMDGPU/SIWholeQuadMode.cpp
9747464
+++ b/lib/Target/AMDGPU/SIWholeQuadMode.cpp
9747464
@@ -219,6 +219,13 @@ char SIWholeQuadMode::scanInstructions(MachineFunction &MF,
9747464
       markInstruction(MI, Flags, Worklist);
9747464
       GlobalFlags |= Flags;
9747464
     }
9747464
+
9747464
+    if (WQMOutputs && MBB.succ_empty()) {
9747464
+      // This is a prolog shader. Make sure we go back to exact mode at the end.
9747464
+      Blocks[&MBB].OutNeeds = StateExact;
9747464
+      Worklist.push_back(&MBB);
9747464
+      GlobalFlags |= StateExact;
9747464
+    }
9747464
   }
9747464
 
9747464
   return GlobalFlags;
9747464
diff --git a/test/CodeGen/AMDGPU/wqm.ll b/test/CodeGen/AMDGPU/wqm.ll
9747464
index 41e4264..809a7ba 100644
9747464
--- a/test/CodeGen/AMDGPU/wqm.ll
9747464
+++ b/test/CodeGen/AMDGPU/wqm.ll
9747464
@@ -17,18 +17,17 @@ main_body:
9747464
 ;CHECK-LABEL: {{^}}test2:
9747464
 ;CHECK-NEXT: ; %main_body
9747464
 ;CHECK-NEXT: s_wqm_b64 exec, exec
9747464
+;CHECK: image_sample
9747464
 ;CHECK-NOT: exec
9747464
-define amdgpu_ps void @test2(<8 x i32> inreg %rsrc, <4 x i32> inreg %sampler, float addrspace(1)* inreg %ptr, <4 x i32> %c) {
9747464
+;CHECK: _load_dword v0,
9747464
+define amdgpu_ps float @test2(<8 x i32> inreg %rsrc, <4 x i32> inreg %sampler, float addrspace(1)* inreg %ptr, <4 x i32> %c) {
9747464
 main_body:
9747464
   %c.1 = call <4 x float> @llvm.SI.image.sample.v4i32(<4 x i32> %c, <8 x i32> %rsrc, <4 x i32> %sampler, i32 15, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
9747464
   %c.2 = bitcast <4 x float> %c.1 to <4 x i32>
9747464
   %c.3 = extractelement <4 x i32> %c.2, i32 0
9747464
   %gep = getelementptr float, float addrspace(1)* %ptr, i32 %c.3
9747464
   %data = load float, float addrspace(1)* %gep
9747464
-
9747464
-  call void @llvm.SI.export(i32 15, i32 1, i32 1, i32 0, i32 1, float %data, float undef, float undef, float undef)
9747464
-
9747464
-  ret void
9747464
+  ret float %data
9747464
 }
9747464
 
9747464
 ; ... but disabled for stores (and, in this simple case, not re-enabled).
9747464
@@ -415,46 +414,6 @@ entry:
9747464
   ret void
9747464
 }
9747464
 
9747464
-; Must return to exact at the end of a non-void returning shader,
9747464
-; otherwise the EXEC mask exported by the epilog will be wrong. This is true
9747464
-; even if the shader has no kills, because a kill could have happened in a
9747464
-; previous shader fragment.
9747464
-;
9747464
-; CHECK-LABEL: {{^}}test_nonvoid_return:
9747464
-; CHECK: s_mov_b64 [[LIVE:s\[[0-9]+:[0-9]+\]]], exec
9747464
-; CHECK: s_wqm_b64 exec, exec
9747464
-;
9747464
-; CHECK: s_and_b64 exec, exec, [[LIVE]]
9747464
-; CHECK-NOT: exec
9747464
-define amdgpu_ps <4 x float> @test_nonvoid_return() nounwind {
9747464
-  %tex = call <4 x float> @llvm.SI.image.sample.v4i32(<4 x i32> undef, <8 x i32> undef, <4 x i32> undef, i32 15, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
9747464
-  %tex.i = bitcast <4 x float> %tex to <4 x i32>
9747464
-  %dtex = call <4 x float> @llvm.SI.image.sample.v4i32(<4 x i32> %tex.i, <8 x i32> undef, <4 x i32> undef, i32 15, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
9747464
-  ret <4 x float> %dtex
9747464
-}
9747464
-
9747464
-; CHECK-LABEL: {{^}}test_nonvoid_return_unreachable:
9747464
-; CHECK: s_mov_b64 [[LIVE:s\[[0-9]+:[0-9]+\]]], exec
9747464
-; CHECK: s_wqm_b64 exec, exec
9747464
-;
9747464
-; CHECK: s_and_b64 exec, exec, [[LIVE]]
9747464
-; CHECK-NOT: exec
9747464
-define amdgpu_ps <4 x float> @test_nonvoid_return_unreachable(i32 inreg %c) nounwind {
9747464
-entry:
9747464
-  %tex = call <4 x float> @llvm.SI.image.sample.v4i32(<4 x i32> undef, <8 x i32> undef, <4 x i32> undef, i32 15, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
9747464
-  %tex.i = bitcast <4 x float> %tex to <4 x i32>
9747464
-  %dtex = call <4 x float> @llvm.SI.image.sample.v4i32(<4 x i32> %tex.i, <8 x i32> undef, <4 x i32> undef, i32 15, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
9747464
-
9747464
-  %cc = icmp sgt i32 %c, 0
9747464
-  br i1 %cc, label %if, label %else
9747464
-
9747464
-if:
9747464
-  store volatile <4 x float> %dtex, <4 x float>* undef
9747464
-  unreachable
9747464
-
9747464
-else:
9747464
-  ret <4 x float> %dtex
9747464
-}
9747464
 
9747464
 declare void @llvm.amdgcn.image.store.v4i32(<4 x float>, <4 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #1
9747464
 declare void @llvm.amdgcn.buffer.store.f32(float, <4 x i32>, i32, i32, i1, i1) #1
9747464
-- 
9747464
2.9.3
9747464