|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3 |
| 2 | +; RUN: llc -march=amdgcn -mcpu=gfx1100 -verify-machineinstrs < %s | FileCheck %s -check-prefixes=GCN |
| 3 | +; RUN: llc -global-isel -march=amdgcn -mcpu=gfx1100 -verify-machineinstrs < %s | FileCheck %s -check-prefixes=GISEL |
| 4 | + |
| 5 | +define amdgpu_gfx i32 @sink_scratch_pointer(ptr addrspace(5) %stack, i32 inreg %flag) { |
| 6 | +; GCN-LABEL: sink_scratch_pointer: |
| 7 | +; GCN: ; %bb.0: |
| 8 | +; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 9 | +; GCN-NEXT: v_add_nc_u32_e32 v0, -4, v0 |
| 10 | +; GCN-NEXT: s_cmp_lg_u32 s4, 0 |
| 11 | +; GCN-NEXT: s_cbranch_scc0 .LBB0_2 |
| 12 | +; GCN-NEXT: ; %bb.1: ; %bb2 |
| 13 | +; GCN-NEXT: scratch_load_b32 v0, v0, off |
| 14 | +; GCN-NEXT: s_waitcnt vmcnt(0) |
| 15 | +; GCN-NEXT: s_setpc_b64 s[30:31] |
| 16 | +; GCN-NEXT: .LBB0_2: ; %bb1 |
| 17 | +; GCN-NEXT: v_mov_b32_e32 v1, 1 |
| 18 | +; GCN-NEXT: scratch_store_b32 v0, v1, off |
| 19 | +; GCN-NEXT: v_mov_b32_e32 v0, 0 |
| 20 | +; GCN-NEXT: s_setpc_b64 s[30:31] |
| 21 | +; |
| 22 | +; GISEL-LABEL: sink_scratch_pointer: |
| 23 | +; GISEL: ; %bb.0: |
| 24 | +; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 25 | +; GISEL-NEXT: s_cmp_lg_u32 s4, 0 |
| 26 | +; GISEL-NEXT: s_cbranch_scc0 .LBB0_2 |
| 27 | +; GISEL-NEXT: ; %bb.1: ; %bb2 |
| 28 | +; GISEL-NEXT: scratch_load_b32 v0, v0, off offset:-4 |
| 29 | +; GISEL-NEXT: s_waitcnt vmcnt(0) |
| 30 | +; GISEL-NEXT: s_setpc_b64 s[30:31] |
| 31 | +; GISEL-NEXT: .LBB0_2: ; %bb1 |
| 32 | +; GISEL-NEXT: v_mov_b32_e32 v1, 1 |
| 33 | +; GISEL-NEXT: scratch_store_b32 v0, v1, off offset:-4 |
| 34 | +; GISEL-NEXT: v_mov_b32_e32 v0, 0 |
| 35 | +; GISEL-NEXT: s_setpc_b64 s[30:31] |
| 36 | + %ptr = getelementptr inbounds i32, ptr addrspace(5) %stack, i32 -1 |
| 37 | + %cond = icmp eq i32 %flag, 0 |
| 38 | + br i1 %cond, label %bb1, label %bb2 |
| 39 | + |
| 40 | +bb1: |
| 41 | + store i32 1, ptr addrspace(5) %ptr, align 4 |
| 42 | + ret i32 0 |
| 43 | + |
| 44 | +bb2: |
| 45 | + %value = load i32, ptr addrspace(5) %ptr, align 4 |
| 46 | + ret i32 %value |
| 47 | +} |
0 commit comments