[PATCH 6/9] R600/SI: Add global atomicrmw min/umin
Matt Arsenault
Matthew.Arsenault at amd.com
Thu Oct 16 18:22:42 PDT 2014
On 10/16/2014 06:01 PM, Aaron Watry wrote:
> v2: Add separate offset/no-offset tests
>
> Signed-off-by: Aaron Watry <awatry at gmail.com>
> Reviewed-by (v1): Matt Arsenault <matthew.arsenault at amd.com>
> ---
> lib/Target/R600/AMDGPUInstructions.td | 2 +
> lib/Target/R600/SIInstructions.td | 8 +-
> test/CodeGen/R600/global_atomics.ll | 160 ++++++++++++++++++++++++++++++++++
> 3 files changed, 168 insertions(+), 2 deletions(-)
LGTM
>
> diff --git a/lib/Target/R600/AMDGPUInstructions.td b/lib/Target/R600/AMDGPUInstructions.td
> index f295f33..03d7320 100644
> --- a/lib/Target/R600/AMDGPUInstructions.td
> +++ b/lib/Target/R600/AMDGPUInstructions.td
> @@ -389,8 +389,10 @@ class global_binary_atomic_op<SDNode atomic_op> : PatFrag<
> def atomic_add_global : global_binary_atomic_op<atomic_load_add>;
> def atomic_and_global : global_binary_atomic_op<atomic_load_and>;
> def atomic_max_global : global_binary_atomic_op<atomic_load_max>;
> +def atomic_min_global : global_binary_atomic_op<atomic_load_min>;
> def atomic_sub_global : global_binary_atomic_op<atomic_load_sub>;
> def atomic_umax_global : global_binary_atomic_op<atomic_load_umax>;
> +def atomic_umin_global : global_binary_atomic_op<atomic_load_umin>;
>
> //===----------------------------------------------------------------------===//
> // Misc Pattern Fragments
> diff --git a/lib/Target/R600/SIInstructions.td b/lib/Target/R600/SIInstructions.td
> index 5a7cdf3..4f2e0cc 100644
> --- a/lib/Target/R600/SIInstructions.td
> +++ b/lib/Target/R600/SIInstructions.td
> @@ -904,8 +904,12 @@ defm BUFFER_ATOMIC_SUB : MUBUF_Atomic <
> 0x00000033, "BUFFER_ATOMIC_SUB", VReg_32, i32, atomic_sub_global
> >;
> //def BUFFER_ATOMIC_RSUB : MUBUF_ <0x00000034, "BUFFER_ATOMIC_RSUB", []>;
> -//def BUFFER_ATOMIC_SMIN : MUBUF_ <0x00000035, "BUFFER_ATOMIC_SMIN", []>;
> -//def BUFFER_ATOMIC_UMIN : MUBUF_ <0x00000036, "BUFFER_ATOMIC_UMIN", []>;
> +defm BUFFER_ATOMIC_SMIN : MUBUF_Atomic <
> + 0x00000035, "BUFFER_ATOMIC_SMIN", VReg_32, i32, atomic_min_global
> +>;
> +defm BUFFER_ATOMIC_UMIN : MUBUF_Atomic <
> + 0x00000036, "BUFFER_ATOMIC_UMIN", VReg_32, i32, atomic_umin_global
> +>;
> defm BUFFER_ATOMIC_SMAX : MUBUF_Atomic <
> 0x00000037, "BUFFER_ATOMIC_SMAX", VReg_32, i32, atomic_max_global
> >;
> diff --git a/test/CodeGen/R600/global_atomics.ll b/test/CodeGen/R600/global_atomics.ll
> index 93dba4a..2405c68 100644
> --- a/test/CodeGen/R600/global_atomics.ll
> +++ b/test/CodeGen/R600/global_atomics.ll
> @@ -399,3 +399,163 @@ entry:
> store i32 %0, i32 addrspace(1)* %out2
> ret void
> }
> +
> +; FUNC-LABEL: {{^}}atomic_min_i32_offset:
> +; SI: BUFFER_ATOMIC_SMIN v{{[0-9]+}}, s[{{[0-9]+}}:{{[0-9]+}}], 0 offset:0x10{{$}}
> +define void @atomic_min_i32_offset(i32 addrspace(1)* %out, i32 %in) {
> +entry:
> + %gep = getelementptr i32 addrspace(1)* %out, i32 4
> + %0 = atomicrmw volatile min i32 addrspace(1)* %gep, i32 %in seq_cst
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_min_i32_ret_offset:
> +; SI: BUFFER_ATOMIC_SMIN [[RET:v[0-9]+]], s[{{[0-9]+}}:{{[0-9]+}}], 0 offset:0x10 glc {{$}}
> +; SI: BUFFER_STORE_DWORD [[RET]]
> +define void @atomic_min_i32_ret_offset(i32 addrspace(1)* %out, i32 addrspace(1)* %out2, i32 %in) {
> +entry:
> + %gep = getelementptr i32 addrspace(1)* %out, i32 4
> + %0 = atomicrmw volatile min i32 addrspace(1)* %gep, i32 %in seq_cst
> + store i32 %0, i32 addrspace(1)* %out2
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_min_i32_addr64_offset:
> +; SI: BUFFER_ATOMIC_SMIN v{{[0-9]+}}, v[{{[0-9]+}}:{{[0-9]+}}], s[{{[0-9]+}}:{{[0-9]+}}], 0 addr64 offset:0x10{{$}}
> +define void @atomic_min_i32_addr64_offset(i32 addrspace(1)* %out, i32 %in, i64 %index) {
> +entry:
> + %ptr = getelementptr i32 addrspace(1)* %out, i64 %index
> + %gep = getelementptr i32 addrspace(1)* %ptr, i32 4
> + %0 = atomicrmw volatile min i32 addrspace(1)* %gep, i32 %in seq_cst
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_min_i32_ret_addr64_offset:
> +; SI: BUFFER_ATOMIC_SMIN [[RET:v[0-9]+]], v[{{[0-9]+}}:{{[0-9]+}}], s[{{[0-9]+}}:{{[0-9]+}}], 0 addr64 offset:0x10 glc{{$}}
> +; SI: BUFFER_STORE_DWORD [[RET]]
> +define void @atomic_min_i32_ret_addr64_offset(i32 addrspace(1)* %out, i32 addrspace(1)* %out2, i32 %in, i64 %index) {
> +entry:
> + %ptr = getelementptr i32 addrspace(1)* %out, i64 %index
> + %gep = getelementptr i32 addrspace(1)* %ptr, i32 4
> + %0 = atomicrmw volatile min i32 addrspace(1)* %gep, i32 %in seq_cst
> + store i32 %0, i32 addrspace(1)* %out2
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_min_i32:
> +; SI: BUFFER_ATOMIC_SMIN v{{[0-9]+}}, s[{{[0-9]+}}:{{[0-9]+}}], 0{{$}}
> +define void @atomic_min_i32(i32 addrspace(1)* %out, i32 %in) {
> +entry:
> + %0 = atomicrmw volatile min i32 addrspace(1)* %out, i32 %in seq_cst
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_min_i32_ret:
> +; SI: BUFFER_ATOMIC_SMIN [[RET:v[0-9]+]], s[{{[0-9]+}}:{{[0-9]+}}], 0 glc
> +; SI: BUFFER_STORE_DWORD [[RET]]
> +define void @atomic_min_i32_ret(i32 addrspace(1)* %out, i32 addrspace(1)* %out2, i32 %in) {
> +entry:
> + %0 = atomicrmw volatile min i32 addrspace(1)* %out, i32 %in seq_cst
> + store i32 %0, i32 addrspace(1)* %out2
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_min_i32_addr64:
> +; SI: BUFFER_ATOMIC_SMIN v{{[0-9]+}}, v[{{[0-9]+}}:{{[0-9]+}}], s[{{[0-9]+}}:{{[0-9]+}}], 0 addr64{{$}}
> +define void @atomic_min_i32_addr64(i32 addrspace(1)* %out, i32 %in, i64 %index) {
> +entry:
> + %ptr = getelementptr i32 addrspace(1)* %out, i64 %index
> + %0 = atomicrmw volatile min i32 addrspace(1)* %ptr, i32 %in seq_cst
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_min_i32_ret_addr64:
> +; SI: BUFFER_ATOMIC_SMIN [[RET:v[0-9]+]], v[{{[0-9]+}}:{{[0-9]+}}], s[{{[0-9]+}}:{{[0-9]+}}], 0 addr64 glc{{$}}
> +; SI: BUFFER_STORE_DWORD [[RET]]
> +define void @atomic_min_i32_ret_addr64(i32 addrspace(1)* %out, i32 addrspace(1)* %out2, i32 %in, i64 %index) {
> +entry:
> + %ptr = getelementptr i32 addrspace(1)* %out, i64 %index
> + %0 = atomicrmw volatile min i32 addrspace(1)* %ptr, i32 %in seq_cst
> + store i32 %0, i32 addrspace(1)* %out2
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_umin_i32_offset:
> +; SI: BUFFER_ATOMIC_UMIN v{{[0-9]+}}, s[{{[0-9]+}}:{{[0-9]+}}], 0 offset:0x10{{$}}
> +define void @atomic_umin_i32_offset(i32 addrspace(1)* %out, i32 %in) {
> +entry:
> + %gep = getelementptr i32 addrspace(1)* %out, i32 4
> + %0 = atomicrmw volatile umin i32 addrspace(1)* %gep, i32 %in seq_cst
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_umin_i32_ret_offset:
> +; SI: BUFFER_ATOMIC_UMIN [[RET:v[0-9]+]], s[{{[0-9]+}}:{{[0-9]+}}], 0 offset:0x10 glc {{$}}
> +; SI: BUFFER_STORE_DWORD [[RET]]
> +define void @atomic_umin_i32_ret_offset(i32 addrspace(1)* %out, i32 addrspace(1)* %out2, i32 %in) {
> +entry:
> + %gep = getelementptr i32 addrspace(1)* %out, i32 4
> + %0 = atomicrmw volatile umin i32 addrspace(1)* %gep, i32 %in seq_cst
> + store i32 %0, i32 addrspace(1)* %out2
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_umin_i32_addr64_offset:
> +; SI: BUFFER_ATOMIC_UMIN v{{[0-9]+}}, v[{{[0-9]+}}:{{[0-9]+}}], s[{{[0-9]+}}:{{[0-9]+}}], 0 addr64 offset:0x10{{$}}
> +define void @atomic_umin_i32_addr64_offset(i32 addrspace(1)* %out, i32 %in, i64 %index) {
> +entry:
> + %ptr = getelementptr i32 addrspace(1)* %out, i64 %index
> + %gep = getelementptr i32 addrspace(1)* %ptr, i32 4
> + %0 = atomicrmw volatile umin i32 addrspace(1)* %gep, i32 %in seq_cst
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_umin_i32_ret_addr64_offset:
> +; SI: BUFFER_ATOMIC_UMIN [[RET:v[0-9]+]], v[{{[0-9]+}}:{{[0-9]+}}], s[{{[0-9]+}}:{{[0-9]+}}], 0 addr64 offset:0x10 glc{{$}}
> +; SI: BUFFER_STORE_DWORD [[RET]]
> +define void @atomic_umin_i32_ret_addr64_offset(i32 addrspace(1)* %out, i32 addrspace(1)* %out2, i32 %in, i64 %index) {
> +entry:
> + %ptr = getelementptr i32 addrspace(1)* %out, i64 %index
> + %gep = getelementptr i32 addrspace(1)* %ptr, i32 4
> + %0 = atomicrmw volatile umin i32 addrspace(1)* %gep, i32 %in seq_cst
> + store i32 %0, i32 addrspace(1)* %out2
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_umin_i32:
> +; SI: BUFFER_ATOMIC_UMIN v{{[0-9]+}}, s[{{[0-9]+}}:{{[0-9]+}}], 0{{$}}
> +define void @atomic_umin_i32(i32 addrspace(1)* %out, i32 %in) {
> +entry:
> + %0 = atomicrmw volatile umin i32 addrspace(1)* %out, i32 %in seq_cst
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_umin_i32_ret:
> +; SI: BUFFER_ATOMIC_UMIN [[RET:v[0-9]+]], s[{{[0-9]+}}:{{[0-9]+}}], 0 glc
> +; SI: BUFFER_STORE_DWORD [[RET]]
> +define void @atomic_umin_i32_ret(i32 addrspace(1)* %out, i32 addrspace(1)* %out2, i32 %in) {
> +entry:
> + %0 = atomicrmw volatile umin i32 addrspace(1)* %out, i32 %in seq_cst
> + store i32 %0, i32 addrspace(1)* %out2
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_umin_i32_addr64:
> +; SI: BUFFER_ATOMIC_UMIN v{{[0-9]+}}, v[{{[0-9]+}}:{{[0-9]+}}], s[{{[0-9]+}}:{{[0-9]+}}], 0 addr64{{$}}
> +define void @atomic_umin_i32_addr64(i32 addrspace(1)* %out, i32 %in, i64 %index) {
> +entry:
> + %ptr = getelementptr i32 addrspace(1)* %out, i64 %index
> + %0 = atomicrmw volatile umin i32 addrspace(1)* %ptr, i32 %in seq_cst
> + ret void
> +}
> +
> +; FUNC-LABEL: {{^}}atomic_umin_i32_ret_addr64:
> +; SI: BUFFER_ATOMIC_UMIN [[RET:v[0-9]+]], v[{{[0-9]+}}:{{[0-9]+}}], s[{{[0-9]+}}:{{[0-9]+}}], 0 addr64 glc{{$}}
> +; SI: BUFFER_STORE_DWORD [[RET]]
> +define void @atomic_umin_i32_ret_addr64(i32 addrspace(1)* %out, i32 addrspace(1)* %out2, i32 %in, i64 %index) {
> +entry:
> + %ptr = getelementptr i32 addrspace(1)* %out, i64 %index
> + %0 = atomicrmw volatile umin i32 addrspace(1)* %ptr, i32 %in seq_cst
> + store i32 %0, i32 addrspace(1)* %out2
> + ret void
> +}
More information about the llvm-commits
mailing list