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