1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -global-isel -march=amdgcn -verify-machineinstrs -amdgpu-mem-intrinsic-expand-size=3 %s -o - | FileCheck -check-prefix=LOOP %s
3; RUN: llc -global-isel -march=amdgcn -verify-machineinstrs -amdgpu-mem-intrinsic-expand-size=5 %s -o - | FileCheck -check-prefix=UNROLL %s
4
5declare void @llvm.memset.p1i8.i32(i8 addrspace(1)*, i8, i32, i1)
6
7define amdgpu_cs void @memset_p1i8(i8 addrspace(1)* %dst, i8 %val) {
8; LOOP-LABEL: memset_p1i8:
9; LOOP:       ; %bb.0: ; %loadstoreloop.preheader
10; LOOP-NEXT:    s_mov_b64 s[0:1], 0
11; LOOP-NEXT:    s_mov_b32 s2, 0
12; LOOP-NEXT:    s_mov_b32 s3, 0xf000
13; LOOP-NEXT:    v_mov_b32_e32 v4, s1
14; LOOP-NEXT:    v_mov_b32_e32 v3, s0
15; LOOP-NEXT:  BB0_1: ; %loadstoreloop
16; LOOP-NEXT:    ; =>This Inner Loop Header: Depth=1
17; LOOP-NEXT:    v_add_i32_e32 v5, vcc, v0, v3
18; LOOP-NEXT:    v_addc_u32_e32 v6, vcc, v1, v4, vcc
19; LOOP-NEXT:    v_add_i32_e32 v3, vcc, 1, v3
20; LOOP-NEXT:    v_addc_u32_e32 v4, vcc, 0, v4, vcc
21; LOOP-NEXT:    v_cmp_gt_u32_e32 vcc, 4, v3
22; LOOP-NEXT:    buffer_store_byte v2, v[5:6], s[0:3], 0 addr64
23; LOOP-NEXT:    s_cbranch_vccnz BB0_1
24; LOOP-NEXT:  ; %bb.2: ; %split
25; LOOP-NEXT:    s_endpgm
26;
27; UNROLL-LABEL: memset_p1i8:
28; UNROLL:       ; %bb.0:
29; UNROLL-NEXT:    s_mov_b32 s2, 0
30; UNROLL-NEXT:    s_mov_b32 s3, 0xf000
31; UNROLL-NEXT:    s_mov_b64 s[0:1], 0
32; UNROLL-NEXT:    buffer_store_byte v2, v[0:1], s[0:3], 0 addr64
33; UNROLL-NEXT:    buffer_store_byte v2, v[0:1], s[0:3], 0 addr64 offset:1
34; UNROLL-NEXT:    buffer_store_byte v2, v[0:1], s[0:3], 0 addr64 offset:2
35; UNROLL-NEXT:    buffer_store_byte v2, v[0:1], s[0:3], 0 addr64 offset:3
36; UNROLL-NEXT:    s_endpgm
37  call void @llvm.memset.p1i8.i32(i8 addrspace(1)* %dst, i8 %val, i32 4, i1 false)
38  ret void
39}
40