1; RUN: llc -march=hexagon -hexagon-small-data-threshold=0 < %s | FileCheck %s
2; Disable small-data, or otherwise g3 will end up in .sdata. While that is
3; not a problem, this test was originally written with the g3 not being in
4; there, so keep it that way.
5
6%s.0 = type { i32, i32, i32, i32, i32, i32 }
7%s.1 = type { i64, i64, i64, i64, i64, i64 }
8%s.2 = type { i16, i16, i16, i16, i16, i16 }
9%s.3 = type { i8, i8, i8, i8, i8, i8 }
10
11@g0 = external global %s.0
12@g1 = external global %s.1
13@g2 = external global %s.2
14@g3 = external global %s.3
15
16; CHECK-LABEL: f0:
17; CHECK: [[REG1:(r[0-9]+)]] = {{[#]+}}g0
18; CHECK: r{{[0-9]+}} = memw([[REG1]]+#{{[0-9]+}})
19; CHECK-NOT: = memd
20; CHECK: dealloc_return
21define i32 @f0() #0 {
22b0:
23  %v0 = alloca %s.0, align 4
24  %v1 = bitcast %s.0* %v0 to i8*
25  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %v1, i8* align 4 bitcast (%s.0* @g0 to i8*), i32 24, i1 false)
26  call void @f1(%s.0* %v0) #0
27  ret i32 0
28}
29
30declare void @f1(%s.0*)
31
32; CHECK-LABEL: f2:
33; CHECK: [[REG2:(r[0-9]+)]] = {{[#]+}}g1
34; CHECK: r{{[0-9]+}}:{{[0-9]+}} = memd([[REG2]]+#{{[0-9]+}})
35; CHECK: dealloc_return
36define i32 @f2() #0 {
37b0:
38  %v0 = alloca %s.1, align 8
39  %v1 = bitcast %s.1* %v0 to i8*
40  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %v1, i8* align 8 bitcast (%s.1* @g1 to i8*), i32 48, i1 false)
41  call void @f3(%s.1* %v0) #0
42  ret i32 0
43}
44
45declare void @f3(%s.1*)
46
47; CHECK-LABEL: f4:
48; CHECK: [[REG1:(r[0-9]+)]] = {{[#]+}}g2
49; CHECK: r{{[0-9]+}} = mem{{u?}}h([[REG1]]+#{{[0-9]+}})
50; CHECK-NOT: = memd
51; CHECK: dealloc_return
52define i32 @f4() #0 {
53b0:
54  %v0 = alloca %s.2, align 2
55  %v1 = bitcast %s.2* %v0 to i8*
56  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %v1, i8* align 2 bitcast (%s.2* @g2 to i8*), i32 12, i1 false)
57  call void @f5(%s.2* %v0) #0
58  ret i32 0
59}
60
61declare void @f5(%s.2*)
62
63; CHECK-LABEL: f6:
64; CHECK: [[REG1:(r[0-9]+)]] = {{[#]+}}g3
65; CHECK: r{{[0-9]+}} = mem{{u?}}b([[REG1]]+#{{[0-9]+}})
66; CHECK-NOT: = memw
67; CHECK: dealloc_return
68define i32 @f6() #0 {
69b0:
70  %v0 = alloca %s.3, align 1
71  %v1 = getelementptr inbounds %s.3, %s.3* %v0, i32 0, i32 0
72  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %v1, i8* align 1 getelementptr inbounds (%s.3, %s.3* @g3, i32 0, i32 0), i32 6, i1 false)
73  call void @f7(%s.3* %v0) #0
74  ret i32 0
75}
76
77declare void @f7(%s.3*)
78
79declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1) #1
80
81attributes #0 = { nounwind }
82attributes #1 = { argmemonly nounwind }
83