1; RUN: llc -march=hexagon < %s | FileCheck %s
2;
3; Bug 6840. Use absolute+index addressing.
4
5@ga = common global [1024 x i8] zeroinitializer, align 8
6
7; CHECK-LABEL: test0
8; CHECK: memub(r{{[0-9]+}}+##ga)
9define zeroext i8 @test0(i32 %i) nounwind readonly {
10entry:
11  %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %i
12  %0 = load i8, i8* %t, align 1
13  ret i8 %0
14}
15
16; CHECK-LABEL: test1
17; CHECK: memb(r{{[0-9]+}}+##ga)
18define signext i8 @test1(i32 %i) nounwind readonly {
19entry:
20  %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %i
21  %0 = load i8, i8* %t, align 1
22  ret i8 %0
23}
24
25; CHECK-LABEL: test2
26; CHECK: memub(r{{[0-9]+}}<<#1+##ga)
27define zeroext i8 @test2(i32 %i) nounwind readonly {
28entry:
29  %j = shl nsw i32 %i, 1
30  %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %j
31  %0 = load i8, i8* %t, align 1
32  ret i8 %0
33}
34
35; CHECK-LABEL: test3
36; CHECK: memb(r{{[0-9]+}}<<#1+##ga)
37define signext i8 @test3(i32 %i) nounwind readonly {
38entry:
39  %j = shl nsw i32 %i, 1
40  %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %j
41  %0 = load i8, i8* %t, align 1
42  ret i8 %0
43}
44
45; CHECK-LABEL: test4
46; CHECK: memub(r{{[0-9]+}}<<#2+##ga)
47define zeroext i8 @test4(i32 %i) nounwind readonly {
48entry:
49  %j = shl nsw i32 %i, 2
50  %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %j
51  %0 = load i8, i8* %t, align 1
52  ret i8 %0
53}
54
55; CHECK-LABEL: test5
56; CHECK: memb(r{{[0-9]+}}<<#2+##ga)
57define signext i8 @test5(i32 %i) nounwind readonly {
58entry:
59  %j = shl nsw i32 %i, 2
60  %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %j
61  %0 = load i8, i8* %t, align 1
62  ret i8 %0
63}
64
65; CHECK-LABEL: test10
66; CHECK: memb(r{{[0-9]+}}+##ga)
67define void @test10(i32 %i, i8 zeroext %v) nounwind {
68entry:
69  %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %i
70  store i8 %v, i8* %t, align 1
71  ret void
72}
73
74; CHECK-LABEL: test11
75; CHECK: memb(r{{[0-9]+}}<<#1+##ga)
76define void @test11(i32 %i, i8 signext %v) nounwind {
77entry:
78  %j = shl nsw i32 %i, 1
79  %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %j
80  store i8 %v, i8* %t, align 1
81  ret void
82}
83
84; CHECK-LABEL: test12
85; CHECK: memb(r{{[0-9]+}}<<#2+##ga)
86define void @test12(i32 %i, i8 zeroext %v) nounwind {
87entry:
88  %j = shl nsw i32 %i, 2
89  %t = getelementptr inbounds [1024 x i8], [1024 x i8]* @ga, i32 0, i32 %j
90  store i8 %v, i8* %t, align 1
91  ret void
92}
93