[libclc] r193753 - R600: Set the noduplicate attribute on barrier() intrinsics
Tom Stellard
thomas.stellard at amd.com
Thu Oct 31 08:50:48 PDT 2013
Author: tstellar
Date: Thu Oct 31 10:50:48 2013
New Revision: 193753
URL: http://llvm.org/viewvc/llvm-project?rev=193753&view=rev
Log:
R600: Set the noduplicate attribute on barrier() intrinsics
This will prevent LLVM optimization passes from creating illegal uses
of the barrier() intrinsic (e.g. calling barrier() from a conditional
that is not executed by all threads).
Modified:
libclc/trunk/r600/lib/SOURCES
libclc/trunk/r600/lib/synchronization/barrier.cl
libclc/trunk/r600/lib/synchronization/barrier_impl.ll
Modified: libclc/trunk/r600/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/SOURCES?rev=193753&r1=193752&r2=193753&view=diff
==============================================================================
--- libclc/trunk/r600/lib/SOURCES (original)
+++ libclc/trunk/r600/lib/SOURCES Thu Oct 31 10:50:48 2013
@@ -8,4 +8,3 @@ workitem/get_global_size.ll
synchronization/barrier.cl
synchronization/barrier_impl.ll
shared/vload.cl
-shared/vstore.cl
\ No newline at end of file
Modified: libclc/trunk/r600/lib/synchronization/barrier.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/synchronization/barrier.cl?rev=193753&r1=193752&r2=193753&view=diff
==============================================================================
--- libclc/trunk/r600/lib/synchronization/barrier.cl (original)
+++ libclc/trunk/r600/lib/synchronization/barrier.cl Thu Oct 31 10:50:48 2013
@@ -1,15 +1,10 @@
#include <clc/clc.h>
-void barrier_local(void);
-void barrier_global(void);
-
-void barrier(cl_mem_fence_flags flags) {
- if (flags & CLK_LOCAL_MEM_FENCE) {
- barrier_local();
- }
+_CLC_DEF int __clc_clk_local_mem_fence() {
+ return CLK_LOCAL_MEM_FENCE;
+}
- if (flags & CLK_GLOBAL_MEM_FENCE) {
- barrier_global();
- }
+_CLC_DEF int __clc_clk_global_mem_fence() {
+ return CLK_GLOBAL_MEM_FENCE;
}
Modified: libclc/trunk/r600/lib/synchronization/barrier_impl.ll
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/synchronization/barrier_impl.ll?rev=193753&r1=193752&r2=193753&view=diff
==============================================================================
--- libclc/trunk/r600/lib/synchronization/barrier_impl.ll (original)
+++ libclc/trunk/r600/lib/synchronization/barrier_impl.ll Thu Oct 31 10:50:48 2013
@@ -1,12 +1,29 @@
-declare void @llvm.AMDGPU.barrier.local() nounwind
-declare void @llvm.AMDGPU.barrier.global() nounwind
+declare i32 @__clc_clk_local_mem_fence() nounwind alwaysinline
+declare i32 @__clc_clk_global_mem_fence() nounwind alwaysinline
+declare void @llvm.AMDGPU.barrier.local() nounwind noduplicate
+declare void @llvm.AMDGPU.barrier.global() nounwind noduplicate
-define void @barrier_local() nounwind alwaysinline {
- call void @llvm.AMDGPU.barrier.local()
- ret void
-}
+define void @barrier(i32 %flags) nounwind noduplicate alwaysinline {
+barrier_local_test:
+ %CLK_LOCAL_MEM_FENCE = call i32 @__clc_clk_local_mem_fence()
+ %0 = and i32 %flags, %CLK_LOCAL_MEM_FENCE
+ %1 = icmp ne i32 %0, 0
+ br i1 %1, label %barrier_local, label %barrier_global_test
+
+barrier_local:
+ call void @llvm.AMDGPU.barrier.local() noduplicate
+ br label %barrier_global_test
+
+barrier_global_test:
+ %CLK_GLOBAL_MEM_FENCE = call i32 @__clc_clk_global_mem_fence()
+ %2 = and i32 %flags, %CLK_GLOBAL_MEM_FENCE
+ %3 = icmp ne i32 %2, 0
+ br i1 %3, label %barrier_global, label %done
+
+barrier_global:
+ call void @llvm.AMDGPU.barrier.global() noduplicate
+ br label %done
-define void @barrier_global() nounwind alwaysinline {
- call void @llvm.AMDGPU.barrier.global()
+done:
ret void
}
More information about the cfe-commits
mailing list