1 ; RUN: llc -mtriple armv7a--none-eabi < %s | FileCheck %s --check-prefix=CHECK --check-prefix=DISABLED
2 ; RUN: llc -mtriple armv7a--none-eabi < %s -enable-ipra | FileCheck %s --check-prefix=CHECK --check-prefix=ENABLED
6 tail call void asm sideeffect "", ""()
10 define void @leaf_r3() {
12 tail call void asm sideeffect "", "~{r3}"()
16 define void @leaf_r4() {
18 tail call void asm sideeffect "", "~{r4}"()
22 define void @leaf_s0() {
24 tail call void asm sideeffect "", "~{s0}"()
28 define void @leaf_d0() {
30 tail call void asm sideeffect "", "~{d0}"()
34 ; r3 is normally caller-saved, but with IPRA we can see that it isn't used in
35 ; the callee, so can leave a live value in it.
36 define void @test_r3_presrved() {
37 ; CHECK-LABEL: test_r3_presrved:
40 ; DISABLED: mov [[TEMP:r[0-9]+]], r3
43 ; DISABLED: mov r3, [[TEMP]]
46 %a = tail call i32 asm sideeffect "// ASM1: $0", "={r3},0"(i32 undef)
47 tail call void @leaf()
48 %b = tail call i32 asm sideeffect "// ASM2: $0", "={r3},0"(i32 %a)
52 ; Same as above, but r3 is clobbered in the callee, so it is clobbered by the
54 define void @test_r3_clobbered() {
55 ; CHECK-LABEL: test_r3_clobbered:
58 ; CHECK: mov [[TEMP:r[0-9]+]], r3
60 ; CHECK: mov r3, [[TEMP]]
62 %a = tail call i32 asm sideeffect "// ASM1: $0", "={r3},0"(i32 undef)
63 tail call void @leaf_r3()
64 %b = tail call i32 asm sideeffect "// ASM2: $0", "={r3},0"(i32 %a)
68 ; r4 is a callee-saved register, so IPRA has no effect.
69 define void @test_r4_preserved() {
70 ; CHECK-LABEL: test_r4_preserved:
77 %a = tail call i32 asm sideeffect "// ASM1: $0", "={r4},0"(i32 undef)
78 tail call void @leaf()
79 %b = tail call i32 asm sideeffect "// ASM2: $0", "={r4},0"(i32 %a)
82 define void @test_r4_clobbered() {
83 ; CHECK-LABEL: test_r4_clobbered:
90 %a = tail call i32 asm sideeffect "// ASM1: $0", "={r4},0"(i32 undef)
91 tail call void @leaf_r4()
92 %b = tail call i32 asm sideeffect "// ASM2: $0", "={r4},0"(i32 %a)
96 ; r12 is the intra-call scratch register, so we have to assume it is clobbered
97 ; even if we can see that the callee does not touch it.
98 define void @test_r12() {
99 ; CHECK-LABEL: test_r12:
102 ; CHECK: mov [[TEMP:r[0-9]+]], r12
104 ; CHECK: mov r12, [[TEMP]]
106 %a = tail call i32 asm sideeffect "// ASM1: $0", "={r12},0"(i32 undef)
107 tail call void @leaf()
108 %b = tail call i32 asm sideeffect "// ASM2: $0", "={r12},0"(i32 %a)
112 ; s0 and d0 are caller-saved, IPRA allows us to keep them live in the caller if
113 ; the callee doesn't modify them.
114 define void @test_s0_preserved() {
115 ; CHECK-LABEL: test_s0_preserved:
118 ; DISABLED: vmov.f32 [[TEMP:s[0-9]+]], s0
121 ; DISABLED: vmov.f32 s0, [[TEMP]]
124 %a = tail call float asm sideeffect "// ASM1: $0", "={s0},0"(float undef)
125 tail call void @leaf()
126 %b = tail call float asm sideeffect "// ASM2: $0", "={s0},0"(float %a)
130 define void @test_s0_clobbered() {
131 ; CHECK-LABEL: test_s0_clobbered:
134 ; CHECK: vmov.f32 [[TEMP:s[0-9]+]], s0
136 ; CHECK: vmov.f32 s0, [[TEMP]]
138 %a = tail call float asm sideeffect "// ASM1: $0", "={s0},0"(float undef)
139 tail call void @leaf_s0()
140 %b = tail call float asm sideeffect "// ASM2: $0", "={s0},0"(float %a)
144 define void @test_d0_preserved() {
145 ; CHECK-LABEL: test_d0_preserved:
148 ; DISABLED: vmov.f64 [[TEMP:d[0-9]+]], d0
151 ; DISABLED: vmov.f64 d0, [[TEMP]]
154 %a = tail call double asm sideeffect "// ASM1: $0", "={d0},0"(double undef)
155 tail call void @leaf()
156 %b = tail call double asm sideeffect "// ASM2: $0", "={d0},0"(double %a)
160 define void @test_d0_clobbered() {
161 ; CHECK-LABEL: test_d0_clobbered:
164 ; CHECK: vmov.f64 [[TEMP:d[0-9]+]], d0
166 ; CHECK: vmov.f64 d0, [[TEMP]]
168 %a = tail call double asm sideeffect "// ASM1: $0", "={d0},0"(double undef)
169 tail call void @leaf_d0()
170 %b = tail call double asm sideeffect "// ASM2: $0", "={d0},0"(double %a)
174 ; s0 and d0 overlap, so clobbering one in the callee prevents the other from
175 ; being kept live across the call.
176 define void @test_s0_clobber_d0() {
177 ; CHECK-LABEL: test_s0_clobber_d0:
180 ; CHECK: vmov.f32 [[TEMP:s[0-9]+]], s0
182 ; CHECK: vmov.f32 s0, [[TEMP]]
184 %a = tail call float asm sideeffect "// ASM1: $0", "={s0},0"(float undef)
185 tail call void @leaf_d0()
186 %b = tail call float asm sideeffect "// ASM2: $0", "={s0},0"(float %a)
190 define void @test_d0_clobber_s0() {
191 ; CHECK-LABEL: test_d0_clobber_s0:
194 ; CHECK: vmov.f64 [[TEMP:d[0-9]+]], d0
196 ; CHECK: vmov.f64 d0, [[TEMP]]
198 %a = tail call double asm sideeffect "// ASM1: $0", "={d0},0"(double undef)
199 tail call void @leaf_s0()
200 %b = tail call double asm sideeffect "// ASM2: $0", "={d0},0"(double %a)