1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 < %s | FileCheck %s -check-prefix=MUBUF
3; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -amdgpu-enable-flat-scratch < %s | FileCheck %s -check-prefix=FLATSCR
4
5; Make sure there's no assertion from passing a 0 alignment value
6define void @memcpy_fixed_align(i8 addrspace(5)*  %dst, i8 addrspace(1)* %src) {
7; MUBUF-LABEL: memcpy_fixed_align:
8; MUBUF:       ; %bb.0:
9; MUBUF-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
10; MUBUF-NEXT:    global_load_dword v0, v[1:2], off offset:36
11; MUBUF-NEXT:    global_load_dword v11, v[1:2], off offset:32
12; MUBUF-NEXT:    global_load_dwordx4 v[3:6], v[1:2], off offset:16
13; MUBUF-NEXT:    global_load_dwordx4 v[7:10], v[1:2], off
14; MUBUF-NEXT:    s_waitcnt vmcnt(3)
15; MUBUF-NEXT:    buffer_store_dword v0, off, s[0:3], s32 offset:36
16; MUBUF-NEXT:    s_waitcnt vmcnt(3)
17; MUBUF-NEXT:    buffer_store_dword v11, off, s[0:3], s32 offset:32
18; MUBUF-NEXT:    s_waitcnt vmcnt(3)
19; MUBUF-NEXT:    buffer_store_dword v6, off, s[0:3], s32 offset:28
20; MUBUF-NEXT:    buffer_store_dword v5, off, s[0:3], s32 offset:24
21; MUBUF-NEXT:    buffer_store_dword v4, off, s[0:3], s32 offset:20
22; MUBUF-NEXT:    buffer_store_dword v3, off, s[0:3], s32 offset:16
23; MUBUF-NEXT:    s_waitcnt vmcnt(6)
24; MUBUF-NEXT:    buffer_store_dword v10, off, s[0:3], s32 offset:12
25; MUBUF-NEXT:    buffer_store_dword v9, off, s[0:3], s32 offset:8
26; MUBUF-NEXT:    buffer_store_dword v8, off, s[0:3], s32 offset:4
27; MUBUF-NEXT:    buffer_store_dword v7, off, s[0:3], s32
28; MUBUF-NEXT:    s_waitcnt vmcnt(0)
29; MUBUF-NEXT:    s_setpc_b64 s[30:31]
30;
31; FLATSCR-LABEL: memcpy_fixed_align:
32; FLATSCR:       ; %bb.0:
33; FLATSCR-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
34; FLATSCR-NEXT:    global_load_dword v0, v[1:2], off offset:36
35; FLATSCR-NEXT:    global_load_dword v11, v[1:2], off offset:32
36; FLATSCR-NEXT:    global_load_dwordx4 v[3:6], v[1:2], off offset:16
37; FLATSCR-NEXT:    global_load_dwordx4 v[7:10], v[1:2], off
38; FLATSCR-NEXT:    s_waitcnt vmcnt(3)
39; FLATSCR-NEXT:    scratch_store_dword off, v0, s32 offset:36
40; FLATSCR-NEXT:    s_waitcnt vmcnt(3)
41; FLATSCR-NEXT:    scratch_store_dword off, v11, s32 offset:32
42; FLATSCR-NEXT:    s_waitcnt vmcnt(3)
43; FLATSCR-NEXT:    scratch_store_dword off, v6, s32 offset:28
44; FLATSCR-NEXT:    scratch_store_dword off, v5, s32 offset:24
45; FLATSCR-NEXT:    scratch_store_dword off, v4, s32 offset:20
46; FLATSCR-NEXT:    scratch_store_dword off, v3, s32 offset:16
47; FLATSCR-NEXT:    s_waitcnt vmcnt(6)
48; FLATSCR-NEXT:    scratch_store_dword off, v10, s32 offset:12
49; FLATSCR-NEXT:    scratch_store_dword off, v9, s32 offset:8
50; FLATSCR-NEXT:    scratch_store_dword off, v8, s32 offset:4
51; FLATSCR-NEXT:    scratch_store_dword off, v7, s32
52; FLATSCR-NEXT:    s_waitcnt vmcnt(0)
53; FLATSCR-NEXT:    s_setpc_b64 s[30:31]
54  %alloca = alloca [40 x i8], addrspace(5)
55  %cast = bitcast [40 x i8] addrspace(5)* %alloca to i8 addrspace(5)*
56  call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)* align 4 dereferenceable(40) %cast, i8 addrspace(1)* align 4 dereferenceable(40) %src, i64 40, i1 false)
57  ret void
58}
59
60declare void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)* noalias nocapture writeonly, i8 addrspace(1)* noalias nocapture readonly, i64, i1 immarg) #0
61
62attributes #0 = { argmemonly nounwind willreturn }
63