xref: /llvm-project/llvm/test/CodeGen/Thumb2/thumb2-ldm.ll (revision b5b663aac17415625340eb29c8010832bfc4c21c)
1; RUN: llc < %s -mtriple=thumbv7-apple-ios -mattr=+thumb2 | FileCheck %s -check-prefix=ALL -check-prefix=CHECK
2; RUN: llc < %s -mtriple=thumbv7-apple-ios -mattr=+thumb2 -arm-assume-misaligned-load-store | FileCheck %s -check-prefix=ALL -check-prefix=CONSERVATIVE
3
4@X = external global [0 x i32]          ; <ptr> [#uses=5]
5
6define i32 @t1() "frame-pointer"="all" {
7; ALL-LABEL: t1:
8; ALL: push {r7, lr}
9; CHECK: ldrd
10; CONSERVATIVE-NOT: ldrd
11; CONSERVATIVE-NOT: ldm
12; ALL: pop {r7, pc}
13        %tmp = load i32, ptr @X            ; <i32> [#uses=1]
14        %tmp3 = load i32, ptr getelementptr ([0 x i32], ptr @X, i32 0, i32 1)           ; <i32> [#uses=1]
15        %tmp4 = call i32 @f1( i32 %tmp, i32 %tmp3 )                ; <i32> [#uses=1]
16        ret i32 %tmp4
17}
18
19define i32 @t2() "frame-pointer"="all" {
20; ALL-LABEL: t2:
21; ALL: push {r7, lr}
22; CHECK: ldm
23; CONSERVATIVE-NOT: ldrd
24; CONSERVATIVE-NOT: ldm
25; ALL: pop {r7, pc}
26        %tmp = load i32, ptr getelementptr ([0 x i32], ptr @X, i32 0, i32 2)            ; <i32> [#uses=1]
27        %tmp3 = load i32, ptr getelementptr ([0 x i32], ptr @X, i32 0, i32 3)           ; <i32> [#uses=1]
28        %tmp5 = load i32, ptr getelementptr ([0 x i32], ptr @X, i32 0, i32 4)           ; <i32> [#uses=1]
29        %tmp6 = call i32 @f2( i32 %tmp, i32 %tmp3, i32 %tmp5 )             ; <i32> [#uses=1]
30        ret i32 %tmp6
31}
32
33define i32 @t3() "frame-pointer"="all" {
34; ALL-LABEL: t3:
35; ALL: push {r7, lr}
36; CHECK: ldm
37; CONSERVATIVE-NOT: ldrd
38; CONSERVATIVE-NOT: ldm
39; ALL: pop {r7, pc}
40        %tmp = load i32, ptr getelementptr ([0 x i32], ptr @X, i32 0, i32 1)            ; <i32> [#uses=1]
41        %tmp3 = load i32, ptr getelementptr ([0 x i32], ptr @X, i32 0, i32 2)           ; <i32> [#uses=1]
42        %tmp5 = load i32, ptr getelementptr ([0 x i32], ptr @X, i32 0, i32 3)           ; <i32> [#uses=1]
43        %tmp6 = call i32 @f2( i32 %tmp, i32 %tmp3, i32 %tmp5 )             ; <i32> [#uses=1]
44        ret i32 %tmp6
45}
46
47@g = common global ptr null
48
49define void @t4(i32 %a0, i32 %a1, i32 %a2) "frame-pointer"="all" {
50; ALL-LABEL: t4:
51; ALL: stm.w sp, {r0, r1, r2}
52; ALL: bl _ext
53; ALL: ldm.w sp, {r0, r1, r2}
54; ALL: bl _f2
55  %arr = alloca [4 x i32], align 4
56  %p1 = getelementptr inbounds [4 x i32], ptr %arr, i64 0, i64 1
57  %p2 = getelementptr inbounds [4 x i32], ptr %arr, i64 0, i64 2
58  store ptr %arr, ptr @g, align 8
59
60  store i32 %a0, ptr %arr, align 4
61  store i32 %a1, ptr %p1, align 4
62  store i32 %a2, ptr %p2, align 4
63  call void @ext()
64
65  %v0 = load i32, ptr %arr, align 4
66  %v1 = load i32, ptr %p1, align 4
67  %v2 = load i32, ptr %p2, align 4
68  call i32 @f2(i32 %v0, i32 %v1, i32 %v2)
69  ret void
70}
71
72declare i32 @f1(i32, i32)
73
74declare i32 @f2(i32, i32, i32)
75
76declare void @ext()
77