1 ; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=armv7-apple-darwin | FileCheck %s --check-prefix=ARM
4 ; TODO: We currently don't support ldrh/strh for negative offsets. Likely a
5 ; rare case, but possibly worth pursuing. Comments above the test case show
6 ; what could be selected.
9 define zeroext i16 @t1(i16* nocapture %a) nounwind uwtable readonly ssp {
12 %add.ptr = getelementptr inbounds i16* %a, i64 -8
13 %0 = load i16* %add.ptr, align 2
14 ; ARM: mvn r{{[1-9]}}, #15
15 ; ARM: add r0, r0, r{{[1-9]}}
21 define zeroext i16 @t2(i16* nocapture %a) nounwind uwtable readonly ssp {
24 %add.ptr = getelementptr inbounds i16* %a, i64 -16
25 %0 = load i16* %add.ptr, align 2
26 ; ARM: mvn r{{[1-9]}}, #31
27 ; ARM: add r0, r0, r{{[1-9]}}
32 ; ldrh r0, [r0, #-254]
33 define zeroext i16 @t3(i16* nocapture %a) nounwind uwtable readonly ssp {
36 %add.ptr = getelementptr inbounds i16* %a, i64 -127
37 %0 = load i16* %add.ptr, align 2
38 ; ARM: mvn r{{[1-9]}}, #253
39 ; ARM: add r0, r0, r{{[1-9]}}
46 define zeroext i16 @t4(i16* nocapture %a) nounwind uwtable readonly ssp {
49 %add.ptr = getelementptr inbounds i16* %a, i64 -128
50 %0 = load i16* %add.ptr, align 2
51 ; ARM: mvn r{{[1-9]}}, #255
52 ; ARM: add r0, r0, r{{[1-9]}}
57 define zeroext i16 @t5(i16* nocapture %a) nounwind uwtable readonly ssp {
60 %add.ptr = getelementptr inbounds i16* %a, i64 8
61 %0 = load i16* %add.ptr, align 2
62 ; ARM: ldrh r0, [r0, #16]
66 define zeroext i16 @t6(i16* nocapture %a) nounwind uwtable readonly ssp {
69 %add.ptr = getelementptr inbounds i16* %a, i64 16
70 %0 = load i16* %add.ptr, align 2
71 ; ARM: ldrh r0, [r0, #32]
75 define zeroext i16 @t7(i16* nocapture %a) nounwind uwtable readonly ssp {
78 %add.ptr = getelementptr inbounds i16* %a, i64 127
79 %0 = load i16* %add.ptr, align 2
80 ; ARM: ldrh r0, [r0, #254]
84 define zeroext i16 @t8(i16* nocapture %a) nounwind uwtable readonly ssp {
87 %add.ptr = getelementptr inbounds i16* %a, i64 128
88 %0 = load i16* %add.ptr, align 2
89 ; ARM: add r0, r0, #256
95 define void @t9(i16* nocapture %a) nounwind uwtable ssp {
98 %add.ptr = getelementptr inbounds i16* %a, i64 -8
99 store i16 0, i16* %add.ptr, align 2
100 ; ARM: mvn r{{[1-9]}}, #15
101 ; ARM: add r0, r0, r{{[1-9]}}
102 ; ARM: strh r{{[1-9]}}, [r0]
108 define void @t10(i16* nocapture %a) nounwind uwtable ssp {
111 %add.ptr = getelementptr inbounds i16* %a, i64 -128
112 store i16 0, i16* %add.ptr, align 2
113 ; ARM: mvn r{{[1-9]}}, #255
114 ; ARM: add r0, r0, r{{[1-9]}}
115 ; ARM: strh r{{[1-9]}}, [r0]
119 define void @t11(i16* nocapture %a) nounwind uwtable ssp {
122 %add.ptr = getelementptr inbounds i16* %a, i64 8
123 store i16 0, i16* %add.ptr, align 2
124 ; ARM strh r{{[1-9]}}, [r0, #16]
130 define void @t12(i16* nocapture %a) nounwind uwtable ssp {
133 %add.ptr = getelementptr inbounds i16* %a, i64 128
134 store i16 0, i16* %add.ptr, align 2
135 ; ARM: add r0, r0, #256
136 ; ARM: strh r{{[1-9]}}, [r0]