[PATCH] D18197: AMDGPU/SI: Do not generate s_waitcnt for ds_permute/ds_bpermute Instructions.

Changpeng Fang via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 16 15:58:48 PDT 2016


cfang updated this revision to Diff 50888.
cfang added a comment.

Add test case for ds_permute/ds_bpermute NOT generating s_waitcnts


http://reviews.llvm.org/D18197

Files:
  lib/Target/AMDGPU/SIInstrInfo.td
  test/CodeGen/AMDGPU/llvm.amdgcn.ds.bpermute.ll
  test/CodeGen/AMDGPU/llvm.amdgcn.ds.permute.ll

Index: test/CodeGen/AMDGPU/llvm.amdgcn.ds.permute.ll
===================================================================
--- test/CodeGen/AMDGPU/llvm.amdgcn.ds.permute.ll
+++ test/CodeGen/AMDGPU/llvm.amdgcn.ds.permute.ll
@@ -10,4 +10,27 @@
   ret void
 }
 
+; FUNC-LABEL: {{^}}permute_no_waitcnt_test:
+; CHECK: ds_permute_b32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
+; CHECK-NOT: s_waitcnt
+define void @permute_no_waitcnt_test(i32 addrspace(1)* %out, i32 %cond) {
+entry:
+
+  %tmp = icmp eq i32 %cond, 0
+  br i1 %tmp, label %if, label %else
+
+if:                                               ; preds = %entry
+  %bpermute = call i32 @llvm.amdgcn.ds.permute(i32 0, i32 0) #0
+  br label %endif
+
+else:                                             ; preds = %entry
+  br label %endif
+
+endif:
+  %val = phi i32 [ %bpermute, %if ], [0, %else]      ; preds = %else, %if
+  store i32 %val, i32 addrspace(1)* %out, align 4
+  ret void
+}
+
+
 attributes #0 = { nounwind readnone convergent }
Index: test/CodeGen/AMDGPU/llvm.amdgcn.ds.bpermute.ll
===================================================================
--- test/CodeGen/AMDGPU/llvm.amdgcn.ds.bpermute.ll
+++ test/CodeGen/AMDGPU/llvm.amdgcn.ds.bpermute.ll
@@ -10,4 +10,27 @@
   ret void
 }
 
+; FUNC-LABEL: {{^}}bpermute_no_waitcnt_test:
+; CHECK: ds_bpermute_b32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
+; CHECK-NOT: s_waitcnt
+define void @bpermute_no_waitcnt_test(i32 addrspace(1)* %out, i32 %cond) {
+entry:
+
+  %tmp = icmp eq i32 %cond, 0
+  br i1 %tmp, label %if, label %else
+
+if:                                               ; preds = %entry
+
+  %bpermute = call i32 @llvm.amdgcn.ds.bpermute(i32 0, i32 0) #0
+  br label %endif
+
+else:                                             ; preds = %entry
+  br label %endif
+
+endif:
+  %val = phi i32 [ %bpermute, %if ], [0, %else]      ; preds = %else, %if
+  store i32 %val, i32 addrspace(1)* %out, align 4
+  ret void
+}
+
 attributes #0 = { nounwind readnone convergent }
Index: lib/Target/AMDGPU/SIInstrInfo.td
===================================================================
--- lib/Target/AMDGPU/SIInstrInfo.td
+++ lib/Target/AMDGPU/SIInstrInfo.td
@@ -2519,7 +2519,7 @@
   dag ins = (ins VGPR_32:$addr, rc:$data0),
   string asm = opName#" $vdst, $addr, $data0"> {
 
-  let mayLoad = 0, mayStore = 0, isConvergent = 1 in {
+  let LGKM_CNT = 0, mayLoad = 0, mayStore = 0, isConvergent = 1 in {
     def "" : DS_Pseudo <opName, outs, ins,
      [(set (i32 rc:$vdst),
          (node (i32 VGPR_32:$addr), (i32 rc:$data0)))]>;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18197.50888.patch
Type: text/x-patch
Size: 2546 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160316/288b1f4a/attachment.bin>


More information about the llvm-commits mailing list