1 ; RUN: llc -fast-isel-sink-local-values < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-apple-ios | FileCheck %s --check-prefix=ARM
2 ; RUN: llc -fast-isel-sink-local-values < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-linux-gnueabi | FileCheck %s --check-prefix=ARM
3 ; RUN: llc -fast-isel-sink-local-values < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-ios | FileCheck %s --check-prefix=THUMB
4 ; RUN: llc -fast-isel-sink-local-values < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-apple-ios -mattr=+long-calls | FileCheck %s --check-prefix=ARM-LONG --check-prefix=ARM-LONG-MACHO
5 ; RUN: llc -fast-isel-sink-local-values < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-linux-gnueabi -mattr=+long-calls | FileCheck %s --check-prefix=ARM-LONG --check-prefix=ARM-LONG-ELF
6 ; RUN: llc -fast-isel-sink-local-values < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-ios -mattr=+long-calls | FileCheck %s --check-prefix=THUMB-LONG
7 ; RUN: llc -fast-isel-sink-local-values < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-apple-ios -mattr=-fpregs | FileCheck %s --check-prefix=ARM-NOVFP
8 ; RUN: llc -fast-isel-sink-local-values < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-linux-gnueabi -mattr=-fpregs | FileCheck %s --check-prefix=ARM-NOVFP
9 ; RUN: llc -fast-isel-sink-local-values < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-ios -mattr=-fpregs | FileCheck %s --check-prefix=THUMB-NOVFP
11 ; Note that some of these tests assume that relocations are either
12 ; movw/movt or constant pool loads. Different platforms will select
13 ; different approaches.
15 define i32 @t0(i1 zeroext %a) nounwind {
16 %1 = zext i1 %a to i32
20 define i32 @t1(i8 signext %a) nounwind {
21 %1 = sext i8 %a to i32
25 define i32 @t2(i8 zeroext %a) nounwind {
26 %1 = zext i8 %a to i32
30 define i32 @t3(i16 signext %a) nounwind {
31 %1 = sext i16 %a to i32
35 define i32 @t4(i16 zeroext %a) nounwind {
36 %1 = zext i16 %a to i32
40 define void @foo(i8 %a, i16 %b) nounwind {
47 ; THUMB: and r2, r2, #1
48 %1 = call i32 @t0(i1 zeroext 1)
53 %2 = call i32 @t1(i8 signext %a)
54 ; ARM: and r2, r1, #255
56 ; THUMB: and r2, r1, #255
58 %3 = call i32 @t2(i8 zeroext %a)
63 %4 = call i32 @t3(i16 signext %b)
68 %5 = call i32 @t4(i16 zeroext %b)
70 ;; A few test to check materialization
71 ;; Note: i1 1 was materialized with t1 call
73 %6 = call i32 @t2(i8 zeroext 255)
74 ; ARM: movw r1, #65535
75 ; THUMB: movw r1, #65535
76 %7 = call i32 @t4(i16 zeroext 65535)
80 define void @foo2() nounwind {
81 %1 = call signext i16 @t5()
82 %2 = call zeroext i16 @t6()
83 %3 = call signext i8 @t7()
84 %4 = call zeroext i8 @t8()
85 %5 = call zeroext i1 @t9()
89 declare signext i16 @t5();
90 declare zeroext i16 @t6();
91 declare signext i8 @t7();
92 declare zeroext i8 @t8();
93 declare zeroext i1 @t9();
98 ; ARM-DAG: movw [[R0:l?r[0-9]*]], #0
99 ; ARM-DAG: movw [[R1:l?r[0-9]*]], #248
100 ; ARM-DAG: movw [[R2:l?r[0-9]*]], #187
101 ; ARM-DAG: movw [[R3:l?r[0-9]*]], #28
102 ; ARM-DAG: movw [[R4:l?r[0-9]*]], #40
103 ; ARM-DAG: movw [[R5:l?r[0-9]*]], #186
104 ; ARM-DAG: and [[R0]], [[R0]], #255
105 ; ARM-DAG: and [[R1]], [[R1]], #255
106 ; ARM-DAG: and [[R2]], [[R2]], #255
107 ; ARM-DAG: and [[R3]], [[R3]], #255
108 ; ARM-DAG: and [[R4]], [[R4]], #255
109 ; ARM-DAG: str [[R4]], [sp]
110 ; ARM-DAG: and [[R4]], [[R5]], #255
111 ; ARM-DAG: str [[R4]], [sp, #4]
113 ; ARM-LONG-LABEL: @t10
115 ; ARM-LONG-MACHO: {{(movw)|(ldr)}} [[R:l?r[0-9]*]], {{(:lower16:L_bar\$non_lazy_ptr)|(.LCPI)}}
116 ; ARM-LONG-MACHO: {{(movt [[R]], :upper16:L_bar\$non_lazy_ptr)?}}
117 ; ARM-LONG-MACHO: str [[R]], [r7, [[SLOT:#[-0-9]+]]] @ 4-byte Spill
118 ; ARM-LONG-MACHO: ldr [[R:l?r[0-9]*]], [r7, [[SLOT]]] @ 4-byte Reload
120 ; ARM-LONG-ELF: movw [[R:l?r[0-9]*]], :lower16:bar
121 ; ARM-LONG-ELF: {{(movt [[R]], :upper16:L_bar\$non_lazy_ptr)?}}
123 ; ARM-LONG: blx [[R]]
125 ; THUMB-DAG: movs [[R0:l?r[0-9]*]], #0
126 ; THUMB-DAG: movs [[R1:l?r[0-9]*]], #248
127 ; THUMB-DAG: movs [[R2:l?r[0-9]*]], #187
128 ; THUMB-DAG: movs [[R3:l?r[0-9]*]], #28
129 ; THUMB-DAG: movw [[R4:l?r[0-9]*]], #40
130 ; THUMB-DAG: movw [[R5:l?r[0-9]*]], #186
131 ; THUMB-DAG: and [[R0]], [[R0]], #255
132 ; THUMB-DAG: and [[R1]], [[R1]], #255
133 ; THUMB-DAG: and [[R2]], [[R2]], #255
134 ; THUMB-DAG: and [[R3]], [[R3]], #255
135 ; THUMB-DAG: and [[R4]], [[R4]], #255
136 ; THUMB-DAG: str.w [[R4]], [sp]
137 ; THUMB-DAG: and [[R4]], [[R5]], #255
138 ; THUMB-DAG: str.w [[R4]], [sp, #4]
139 ; THUMB: bl {{_?}}bar
140 ; THUMB-LONG-LABEL: @t10
141 ; THUMB-LONG: {{(movw)|(ldr.n)}} [[R:l?r[0-9]*]], {{(:lower16:L_bar\$non_lazy_ptr)|(.LCPI)}}
142 ; THUMB-LONG: {{(movt [[R]], :upper16:L_bar\$non_lazy_ptr)?}}
143 ; THUMB-LONG: ldr{{(.w)?}} [[R]], {{\[}}[[R]]{{\]}}
144 ; THUMB-LONG: str [[R]], [sp, [[SLOT:#[-0-9]+]]] @ 4-byte Spill
145 ; THUMB-LONG: ldr.w [[R:l?r[0-9]*]], [sp, [[SLOT]]] @ 4-byte Reload
146 ; THUMB-LONG: blx [[R]]
147 %call = call i32 @bar(i8 zeroext 0, i8 zeroext -8, i8 zeroext -69, i8 zeroext 28, i8 zeroext 40, i8 zeroext -70)
151 declare i32 @bar(i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext)
153 define i32 @bar0(i32 %i) nounwind {
157 define void @foo3() uwtable {
159 ; ARM: {{(movw r[0-9]+, :lower16:_?bar0)|(ldr r[0-9]+, .LCPI)}}
160 ; ARM: {{(movt r[0-9]+, :upper16:_?bar0)|(ldr r[0-9]+, \[r[0-9]+\])}}
161 ; ARM: movw {{r[0-9]+}}, #0
162 ; ARM: blx {{r[0-9]+}}
163 ; THUMB: {{(movw r[0-9]+, :lower16:_?bar0)|(ldr.n r[0-9]+, .LCPI)}}
164 ; THUMB: {{(movt r[0-9]+, :upper16:_?bar0)|(ldr r[0-9]+, \[r[0-9]+\])}}
165 ; THUMB: movs {{r[0-9]+}}, #0
166 ; THUMB: blx {{r[0-9]+}}
167 %fptr = alloca i32 (i32)*, align 8
168 store i32 (i32)* @bar0, i32 (i32)** %fptr, align 8
169 %1 = load i32 (i32)*, i32 (i32)** %fptr, align 8
170 %call = call i32 %1(i32 0)
174 define i32 @LibCall(i32 %a, i32 %b) {
177 ; ARM: bl {{___udivsi3|__aeabi_uidiv}}
178 ; ARM-LONG-LABEL: LibCall
180 ; ARM-LONG-MACHO: {{(movw r2, :lower16:L___udivsi3\$non_lazy_ptr)|(ldr r2, .LCPI)}}
181 ; ARM-LONG-MACHO: {{(movt r2, :upper16:L___udivsi3\$non_lazy_ptr)?}}
182 ; ARM-LONG-MACHO: ldr r2, [r2]
184 ; ARM-LONG-ELF: movw r2, :lower16:__aeabi_uidiv
185 ; ARM-LONG-ELF: movt r2, :upper16:__aeabi_uidiv
189 ; THUMB: bl {{___udivsi3|__aeabi_uidiv}}
190 ; THUMB-LONG-LABEL: LibCall
191 ; THUMB-LONG: {{(movw r2, :lower16:L___udivsi3\$non_lazy_ptr)|(ldr.n r2, .LCPI)}}
192 ; THUMB-LONG: {{(movt r2, :upper16:L___udivsi3\$non_lazy_ptr)?}}
193 ; THUMB-LONG: ldr r2, [r2]
195 %tmp1 = udiv i32 %a, %b ; <i32> [#uses=1]
201 define fastcc void @fast_callee(float %i) ssp {
207 ; ARM-NOVFP: fast_callee
209 ; THUMB-NOVFP: fast_callee
210 ; THUMB-NOVFP-NOT: s0
211 call void @print(float %i)
215 define void @fast_caller() ssp {
221 ; ARM-NOVFP: fast_caller
222 ; ARM-NOVFP: movw r0, #13107
223 ; ARM-NOVFP: movt r0, #16611
224 ; THUMB-NOVFP: fast_caller
225 ; THUMB-NOVFP: movw r0, #13107
226 ; THUMB-NOVFP: movt r0, #16611
227 call fastcc void @fast_callee(float 0x401C666660000000)
231 define void @no_fast_callee(float %i) ssp {
233 ; ARM: no_fast_callee
235 ; THUMB: no_fast_callee
237 ; ARM-NOVFP: no_fast_callee
239 ; THUMB-NOVFP: no_fast_callee
240 ; THUMB-NOVFP-NOT: s0
241 call void @print(float %i)
245 define void @no_fast_caller() ssp {
247 ; ARM: no_fast_caller
249 ; THUMB: no_fast_caller
251 ; ARM-NOVFP: no_fast_caller
252 ; ARM-NOVFP: movw r0, #13107
253 ; ARM-NOVFP: movt r0, #16611
254 ; THUMB-NOVFP: no_fast_caller
255 ; THUMB-NOVFP: movw r0, #13107
256 ; THUMB-NOVFP: movt r0, #16611
257 call void @no_fast_callee(float 0x401C666660000000)
261 declare void @bar2(i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5, i32 %a6)
263 define void @call_undef_args() {
264 ; ARM-LABEL: call_undef_args
266 ; ARM-NEXT: movw r1, #2
267 ; ARM-NEXT: movw r2, #3
268 ; ARM-NEXT: movw r3, #4
269 ; ARM-NOT: str {{r[0-9]+}}, [sp]
270 ; ARM: movw [[REG:l?r[0-9]*]], #6
271 ; ARM-NEXT: str [[REG]], [sp, #4]
272 call void @bar2(i32 1, i32 2, i32 3, i32 4, i32 undef, i32 6)
276 declare void @print(float)