1 ; RUN: llc -mtriple=thumbv6m-eabi -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-T1
2 ; RUN: llc -mtriple=thumbv5e-linux-gnueabi -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-T1
3 ; RUN: llc -mtriple=thumbv7m -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-T2
4 ; RUN: llc -mtriple=thumbv7a -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-T2
6 %struct1 = type { ptr, ptr, i32 }
7 %struct2 = type { i32, i32, ptr }
9 @x1 = external global %struct1, align 4
10 @x2 = external global %struct1, align 4
12 declare void @fn1(i32, i32)
13 declare void @fn2(ptr)
16 ; CHECK-T1: str r0, [r1]
17 ; CHECK-T1-NEXT: str r1, [r1, #4]
18 ; CHECK-T2: strd r0, r1, [r1]
20 define void @test1(i32 %unused, ptr %x) {
21 %second = getelementptr inbounds %struct1, ptr %x, i32 0, i32 1
23 store ptr %x, ptr %second
28 ; CHECK-T1: str r0, [r2]
29 ; CHECK-T1-NEXT: str r1, [r2, #4]
30 ; CHECK-T1-NEXT: str r2, [r2, #8]
31 ; CHECK-T2: stm.w r2, {r0, r1, r2}
32 ; CHECK-NOT: stm r2!, {r0, r1, r2}
33 define i32 @test2(i32 %a, i32 %b, ptr %p) {
35 %p2 = getelementptr inbounds %struct2, ptr %p, i32 0, i32 1
36 %p3 = getelementptr inbounds %struct2, ptr %p, i32 0, i32 2
37 store i32 %a, ptr %p, align 4
38 store i32 %b, ptr %p2, align 4
39 store ptr %p, ptr %p3, align 4
40 call void @fn1(i32 %a, i32 %b)
45 ; CHECK-T1: str r0, [r2]
46 ; CHECK-T1-NEXT: str r1, [r2, #4]
47 ; CHECK-T1-NEXT: str r2, [r2, #8]
48 ; CHECK-T2: stm.w r2, {r0, r1, r2}
49 ; CHECK-NOT: stm r2!, {r0, r1, r2}
50 define i32 @test3(i32 %a, i32 %b, ptr %p) {
52 %p2 = getelementptr inbounds %struct2, ptr %p, i32 0, i32 1
53 %p3 = getelementptr inbounds %struct2, ptr %p, i32 0, i32 2
54 store i32 %a, ptr %p, align 4
55 store i32 %b, ptr %p2, align 4
56 store ptr %p, ptr %p3, align 4
57 %p4 = getelementptr inbounds %struct2, ptr %p, i32 1
58 call void @fn2(ptr %p4)
62 ; FIXME: We should be using stm in both thumb1 and thumb2
64 ; CHECK-T1: str r0, [r0]
65 ; CHECK-T1-NEXT: str r1, [r0, #4]
66 ; CHECK-T1-NEXT: str r2, [r0, #8]
67 ; CHECK-T2: stm r0!, {r0, r1, r2}
68 define i32 @test4(ptr %p, ptr %q, i32 %a) {
70 %p2 = getelementptr inbounds %struct1, ptr %p, i32 0, i32 1
71 %p3 = getelementptr inbounds %struct1, ptr %p, i32 0, i32 2
72 store ptr %p, ptr %p, align 4
73 store ptr %q, ptr %p2, align 4
74 store i32 %a, ptr %p3, align 4
75 call void @fn1(i32 %a, i32 %a)