• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s
2
3define i32 @f1(i32* %v) {
4entry:
5; CHECK: f1:
6; CHECK: ldr r0, [r0]
7        %tmp = load i32* %v
8        ret i32 %tmp
9}
10
11define i32 @f2(i32* %v) {
12entry:
13; CHECK: f2:
14; CHECK: ldr.w r0, [r0, #4092]
15        %tmp2 = getelementptr i32* %v, i32 1023
16        %tmp = load i32* %tmp2
17        ret i32 %tmp
18}
19
20define i32 @f3(i32* %v) {
21entry:
22; CHECK: f3:
23; CHECK: mov.w r1, #4096
24; CHECK: ldr r0, [r0, r1]
25        %tmp2 = getelementptr i32* %v, i32 1024
26        %tmp = load i32* %tmp2
27        ret i32 %tmp
28}
29
30define i32 @f4(i32 %base) {
31entry:
32; CHECK: f4:
33; CHECK: ldr r0, [r0, #-128]
34        %tmp1 = sub i32 %base, 128
35        %tmp2 = inttoptr i32 %tmp1 to i32*
36        %tmp3 = load i32* %tmp2
37        ret i32 %tmp3
38}
39
40define i32 @f5(i32 %base, i32 %offset) {
41entry:
42; CHECK: f5:
43; CHECK: ldr r0, [r0, r1]
44        %tmp1 = add i32 %base, %offset
45        %tmp2 = inttoptr i32 %tmp1 to i32*
46        %tmp3 = load i32* %tmp2
47        ret i32 %tmp3
48}
49
50define i32 @f6(i32 %base, i32 %offset) {
51entry:
52; CHECK: f6:
53; CHECK: ldr.w r0, [r0, r1, lsl #2]
54        %tmp1 = shl i32 %offset, 2
55        %tmp2 = add i32 %base, %tmp1
56        %tmp3 = inttoptr i32 %tmp2 to i32*
57        %tmp4 = load i32* %tmp3
58        ret i32 %tmp4
59}
60
61define i32 @f7(i32 %base, i32 %offset) {
62entry:
63; CHECK: f7:
64; CHECK: lsrs r1, r1, #2
65; CHECK: ldr r0, [r0, r1]
66
67        %tmp1 = lshr i32 %offset, 2
68        %tmp2 = add i32 %base, %tmp1
69        %tmp3 = inttoptr i32 %tmp2 to i32*
70        %tmp4 = load i32* %tmp3
71        ret i32 %tmp4
72}
73