[PATCH] D26585: [AMDGPU] Add wave barrier builtin
Stanislav Mekhanoshin via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 13 01:34:49 PST 2016
rampitec created this revision.
rampitec added a reviewer: vpykhtin.
rampitec added a subscriber: llvm-commits.
rampitec set the repository for this revision to rL LLVM.
Herald added a reviewer: tstellarAMD.
Herald added subscribers: tony-tye, yaxunl, nhaehnle, wdng, kzhuravl, arsenm.
The wave barrier represents the discardable barrier. Its main purpose is to carry convergent attribute, thus preventing illegal CFG optimizations.
All lanes in a wave come to convergence point simultaneously with SIMT, thus no special instruction is needed in the ISA.
The barrier is discarded during lowering to machine instructions.
Repository:
rL LLVM
https://reviews.llvm.org/D26585
Files:
include/llvm/IR/IntrinsicsAMDGPU.td
lib/Target/AMDGPU/SIISelLowering.cpp
test/CodeGen/AMDGPU/llvm.amdgcn.s.wave.barrier.ll
Index: test/CodeGen/AMDGPU/llvm.amdgcn.s.wave.barrier.ll
===================================================================
--- /dev/null
+++ test/CodeGen/AMDGPU/llvm.amdgcn.s.wave.barrier.ll
@@ -0,0 +1,15 @@
+; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
+
+; GCN-LABEL: {{^}}test_wave_barrier:
+; GCN-NOT: s_barrier
+
+define void @test_wave_barrier() #0 {
+entry:
+ call void @llvm.amdgcn.s.wave.barrier()
+ ret void
+}
+
+declare void @llvm.amdgcn.s.wave.barrier() #1
+
+attributes #0 = { nounwind }
+attributes #1 = { convergent nounwind }
Index: lib/Target/AMDGPU/SIISelLowering.cpp
===================================================================
--- lib/Target/AMDGPU/SIISelLowering.cpp
+++ lib/Target/AMDGPU/SIISelLowering.cpp
@@ -2694,6 +2694,8 @@
SDValue Cast = DAG.getNode(ISD::BITCAST, DL, MVT::i32, Src);
return DAG.getNode(AMDGPUISD::KILL, DL, MVT::Other, Chain, Cast);
}
+ case Intrinsic::amdgcn_s_wave_barrier:
+ return Chain;
default:
return SDValue();
}
Index: include/llvm/IR/IntrinsicsAMDGPU.td
===================================================================
--- include/llvm/IR/IntrinsicsAMDGPU.td
+++ include/llvm/IR/IntrinsicsAMDGPU.td
@@ -107,6 +107,9 @@
def int_amdgcn_s_barrier : GCCBuiltin<"__builtin_amdgcn_s_barrier">,
Intrinsic<[], [], [IntrConvergent]>;
+def int_amdgcn_s_wave_barrier : GCCBuiltin<"__builtin_amdgcn_s_wave_barrier">,
+ Intrinsic<[], [], [IntrConvergent]>;
+
def int_amdgcn_s_waitcnt : Intrinsic<[], [llvm_i32_ty], []>;
def int_amdgcn_div_scale : Intrinsic<
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26585.77739.patch
Type: text/x-patch
Size: 1594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161113/3bc989b5/attachment.bin>
More information about the llvm-commits
mailing list