1; RUN: llc -mtriple=amdgcn-- -amdgpu-atomic-optimizations=true -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GFX7LESS %s 2; RUN: llc -mtriple=amdgcn-- -mcpu=tonga -mattr=-flat-for-global -amdgpu-atomic-optimizations=true -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GFX8MORE %s 3; RUN: llc -mtriple=amdgcn-- -mcpu=gfx900 -mattr=-flat-for-global -amdgpu-atomic-optimizations=true -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GFX8MORE %s 4 5declare i1 @llvm.amdgcn.wqm.vote(i1) 6declare i32 @llvm.amdgcn.buffer.atomic.add(i32, <4 x i32>, i32, i32, i1) 7declare void @llvm.amdgcn.buffer.store.f32(float, <4 x i32>, i32, i32, i1, i1) 8 9; Show that what the atomic optimization pass will do for raw buffers. 10 11; GCN-LABEL: add_i32_constant: 12; GCN-LABEL: BB0_1: 13; GCN: s_mov_b64 s{{\[}}[[exec_lo:[0-9]+]]:[[exec_hi:[0-9]+]]{{\]}}, exec 14; GCN: v_mbcnt_lo_u32_b32{{(_e[0-9]+)?}} v[[mbcnt_lo:[0-9]+]], s[[exec_lo]], 0 15; GCN: v_mbcnt_hi_u32_b32{{(_e[0-9]+)?}} v[[mbcnt_hi:[0-9]+]], s[[exec_hi]], v[[mbcnt_lo]] 16; GCN: v_cmp_eq_u32{{(_e[0-9]+)?}} vcc, 0, v[[mbcnt_hi]] 17; GCN: s_bcnt1_i32_b64 s[[popcount:[0-9]+]], s{{\[}}[[exec_lo]]:[[exec_hi]]{{\]}} 18; GCN: v_mul_u32_u24{{(_e[0-9]+)?}} v[[value:[0-9]+]], s[[popcount]], 5 19; GCN: buffer_atomic_add v[[value]] 20; GCN: v_readfirstlane_b32 s{{[0-9]+}}, v[[value]] 21define amdgpu_ps void @add_i32_constant(<4 x i32> inreg %out, <4 x i32> inreg %inout) { 22entry: 23 %cond1 = call i1 @llvm.amdgcn.wqm.vote(i1 true) 24 %old = call i32 @llvm.amdgcn.buffer.atomic.add(i32 5, <4 x i32> %inout, i32 0, i32 0, i1 0) 25 %cond2 = call i1 @llvm.amdgcn.wqm.vote(i1 true) 26 %cond = and i1 %cond1, %cond2 27 br i1 %cond, label %if, label %else 28if: 29 %bitcast = bitcast i32 %old to float 30 call void @llvm.amdgcn.buffer.store.f32(float %bitcast, <4 x i32> %out, i32 0, i32 0, i1 0, i1 0) 31 ret void 32else: 33 ret void 34} 35 36; GCN-LABEL: add_i32_varying: 37; GFX7LESS-NOT: v_mbcnt_lo_u32_b32 38; GFX7LESS-NOT: v_mbcnt_hi_u32_b32 39; GFX8MORE: v_mbcnt_lo_u32_b32{{(_e[0-9]+)?}} v[[mbcnt_lo:[0-9]+]], exec_lo, 0 40; GFX8MORE: v_mbcnt_hi_u32_b32{{(_e[0-9]+)?}} v[[mbcnt_hi:[0-9]+]], exec_hi, v[[mbcnt_lo]] 41; GFX8MORE: v_readlane_b32 s[[scalar_value:[0-9]+]], v{{[0-9]+}}, 63 42; GFX8MORE: v_cmp_eq_u32{{(_e[0-9]+)?}} vcc, 0, v[[mbcnt_hi]] 43; GFX8MORE: v_mov_b32{{(_e[0-9]+)?}} v[[value:[0-9]+]], s[[scalar_value]] 44; GFX8MORE: buffer_atomic_add v[[value]] 45; GFX8MORE: v_readfirstlane_b32 s{{[0-9]+}}, v[[value]] 46define amdgpu_ps void @add_i32_varying(<4 x i32> inreg %out, <4 x i32> inreg %inout, i32 %val) { 47entry: 48 %cond1 = call i1 @llvm.amdgcn.wqm.vote(i1 true) 49 %old = call i32 @llvm.amdgcn.buffer.atomic.add(i32 %val, <4 x i32> %inout, i32 0, i32 0, i1 0) 50 %cond2 = call i1 @llvm.amdgcn.wqm.vote(i1 true) 51 %cond = and i1 %cond1, %cond2 52 br i1 %cond, label %if, label %else 53if: 54 %bitcast = bitcast i32 %old to float 55 call void @llvm.amdgcn.buffer.store.f32(float %bitcast, <4 x i32> %out, i32 0, i32 0, i1 0, i1 0) 56 ret void 57else: 58 ret void 59} 60