; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc -mtriple=amdgcn-amd-amdpal < %s | FileCheck -check-prefix=GCN %s

define amdgpu_kernel void @global_atomic_fadd_ret_f32_wrong_subtarget(ptr addrspace(1) %ptr) #1 {
; GCN-LABEL: global_atomic_fadd_ret_f32_wrong_subtarget:
; GCN:       ; %bb.0:
; GCN-NEXT:    s_mov_b64 s[0:1], exec
; GCN-NEXT:    v_mbcnt_lo_u32_b32 v0, s0, 0
; GCN-NEXT:    v_mbcnt_hi_u32_b32 v0, s1, v0
; GCN-NEXT:    v_cmp_eq_u32_e32 vcc, 0, v0
; GCN-NEXT:    ; implicit-def: $vgpr1
; GCN-NEXT:    s_and_saveexec_b64 s[2:3], vcc
; GCN-NEXT:    s_cbranch_execz .LBB0_4
; GCN-NEXT:  ; %bb.1:
; GCN-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x0
; GCN-NEXT:    s_bcnt1_i32_b64 s0, s[0:1]
; GCN-NEXT:    v_cvt_f32_ubyte0_e32 v1, s0
; GCN-NEXT:    s_mov_b64 s[6:7], 0
; GCN-NEXT:    v_mul_f32_e32 v2, 4.0, v1
; GCN-NEXT:    s_waitcnt lgkmcnt(0)
; GCN-NEXT:    s_load_dword s8, s[4:5], 0x0
; GCN-NEXT:    v_mov_b32_e32 v3, 0
; GCN-NEXT:    s_waitcnt lgkmcnt(0)
; GCN-NEXT:    v_mov_b32_e32 v1, s8
; GCN-NEXT:  .LBB0_2: ; %atomicrmw.start
; GCN-NEXT:    ; =>This Inner Loop Header: Depth=1
; GCN-NEXT:    v_mov_b32_e32 v5, v1
; GCN-NEXT:    v_add_f32_e32 v4, v5, v2
; GCN-NEXT:    global_atomic_cmpswap v1, v3, v[4:5], s[4:5] glc
; GCN-NEXT:    s_waitcnt vmcnt(0)
; GCN-NEXT:    buffer_wbinvl1
; GCN-NEXT:    v_cmp_eq_u32_e64 s[0:1], v1, v5
; GCN-NEXT:    s_or_b64 s[6:7], s[0:1], s[6:7]
; GCN-NEXT:    s_andn2_b64 exec, exec, s[6:7]
; GCN-NEXT:    s_cbranch_execnz .LBB0_2
; GCN-NEXT:  ; %bb.3: ; %Flow
; GCN-NEXT:    s_or_b64 exec, exec, s[6:7]
; GCN-NEXT:  .LBB0_4: ; %Flow2
; GCN-NEXT:    s_or_b64 exec, exec, s[2:3]
; GCN-NEXT:    v_readfirstlane_b32 s0, v1
; GCN-NEXT:    v_cvt_f32_ubyte0_e32 v0, v0
; GCN-NEXT:    v_mov_b32_e32 v1, s0
; GCN-NEXT:    v_mad_f32 v0, v0, 4.0, s0
; GCN-NEXT:    v_cndmask_b32_e32 v0, v0, v1, vcc
; GCN-NEXT:    global_store_dword v[0:1], v0, off
; GCN-NEXT:    s_endpgm
  %result = atomicrmw fadd ptr addrspace(1) %ptr, float 4.0 syncscope("agent") seq_cst, !amdgpu.no.fine.grained.memory !0, !amdgpu.ignore.denormal.mode !0
  store float %result, ptr addrspace(1) undef
  ret void
}

define amdgpu_kernel void @global_atomic_fadd_noret_f32_wrong_subtarget(ptr addrspace(1) %ptr) #1 {
; GCN-LABEL: global_atomic_fadd_noret_f32_wrong_subtarget:
; GCN:       ; %bb.0:
; GCN-NEXT:    s_mov_b64 s[0:1], exec
; GCN-NEXT:    v_mbcnt_lo_u32_b32 v0, s0, 0
; GCN-NEXT:    v_mbcnt_hi_u32_b32 v0, s1, v0
; GCN-NEXT:    v_cmp_eq_u32_e32 vcc, 0, v0
; GCN-NEXT:    s_and_saveexec_b64 s[2:3], vcc
; GCN-NEXT:    s_cbranch_execz .LBB1_2
; GCN-NEXT:  ; %bb.1:
; GCN-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
; GCN-NEXT:    s_bcnt1_i32_b64 s0, s[0:1]
; GCN-NEXT:    v_cvt_f32_ubyte0_e32 v1, s0
; GCN-NEXT:    v_mov_b32_e32 v0, 0
; GCN-NEXT:    v_mul_f32_e32 v1, 4.0, v1
; GCN-NEXT:    s_waitcnt lgkmcnt(0)
; GCN-NEXT:    global_atomic_add_f32 v0, v1, s[2:3]
; GCN-NEXT:    s_waitcnt vmcnt(0)
; GCN-NEXT:    buffer_wbinvl1
; GCN-NEXT:  .LBB1_2:
; GCN-NEXT:    s_endpgm
  %result = atomicrmw fadd ptr addrspace(1) %ptr, float 4.0 syncscope("agent") seq_cst, !amdgpu.no.fine.grained.memory !0, !amdgpu.ignore.denormal.mode !0
  ret void
}

attributes #1 = { "denormal-fp-math-f32"="preserve-sign,preserve-sign" "target-cpu"="gfx803" "target-features"="+atomic-fadd-no-rtn-insts" }

!0 = !{}
