• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple=thumbv4t-none--eabi < %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-V4T
2; RUN: llc -mtriple=thumbv6m-none--eabi < %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-V6M
3
4; CHECK-LABEL: test1
5define i32 @test1(i32* %p) {
6
7; Offsets less than 8 can be generated in a single add
8; CHECK: adds [[NEWBASE:r[0-9]]], r0, #4
9  %1 = getelementptr inbounds i32, i32* %p, i32 1
10  %2 = getelementptr inbounds i32, i32* %p, i32 2
11  %3 = getelementptr inbounds i32, i32* %p, i32 3
12  %4 = getelementptr inbounds i32, i32* %p, i32 4
13
14; CHECK-NEXT: ldm [[NEWBASE]],
15  %5 = load i32, i32* %1, align 4
16  %6 = load i32, i32* %2, align 4
17  %7 = load i32, i32* %3, align 4
18  %8 = load i32, i32* %4, align 4
19
20  %9 = add nsw i32 %5, %6
21  %10 = add nsw i32 %9, %7
22  %11 = add nsw i32 %10, %8
23  ret i32 %11
24}
25
26; CHECK-LABEL: test2
27define i32 @test2(i32* %p) {
28
29; Offsets >=8 require a mov and an add
30; CHECK-V4T:  movs [[NEWBASE:r[0-9]]], r0
31; CHECK-V6M:  mov [[NEWBASE:r[0-9]]], r0
32; CHECK-NEXT: adds [[NEWBASE]], #8
33  %1 = getelementptr inbounds i32, i32* %p, i32 2
34  %2 = getelementptr inbounds i32, i32* %p, i32 3
35  %3 = getelementptr inbounds i32, i32* %p, i32 4
36  %4 = getelementptr inbounds i32, i32* %p, i32 5
37
38; CHECK-NEXT: ldm [[NEWBASE]],
39  %5 = load i32, i32* %1, align 4
40  %6 = load i32, i32* %2, align 4
41  %7 = load i32, i32* %3, align 4
42  %8 = load i32, i32* %4, align 4
43
44  %9 = add nsw i32 %5, %6
45  %10 = add nsw i32 %9, %7
46  %11 = add nsw i32 %10, %8
47  ret i32 %11
48}
49