1; RUN: llc < %s -O0 -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-ios -verify-machineinstrs | FileCheck %s --check-prefix=THUMB
2
3define i32 @t1(i32* nocapture %ptr) nounwind readonly {
4entry:
5; THUMB-LABEL: t1:
6  %add.ptr = getelementptr inbounds i32, i32* %ptr, i32 -1
7  %0 = load i32, i32* %add.ptr, align 4
8; THUMB: ldr r{{[0-9]}}, [r0, #-4]
9  ret i32 %0
10}
11
12define i32 @t2(i32* nocapture %ptr) nounwind readonly {
13entry:
14; THUMB-LABEL: t2:
15  %add.ptr = getelementptr inbounds i32, i32* %ptr, i32 -63
16  %0 = load i32, i32* %add.ptr, align 4
17; THUMB: ldr r{{[0-9]}}, [r0, #-252]
18  ret i32 %0
19}
20
21define i32 @t3(i32* nocapture %ptr) nounwind readonly {
22entry:
23; THUMB-LABEL: t3:
24  %add.ptr = getelementptr inbounds i32, i32* %ptr, i32 -64
25  %0 = load i32, i32* %add.ptr, align 4
26; THUMB: ldr r{{[0-9]}}, [r0]
27  ret i32 %0
28}
29
30define zeroext i16 @t4(i16* nocapture %ptr) nounwind readonly {
31entry:
32; THUMB-LABEL: t4:
33  %add.ptr = getelementptr inbounds i16, i16* %ptr, i32 -1
34  %0 = load i16, i16* %add.ptr, align 2
35; THUMB: ldrh r{{[0-9]}}, [r0, #-2]
36  ret i16 %0
37}
38
39define zeroext i16 @t5(i16* nocapture %ptr) nounwind readonly {
40entry:
41; THUMB-LABEL: t5:
42  %add.ptr = getelementptr inbounds i16, i16* %ptr, i32 -127
43  %0 = load i16, i16* %add.ptr, align 2
44; THUMB: ldrh r{{[0-9]}}, [r0, #-254]
45  ret i16 %0
46}
47
48define zeroext i16 @t6(i16* nocapture %ptr) nounwind readonly {
49entry:
50; THUMB-LABEL: t6:
51  %add.ptr = getelementptr inbounds i16, i16* %ptr, i32 -128
52  %0 = load i16, i16* %add.ptr, align 2
53; THUMB: ldrh r{{[0-9]}}, [r0]
54  ret i16 %0
55}
56
57define zeroext i8 @t7(i8* nocapture %ptr) nounwind readonly {
58entry:
59; THUMB-LABEL: t7:
60  %add.ptr = getelementptr inbounds i8, i8* %ptr, i32 -1
61  %0 = load i8, i8* %add.ptr, align 1
62; THUMB: ldrb r{{[0-9]}}, [r0, #-1]
63  ret i8 %0
64}
65
66define zeroext i8 @t8(i8* nocapture %ptr) nounwind readonly {
67entry:
68; THUMB-LABEL: t8:
69  %add.ptr = getelementptr inbounds i8, i8* %ptr, i32 -255
70  %0 = load i8, i8* %add.ptr, align 1
71; THUMB: ldrb r{{[0-9]}}, [r0, #-255]
72  ret i8 %0
73}
74
75define zeroext i8 @t9(i8* nocapture %ptr) nounwind readonly {
76entry:
77; THUMB-LABEL: t9:
78  %add.ptr = getelementptr inbounds i8, i8* %ptr, i32 -256
79  %0 = load i8, i8* %add.ptr, align 1
80; THUMB: ldrb r{{[0-9]}}, [r0]
81  ret i8 %0
82}
83
84define void @t10(i32* nocapture %ptr) nounwind {
85entry:
86; THUMB-LABEL: t10:
87  %add.ptr = getelementptr inbounds i32, i32* %ptr, i32 -1
88  store i32 0, i32* %add.ptr, align 4
89; THUMB: mov [[REG:r[0-9]+]], r0
90; THUMB: str r{{[0-9]}}, {{\[}}[[REG]], #-4]
91  ret void
92}
93
94define void @t11(i32* nocapture %ptr) nounwind {
95entry:
96; THUMB-LABEL: t11:
97  %add.ptr = getelementptr inbounds i32, i32* %ptr, i32 -63
98  store i32 0, i32* %add.ptr, align 4
99; THUMB: mov [[REG:r[0-9]+]], r0
100; THUMB: str r{{[0-9]}}, {{\[}}[[REG]], #-252]
101  ret void
102}
103
104define void @t12(i32* nocapture %ptr) nounwind {
105entry:
106; THUMB-LABEL: t12:
107  %add.ptr = getelementptr inbounds i32, i32* %ptr, i32 -64
108  store i32 0, i32* %add.ptr, align 4
109; THUMB: movw [[REG:r[0-9]+]], #65280
110; THUMB: movt [[REG]], #65535
111; THUMB: add [[REG]], r0
112; THUMB: str r{{[0-9]}}, {{\[}}[[REG]]]
113  ret void
114}
115
116define void @t13(i16* nocapture %ptr) nounwind {
117entry:
118; THUMB-LABEL: t13:
119  %add.ptr = getelementptr inbounds i16, i16* %ptr, i32 -1
120  store i16 0, i16* %add.ptr, align 2
121; THUMB: mov [[REG:r[0-9]+]], r0
122; THUMB: strh r{{[0-9]}}, {{\[}}[[REG]], #-2]
123  ret void
124}
125
126define void @t14(i16* nocapture %ptr) nounwind {
127entry:
128; THUMB-LABEL: t14:
129  %add.ptr = getelementptr inbounds i16, i16* %ptr, i32 -127
130  store i16 0, i16* %add.ptr, align 2
131; THUMB: mov [[REG:r[0-9]+]], r0
132; THUMB: strh r{{[0-9]}}, {{\[}}[[REG]], #-254]
133  ret void
134}
135
136define void @t15(i16* nocapture %ptr) nounwind {
137entry:
138; THUMB-LABEL: t15:
139  %add.ptr = getelementptr inbounds i16, i16* %ptr, i32 -128
140  store i16 0, i16* %add.ptr, align 2
141; THUMB: movw [[REG:r[0-9]+]], #65280
142; THUMB: movt [[REG]], #65535
143; THUMB: add [[REG]], r0
144; THUMB: strh r{{[0-9]}}, {{\[}}[[REG]]]
145  ret void
146}
147
148define void @t16(i8* nocapture %ptr) nounwind {
149entry:
150; THUMB-LABEL: t16:
151  %add.ptr = getelementptr inbounds i8, i8* %ptr, i32 -1
152  store i8 0, i8* %add.ptr, align 1
153; THUMB: mov [[REG:r[0-9]+]], r0
154; THUMB: strb r{{[0-9]}}, {{\[}}[[REG]], #-1]
155  ret void
156}
157
158define void @t17(i8* nocapture %ptr) nounwind {
159entry:
160; THUMB-LABEL: t17:
161  %add.ptr = getelementptr inbounds i8, i8* %ptr, i32 -255
162  store i8 0, i8* %add.ptr, align 1
163; THUMB: mov [[REG:r[0-9]+]], r0
164; THUMB: strb r{{[0-9]}}, {{\[}}[[REG]], #-255]
165  ret void
166}
167
168define void @t18(i8* nocapture %ptr) nounwind {
169entry:
170; THUMB-LABEL: t18:
171  %add.ptr = getelementptr inbounds i8, i8* %ptr, i32 -256
172  store i8 0, i8* %add.ptr, align 1
173; THUMB: movw [[REG:r[0-9]+]], #65280
174; THUMB: movt [[REG]], #65535
175; THUMB: add [[REG]], r0
176; THUMB: strb r{{[0-9]}}, {{\[}}[[REG]]]
177  ret void
178}
179