Jay Foad | eac2386 | 2019-08-23 10:07:43 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=amdgcn -mtriple=amdgcn---amdgiz -amdgpu-atomic-optimizations=true -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN64,GFX7LESS %s |
| 2 | ; RUN: llc -march=amdgcn -mtriple=amdgcn---amdgiz -mcpu=tonga -mattr=-flat-for-global -amdgpu-atomic-optimizations=true -amdgpu-dpp-combine=false -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN64,GFX8MORE,GFX8MORE64,GFX89 %s |
| 3 | ; RUN: llc -march=amdgcn -mtriple=amdgcn---amdgiz -mcpu=gfx900 -mattr=-flat-for-global -amdgpu-atomic-optimizations=true -amdgpu-dpp-combine=false -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN64,GFX8MORE,GFX8MORE64,GFX89 %s |
| 4 | ; RUN: llc -march=amdgcn -mtriple=amdgcn---amdgiz -mcpu=gfx1010 -mattr=-wavefrontsize32,+wavefrontsize64 -mattr=-flat-for-global -amdgpu-atomic-optimizations=true -amdgpu-dpp-combine=false -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN64,GFX8MORE,GFX8MORE64 %s |
| 5 | ; RUN: llc -march=amdgcn -mtriple=amdgcn---amdgiz -mcpu=gfx1010 -mattr=+wavefrontsize32,-wavefrontsize64 -mattr=-flat-for-global -amdgpu-atomic-optimizations=true -amdgpu-dpp-combine=false -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN32,GFX8MORE,GFX8MORE32 %s |
Neil Henning | 6641657 | 2018-10-08 15:49:19 +0000 | [diff] [blame] | 6 | |
| 7 | declare i32 @llvm.amdgcn.workitem.id.x() |
| 8 | declare i32 @llvm.amdgcn.buffer.atomic.add(i32, <4 x i32>, i32, i32, i1) |
| 9 | declare i32 @llvm.amdgcn.buffer.atomic.sub(i32, <4 x i32>, i32, i32, i1) |
| 10 | |
| 11 | ; Show that what the atomic optimization pass will do for raw buffers. |
| 12 | |
| 13 | ; GCN-LABEL: add_i32_constant: |
Jay Foad | eac2386 | 2019-08-23 10:07:43 +0000 | [diff] [blame] | 14 | ; GCN32: v_cmp_ne_u32_e64 s[[exec_lo:[0-9]+]], 1, 0 |
| 15 | ; GCN64: v_cmp_ne_u32_e64 s{{\[}}[[exec_lo:[0-9]+]]:[[exec_hi:[0-9]+]]{{\]}}, 1, 0 |
| 16 | ; GCN: v_mbcnt_lo_u32_b32{{(_e[0-9]+)?}} v[[mbcnt:[0-9]+]], s[[exec_lo]], 0 |
| 17 | ; GCN64: v_mbcnt_hi_u32_b32{{(_e[0-9]+)?}} v[[mbcnt]], s[[exec_hi]], v[[mbcnt]] |
| 18 | ; GCN: v_cmp_eq_u32{{(_e[0-9]+)?}} vcc{{(_lo)?}}, 0, v[[mbcnt]] |
| 19 | ; GCN32: s_bcnt1_i32_b32 s[[popcount:[0-9]+]], s[[exec_lo]] |
| 20 | ; GCN64: s_bcnt1_i32_b64 s[[popcount:[0-9]+]], s{{\[}}[[exec_lo]]:[[exec_hi]]{{\]}} |
Neil Henning | 6641657 | 2018-10-08 15:49:19 +0000 | [diff] [blame] | 21 | ; GCN: v_mul_u32_u24{{(_e[0-9]+)?}} v[[value:[0-9]+]], s[[popcount]], 5 |
| 22 | ; GCN: buffer_atomic_add v[[value]] |
| 23 | define amdgpu_kernel void @add_i32_constant(i32 addrspace(1)* %out, <4 x i32> %inout) { |
| 24 | entry: |
| 25 | %old = call i32 @llvm.amdgcn.buffer.atomic.add(i32 5, <4 x i32> %inout, i32 0, i32 0, i1 0) |
| 26 | store i32 %old, i32 addrspace(1)* %out |
| 27 | ret void |
| 28 | } |
| 29 | |
| 30 | ; GCN-LABEL: add_i32_uniform: |
Jay Foad | eac2386 | 2019-08-23 10:07:43 +0000 | [diff] [blame] | 31 | ; GCN32: v_cmp_ne_u32_e64 s[[exec_lo:[0-9]+]], 1, 0 |
| 32 | ; GCN64: v_cmp_ne_u32_e64 s{{\[}}[[exec_lo:[0-9]+]]:[[exec_hi:[0-9]+]]{{\]}}, 1, 0 |
| 33 | ; GCN: v_mbcnt_lo_u32_b32{{(_e[0-9]+)?}} v[[mbcnt:[0-9]+]], s[[exec_lo]], 0 |
| 34 | ; GCN64: v_mbcnt_hi_u32_b32{{(_e[0-9]+)?}} v[[mbcnt]], s[[exec_hi]], v[[mbcnt]] |
| 35 | ; GCN: v_cmp_eq_u32{{(_e[0-9]+)?}} vcc{{(_lo)?}}, 0, v[[mbcnt]] |
| 36 | ; GCN32: s_bcnt1_i32_b32 s[[popcount:[0-9]+]], s[[exec_lo]] |
| 37 | ; GCN64: s_bcnt1_i32_b64 s[[popcount:[0-9]+]], s{{\[}}[[exec_lo]]:[[exec_hi]]{{\]}} |
Neil Henning | 6641657 | 2018-10-08 15:49:19 +0000 | [diff] [blame] | 38 | ; GCN: s_mul_i32 s[[scalar_value:[0-9]+]], s{{[0-9]+}}, s[[popcount]] |
| 39 | ; GCN: v_mov_b32{{(_e[0-9]+)?}} v[[value:[0-9]+]], s[[scalar_value]] |
| 40 | ; GCN: buffer_atomic_add v[[value]] |
| 41 | define amdgpu_kernel void @add_i32_uniform(i32 addrspace(1)* %out, <4 x i32> %inout, i32 %additive) { |
| 42 | entry: |
| 43 | %old = call i32 @llvm.amdgcn.buffer.atomic.add(i32 %additive, <4 x i32> %inout, i32 0, i32 0, i1 0) |
| 44 | store i32 %old, i32 addrspace(1)* %out |
| 45 | ret void |
| 46 | } |
| 47 | |
| 48 | ; GCN-LABEL: add_i32_varying_vdata: |
| 49 | ; GFX7LESS-NOT: v_mbcnt_lo_u32_b32 |
| 50 | ; GFX7LESS-NOT: v_mbcnt_hi_u32_b32 |
| 51 | ; GFX7LESS-NOT: s_bcnt1_i32_b64 |
| 52 | ; GFX7LESS: buffer_atomic_add v{{[0-9]+}} |
Jay Foad | eac2386 | 2019-08-23 10:07:43 +0000 | [diff] [blame] | 53 | ; GFX8MORE: v_mov_b32_dpp v{{[0-9]+}}, v{{[0-9]+}} row_shr:1 row_mask:0xf bank_mask:0xf |
| 54 | ; GFX8MORE: v_mov_b32_dpp v{{[0-9]+}}, v{{[0-9]+}} row_shr:2 row_mask:0xf bank_mask:0xf |
| 55 | ; GFX8MORE: v_mov_b32_dpp v{{[0-9]+}}, v{{[0-9]+}} row_shr:4 row_mask:0xf bank_mask:0xf |
| 56 | ; GFX8MORE: v_mov_b32_dpp v{{[0-9]+}}, v{{[0-9]+}} row_shr:8 row_mask:0xf bank_mask:0xf |
| 57 | ; GFX89: v_mov_b32_dpp v{{[0-9]+}}, v{{[0-9]+}} row_bcast:15 row_mask:0xa bank_mask:0xf |
| 58 | ; GFX89: v_mov_b32_dpp v{{[0-9]+}}, v{{[0-9]+}} row_bcast:31 row_mask:0xc bank_mask:0xf |
| 59 | ; GFX8MORE32: v_readlane_b32 s[[scalar_value:[0-9]+]], v{{[0-9]+}}, 31 |
| 60 | ; GFX8MORE64: v_readlane_b32 s[[scalar_value:[0-9]+]], v{{[0-9]+}}, 63 |
| 61 | ; GFX89: v_mov_b32_dpp v{{[0-9]+}}, v{{[0-9]+}} wave_shr:1 row_mask:0xf bank_mask:0xf |
Neil Henning | 6641657 | 2018-10-08 15:49:19 +0000 | [diff] [blame] | 62 | ; GFX8MORE: v_mov_b32{{(_e[0-9]+)?}} v[[value:[0-9]+]], s[[scalar_value]] |
| 63 | ; GFX8MORE: buffer_atomic_add v[[value]] |
| 64 | define amdgpu_kernel void @add_i32_varying_vdata(i32 addrspace(1)* %out, <4 x i32> %inout) { |
| 65 | entry: |
| 66 | %lane = call i32 @llvm.amdgcn.workitem.id.x() |
| 67 | %old = call i32 @llvm.amdgcn.buffer.atomic.add(i32 %lane, <4 x i32> %inout, i32 0, i32 0, i1 0) |
| 68 | store i32 %old, i32 addrspace(1)* %out |
| 69 | ret void |
| 70 | } |
| 71 | |
| 72 | ; GCN-LABEL: add_i32_varying_offset: |
| 73 | ; GCN-NOT: v_mbcnt_lo_u32_b32 |
| 74 | ; GCN-NOT: v_mbcnt_hi_u32_b32 |
| 75 | ; GCN-NOT: s_bcnt1_i32_b64 |
| 76 | ; GCN: buffer_atomic_add v{{[0-9]+}} |
| 77 | define amdgpu_kernel void @add_i32_varying_offset(i32 addrspace(1)* %out, <4 x i32> %inout) { |
| 78 | entry: |
| 79 | %lane = call i32 @llvm.amdgcn.workitem.id.x() |
| 80 | %old = call i32 @llvm.amdgcn.buffer.atomic.add(i32 1, <4 x i32> %inout, i32 %lane, i32 0, i1 0) |
| 81 | store i32 %old, i32 addrspace(1)* %out |
| 82 | ret void |
| 83 | } |
| 84 | |
| 85 | ; GCN-LABEL: sub_i32_constant: |
Jay Foad | eac2386 | 2019-08-23 10:07:43 +0000 | [diff] [blame] | 86 | ; GCN32: v_cmp_ne_u32_e64 s[[exec_lo:[0-9]+]], 1, 0 |
| 87 | ; GCN64: v_cmp_ne_u32_e64 s{{\[}}[[exec_lo:[0-9]+]]:[[exec_hi:[0-9]+]]{{\]}}, 1, 0 |
| 88 | ; GCN: v_mbcnt_lo_u32_b32{{(_e[0-9]+)?}} v[[mbcnt:[0-9]+]], s[[exec_lo]], 0 |
| 89 | ; GCN64: v_mbcnt_hi_u32_b32{{(_e[0-9]+)?}} v[[mbcnt]], s[[exec_hi]], v[[mbcnt]] |
| 90 | ; GCN: v_cmp_eq_u32{{(_e[0-9]+)?}} vcc{{(_lo)?}}, 0, v[[mbcnt]] |
| 91 | ; GCN32: s_bcnt1_i32_b32 s[[popcount:[0-9]+]], s[[exec_lo]] |
| 92 | ; GCN64: s_bcnt1_i32_b64 s[[popcount:[0-9]+]], s{{\[}}[[exec_lo]]:[[exec_hi]]{{\]}} |
Neil Henning | 6641657 | 2018-10-08 15:49:19 +0000 | [diff] [blame] | 93 | ; GCN: v_mul_u32_u24{{(_e[0-9]+)?}} v[[value:[0-9]+]], s[[popcount]], 5 |
| 94 | ; GCN: buffer_atomic_sub v[[value]] |
| 95 | define amdgpu_kernel void @sub_i32_constant(i32 addrspace(1)* %out, <4 x i32> %inout) { |
| 96 | entry: |
| 97 | %old = call i32 @llvm.amdgcn.buffer.atomic.sub(i32 5, <4 x i32> %inout, i32 0, i32 0, i1 0) |
| 98 | store i32 %old, i32 addrspace(1)* %out |
| 99 | ret void |
| 100 | } |
| 101 | |
| 102 | ; GCN-LABEL: sub_i32_uniform: |
Jay Foad | eac2386 | 2019-08-23 10:07:43 +0000 | [diff] [blame] | 103 | ; GCN32: v_cmp_ne_u32_e64 s[[exec_lo:[0-9]+]], 1, 0 |
| 104 | ; GCN64: v_cmp_ne_u32_e64 s{{\[}}[[exec_lo:[0-9]+]]:[[exec_hi:[0-9]+]]{{\]}}, 1, 0 |
| 105 | ; GCN: v_mbcnt_lo_u32_b32{{(_e[0-9]+)?}} v[[mbcnt:[0-9]+]], s[[exec_lo]], 0 |
| 106 | ; GCN64: v_mbcnt_hi_u32_b32{{(_e[0-9]+)?}} v[[mbcnt]], s[[exec_hi]], v[[mbcnt]] |
| 107 | ; GCN: v_cmp_eq_u32{{(_e[0-9]+)?}} vcc{{(_lo)?}}, 0, v[[mbcnt]] |
| 108 | ; GCN32: s_bcnt1_i32_b32 s[[popcount:[0-9]+]], s[[exec_lo]] |
| 109 | ; GCN64: s_bcnt1_i32_b64 s[[popcount:[0-9]+]], s{{\[}}[[exec_lo]]:[[exec_hi]]{{\]}} |
Neil Henning | 6641657 | 2018-10-08 15:49:19 +0000 | [diff] [blame] | 110 | ; GCN: s_mul_i32 s[[scalar_value:[0-9]+]], s{{[0-9]+}}, s[[popcount]] |
| 111 | ; GCN: v_mov_b32{{(_e[0-9]+)?}} v[[value:[0-9]+]], s[[scalar_value]] |
| 112 | ; GCN: buffer_atomic_sub v[[value]] |
| 113 | define amdgpu_kernel void @sub_i32_uniform(i32 addrspace(1)* %out, <4 x i32> %inout, i32 %subitive) { |
| 114 | entry: |
| 115 | %old = call i32 @llvm.amdgcn.buffer.atomic.sub(i32 %subitive, <4 x i32> %inout, i32 0, i32 0, i1 0) |
| 116 | store i32 %old, i32 addrspace(1)* %out |
| 117 | ret void |
| 118 | } |
| 119 | |
| 120 | ; GCN-LABEL: sub_i32_varying_vdata: |
| 121 | ; GFX7LESS-NOT: v_mbcnt_lo_u32_b32 |
| 122 | ; GFX7LESS-NOT: v_mbcnt_hi_u32_b32 |
| 123 | ; GFX7LESS-NOT: s_bcnt1_i32_b64 |
| 124 | ; GFX7LESS: buffer_atomic_sub v{{[0-9]+}} |
Jay Foad | eac2386 | 2019-08-23 10:07:43 +0000 | [diff] [blame] | 125 | ; GFX8MORE: v_mov_b32_dpp v{{[0-9]+}}, v{{[0-9]+}} row_shr:1 row_mask:0xf bank_mask:0xf |
| 126 | ; GFX8MORE: v_mov_b32_dpp v{{[0-9]+}}, v{{[0-9]+}} row_shr:2 row_mask:0xf bank_mask:0xf |
| 127 | ; GFX8MORE: v_mov_b32_dpp v{{[0-9]+}}, v{{[0-9]+}} row_shr:4 row_mask:0xf bank_mask:0xf |
| 128 | ; GFX8MORE: v_mov_b32_dpp v{{[0-9]+}}, v{{[0-9]+}} row_shr:8 row_mask:0xf bank_mask:0xf |
| 129 | ; GFX89: v_mov_b32_dpp v{{[0-9]+}}, v{{[0-9]+}} row_bcast:15 row_mask:0xa bank_mask:0xf |
| 130 | ; GFX89: v_mov_b32_dpp v{{[0-9]+}}, v{{[0-9]+}} row_bcast:31 row_mask:0xc bank_mask:0xf |
| 131 | ; GFX8MORE32: v_readlane_b32 s[[scalar_value:[0-9]+]], v{{[0-9]+}}, 31 |
| 132 | ; GFX8MORE64: v_readlane_b32 s[[scalar_value:[0-9]+]], v{{[0-9]+}}, 63 |
| 133 | ; GFX89: v_mov_b32_dpp v{{[0-9]+}}, v{{[0-9]+}} wave_shr:1 row_mask:0xf bank_mask:0xf |
Neil Henning | 6641657 | 2018-10-08 15:49:19 +0000 | [diff] [blame] | 134 | ; GFX8MORE: v_mov_b32{{(_e[0-9]+)?}} v[[value:[0-9]+]], s[[scalar_value]] |
| 135 | ; GFX8MORE: buffer_atomic_sub v[[value]] |
| 136 | define amdgpu_kernel void @sub_i32_varying_vdata(i32 addrspace(1)* %out, <4 x i32> %inout) { |
| 137 | entry: |
| 138 | %lane = call i32 @llvm.amdgcn.workitem.id.x() |
| 139 | %old = call i32 @llvm.amdgcn.buffer.atomic.sub(i32 %lane, <4 x i32> %inout, i32 0, i32 0, i1 0) |
| 140 | store i32 %old, i32 addrspace(1)* %out |
| 141 | ret void |
| 142 | } |
| 143 | |
| 144 | ; GCN-LABEL: sub_i32_varying_offset: |
| 145 | ; GCN-NOT: v_mbcnt_lo_u32_b32 |
| 146 | ; GCN-NOT: v_mbcnt_hi_u32_b32 |
| 147 | ; GCN-NOT: s_bcnt1_i32_b64 |
| 148 | ; GCN: buffer_atomic_sub v{{[0-9]+}} |
| 149 | define amdgpu_kernel void @sub_i32_varying_offset(i32 addrspace(1)* %out, <4 x i32> %inout) { |
| 150 | entry: |
| 151 | %lane = call i32 @llvm.amdgcn.workitem.id.x() |
| 152 | %old = call i32 @llvm.amdgcn.buffer.atomic.sub(i32 1, <4 x i32> %inout, i32 %lane, i32 0, i1 0) |
| 153 | store i32 %old, i32 addrspace(1)* %out |
| 154 | ret void |
| 155 | } |