• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=armv7-unknown-linux < %s -verify-machineinstrs | FileCheck --check-prefix=CHECK-ARM %s
3; RUN: llc -mtriple=thumb-eabi < %s  -verify-machineinstrs | FileCheck --check-prefix=CHECK-THUMB1-NOMOV %s
4; RUN: llc -mtriple=thumbv6-unknown-linux < %s -verify-machineinstrs | FileCheck --check-prefix=CHECK-THUMB1 %s
5; RUN: llc -mtriple=thumbv7-unknown-linux < %s -verify-machineinstrs | FileCheck --check-prefix=CHECK-THUMB2 %s
6
7define i32 @test_slt1(i64 %a, i64 %b) {
8; CHECK-ARM-LABEL: test_slt1:
9; CHECK-ARM:       @ %bb.0: @ %entry
10; CHECK-ARM-NEXT:    subs r0, r0, r2
11; CHECK-ARM-NEXT:    mov r12, #2
12; CHECK-ARM-NEXT:    sbcs r0, r1, r3
13; CHECK-ARM-NEXT:    movwlt r12, #1
14; CHECK-ARM-NEXT:    mov r0, r12
15; CHECK-ARM-NEXT:    bx lr
16;
17; CHECK-THUMB1-NOMOV-LABEL: test_slt1:
18; CHECK-THUMB1-NOMOV:       @ %bb.0: @ %entry
19; CHECK-THUMB1-NOMOV-NEXT:    subs r0, r0, r2
20; CHECK-THUMB1-NOMOV-NEXT:    sbcs r1, r3
21; CHECK-THUMB1-NOMOV-NEXT:    bge .LBB0_2
22; CHECK-THUMB1-NOMOV-NEXT:  @ %bb.1: @ %bb1
23; CHECK-THUMB1-NOMOV-NEXT:    movs r0, #1
24; CHECK-THUMB1-NOMOV-NEXT:    bx lr
25; CHECK-THUMB1-NOMOV-NEXT:  .LBB0_2: @ %bb2
26; CHECK-THUMB1-NOMOV-NEXT:    movs r0, #2
27; CHECK-THUMB1-NOMOV-NEXT:    bx lr
28;
29; CHECK-THUMB1-LABEL: test_slt1:
30; CHECK-THUMB1:       @ %bb.0: @ %entry
31; CHECK-THUMB1-NEXT:    subs r0, r0, r2
32; CHECK-THUMB1-NEXT:    sbcs r1, r3
33; CHECK-THUMB1-NEXT:    bge .LBB0_2
34; CHECK-THUMB1-NEXT:  @ %bb.1: @ %bb1
35; CHECK-THUMB1-NEXT:    movs r0, #1
36; CHECK-THUMB1-NEXT:    bx lr
37; CHECK-THUMB1-NEXT:  .LBB0_2: @ %bb2
38; CHECK-THUMB1-NEXT:    movs r0, #2
39; CHECK-THUMB1-NEXT:    bx lr
40;
41; CHECK-THUMB2-LABEL: test_slt1:
42; CHECK-THUMB2:       @ %bb.0: @ %entry
43; CHECK-THUMB2-NEXT:    subs r0, r0, r2
44; CHECK-THUMB2-NEXT:    mov.w r12, #2
45; CHECK-THUMB2-NEXT:    sbcs.w r0, r1, r3
46; CHECK-THUMB2-NEXT:    it lt
47; CHECK-THUMB2-NEXT:    movlt.w r12, #1
48; CHECK-THUMB2-NEXT:    mov r0, r12
49; CHECK-THUMB2-NEXT:    bx lr
50entry:
51  %cmp = icmp slt i64 %a, %b
52  br i1 %cmp, label %bb1, label %bb2
53bb1:
54  ret i32 1
55bb2:
56  ret i32 2
57}
58
59define void @test_slt2(i64 %a, i64 %b) {
60; CHECK-ARM-LABEL: test_slt2:
61; CHECK-ARM:       @ %bb.0: @ %entry
62; CHECK-ARM-NEXT:    push {r11, lr}
63; CHECK-ARM-NEXT:    subs r0, r0, r2
64; CHECK-ARM-NEXT:    sbcs r0, r1, r3
65; CHECK-ARM-NEXT:    bge .LBB1_2
66; CHECK-ARM-NEXT:  @ %bb.1: @ %bb1
67; CHECK-ARM-NEXT:    bl f
68; CHECK-ARM-NEXT:    pop {r11, pc}
69; CHECK-ARM-NEXT:  .LBB1_2: @ %bb2
70; CHECK-ARM-NEXT:    bl g
71; CHECK-ARM-NEXT:    pop {r11, pc}
72;
73; CHECK-THUMB1-NOMOV-LABEL: test_slt2:
74; CHECK-THUMB1-NOMOV:       @ %bb.0: @ %entry
75; CHECK-THUMB1-NOMOV-NEXT:    .save {r7, lr}
76; CHECK-THUMB1-NOMOV-NEXT:    push {r7, lr}
77; CHECK-THUMB1-NOMOV-NEXT:    subs r0, r0, r2
78; CHECK-THUMB1-NOMOV-NEXT:    sbcs r1, r3
79; CHECK-THUMB1-NOMOV-NEXT:    bge .LBB1_2
80; CHECK-THUMB1-NOMOV-NEXT:  @ %bb.1: @ %bb1
81; CHECK-THUMB1-NOMOV-NEXT:    bl f
82; CHECK-THUMB1-NOMOV-NEXT:    b .LBB1_3
83; CHECK-THUMB1-NOMOV-NEXT:  .LBB1_2: @ %bb2
84; CHECK-THUMB1-NOMOV-NEXT:    bl g
85; CHECK-THUMB1-NOMOV-NEXT:  .LBB1_3: @ %bb1
86; CHECK-THUMB1-NOMOV-NEXT:    pop {r7}
87; CHECK-THUMB1-NOMOV-NEXT:    pop {r0}
88; CHECK-THUMB1-NOMOV-NEXT:    bx r0
89;
90; CHECK-THUMB1-LABEL: test_slt2:
91; CHECK-THUMB1:       @ %bb.0: @ %entry
92; CHECK-THUMB1-NEXT:    push {r7, lr}
93; CHECK-THUMB1-NEXT:    subs r0, r0, r2
94; CHECK-THUMB1-NEXT:    sbcs r1, r3
95; CHECK-THUMB1-NEXT:    bge .LBB1_2
96; CHECK-THUMB1-NEXT:  @ %bb.1: @ %bb1
97; CHECK-THUMB1-NEXT:    bl f
98; CHECK-THUMB1-NEXT:    pop {r7, pc}
99; CHECK-THUMB1-NEXT:  .LBB1_2: @ %bb2
100; CHECK-THUMB1-NEXT:    bl g
101; CHECK-THUMB1-NEXT:    pop {r7, pc}
102;
103; CHECK-THUMB2-LABEL: test_slt2:
104; CHECK-THUMB2:       @ %bb.0: @ %entry
105; CHECK-THUMB2-NEXT:    push {r7, lr}
106; CHECK-THUMB2-NEXT:    subs r0, r0, r2
107; CHECK-THUMB2-NEXT:    sbcs.w r0, r1, r3
108; CHECK-THUMB2-NEXT:    bge .LBB1_2
109; CHECK-THUMB2-NEXT:  @ %bb.1: @ %bb1
110; CHECK-THUMB2-NEXT:    bl f
111; CHECK-THUMB2-NEXT:    pop {r7, pc}
112; CHECK-THUMB2-NEXT:  .LBB1_2: @ %bb2
113; CHECK-THUMB2-NEXT:    bl g
114; CHECK-THUMB2-NEXT:    pop {r7, pc}
115entry:
116  %cmp = icmp slt i64 %a, %b
117  br i1 %cmp, label %bb1, label %bb2
118bb1:
119  call void @f()
120  ret void
121bb2:
122  call void @g()
123  ret void
124}
125
126declare void @f()
127declare void @g()
128
129define i64 @test_slt_select(i64 %c, i64 %d, i64 %a, i64 %b) {
130; CHECK-ARM-LABEL: test_slt_select:
131; CHECK-ARM:       @ %bb.0: @ %entry
132; CHECK-ARM-NEXT:    push {r4, r5, r6, r7, r11, lr}
133; CHECK-ARM-NEXT:    ldr r12, [sp, #32]
134; CHECK-ARM-NEXT:    mov r6, #0
135; CHECK-ARM-NEXT:    ldr lr, [sp, #24]
136; CHECK-ARM-NEXT:    ldr r7, [sp, #36]
137; CHECK-ARM-NEXT:    ldr r5, [sp, #28]
138; CHECK-ARM-NEXT:    subs r4, lr, r12
139; CHECK-ARM-NEXT:    sbcs r7, r5, r7
140; CHECK-ARM-NEXT:    movwlo r6, #1
141; CHECK-ARM-NEXT:    cmp r6, #0
142; CHECK-ARM-NEXT:    moveq r0, r2
143; CHECK-ARM-NEXT:    moveq r1, r3
144; CHECK-ARM-NEXT:    pop {r4, r5, r6, r7, r11, pc}
145;
146; CHECK-THUMB1-NOMOV-LABEL: test_slt_select:
147; CHECK-THUMB1-NOMOV:       @ %bb.0: @ %entry
148; CHECK-THUMB1-NOMOV-NEXT:    .save {r4, r5, r6, r7, lr}
149; CHECK-THUMB1-NOMOV-NEXT:    push {r4, r5, r6, r7, lr}
150; CHECK-THUMB1-NOMOV-NEXT:    .pad #4
151; CHECK-THUMB1-NOMOV-NEXT:    sub sp, #4
152; CHECK-THUMB1-NOMOV-NEXT:    ldr r4, [sp, #36]
153; CHECK-THUMB1-NOMOV-NEXT:    ldr r5, [sp, #28]
154; CHECK-THUMB1-NOMOV-NEXT:    ldr r6, [sp, #32]
155; CHECK-THUMB1-NOMOV-NEXT:    ldr r7, [sp, #24]
156; CHECK-THUMB1-NOMOV-NEXT:    subs r6, r7, r6
157; CHECK-THUMB1-NOMOV-NEXT:    sbcs r5, r4
158; CHECK-THUMB1-NOMOV-NEXT:    blo .LBB2_2
159; CHECK-THUMB1-NOMOV-NEXT:  @ %bb.1: @ %entry
160; CHECK-THUMB1-NOMOV-NEXT:    movs r4, #0
161; CHECK-THUMB1-NOMOV-NEXT:    cmp r4, #0
162; CHECK-THUMB1-NOMOV-NEXT:    beq .LBB2_3
163; CHECK-THUMB1-NOMOV-NEXT:    b .LBB2_4
164; CHECK-THUMB1-NOMOV-NEXT:  .LBB2_2:
165; CHECK-THUMB1-NOMOV-NEXT:    movs r4, #1
166; CHECK-THUMB1-NOMOV-NEXT:    cmp r4, #0
167; CHECK-THUMB1-NOMOV-NEXT:    bne .LBB2_4
168; CHECK-THUMB1-NOMOV-NEXT:  .LBB2_3: @ %entry
169; CHECK-THUMB1-NOMOV-NEXT:    movs r0, r2
170; CHECK-THUMB1-NOMOV-NEXT:  .LBB2_4: @ %entry
171; CHECK-THUMB1-NOMOV-NEXT:    cmp r4, #0
172; CHECK-THUMB1-NOMOV-NEXT:    bne .LBB2_6
173; CHECK-THUMB1-NOMOV-NEXT:  @ %bb.5: @ %entry
174; CHECK-THUMB1-NOMOV-NEXT:    movs r1, r3
175; CHECK-THUMB1-NOMOV-NEXT:  .LBB2_6: @ %entry
176; CHECK-THUMB1-NOMOV-NEXT:    add sp, #4
177; CHECK-THUMB1-NOMOV-NEXT:    pop {r4, r5, r6, r7}
178; CHECK-THUMB1-NOMOV-NEXT:    pop {r2}
179; CHECK-THUMB1-NOMOV-NEXT:    bx r2
180;
181; CHECK-THUMB1-LABEL: test_slt_select:
182; CHECK-THUMB1:       @ %bb.0: @ %entry
183; CHECK-THUMB1-NEXT:    push {r4, r5, r6, r7, lr}
184; CHECK-THUMB1-NEXT:    sub sp, #4
185; CHECK-THUMB1-NEXT:    ldr r4, [sp, #36]
186; CHECK-THUMB1-NEXT:    ldr r5, [sp, #28]
187; CHECK-THUMB1-NEXT:    ldr r6, [sp, #32]
188; CHECK-THUMB1-NEXT:    ldr r7, [sp, #24]
189; CHECK-THUMB1-NEXT:    subs r6, r7, r6
190; CHECK-THUMB1-NEXT:    sbcs r5, r4
191; CHECK-THUMB1-NEXT:    blo .LBB2_2
192; CHECK-THUMB1-NEXT:  @ %bb.1: @ %entry
193; CHECK-THUMB1-NEXT:    movs r4, #0
194; CHECK-THUMB1-NEXT:    cmp r4, #0
195; CHECK-THUMB1-NEXT:    beq .LBB2_3
196; CHECK-THUMB1-NEXT:    b .LBB2_4
197; CHECK-THUMB1-NEXT:  .LBB2_2:
198; CHECK-THUMB1-NEXT:    movs r4, #1
199; CHECK-THUMB1-NEXT:    cmp r4, #0
200; CHECK-THUMB1-NEXT:    bne .LBB2_4
201; CHECK-THUMB1-NEXT:  .LBB2_3: @ %entry
202; CHECK-THUMB1-NEXT:    mov r0, r2
203; CHECK-THUMB1-NEXT:  .LBB2_4: @ %entry
204; CHECK-THUMB1-NEXT:    cmp r4, #0
205; CHECK-THUMB1-NEXT:    beq .LBB2_6
206; CHECK-THUMB1-NEXT:  @ %bb.5: @ %entry
207; CHECK-THUMB1-NEXT:    add sp, #4
208; CHECK-THUMB1-NEXT:    pop {r4, r5, r6, r7, pc}
209; CHECK-THUMB1-NEXT:  .LBB2_6: @ %entry
210; CHECK-THUMB1-NEXT:    mov r1, r3
211; CHECK-THUMB1-NEXT:    add sp, #4
212; CHECK-THUMB1-NEXT:    pop {r4, r5, r6, r7, pc}
213;
214; CHECK-THUMB2-LABEL: test_slt_select:
215; CHECK-THUMB2:       @ %bb.0: @ %entry
216; CHECK-THUMB2-NEXT:    push {r4, r5, r6, r7, lr}
217; CHECK-THUMB2-NEXT:    sub sp, #4
218; CHECK-THUMB2-NEXT:    ldrd r12, r7, [sp, #32]
219; CHECK-THUMB2-NEXT:    movs r6, #0
220; CHECK-THUMB2-NEXT:    ldrd lr, r5, [sp, #24]
221; CHECK-THUMB2-NEXT:    subs.w r4, lr, r12
222; CHECK-THUMB2-NEXT:    sbcs.w r7, r5, r7
223; CHECK-THUMB2-NEXT:    it lo
224; CHECK-THUMB2-NEXT:    movlo r6, #1
225; CHECK-THUMB2-NEXT:    cmp r6, #0
226; CHECK-THUMB2-NEXT:    itt eq
227; CHECK-THUMB2-NEXT:    moveq r0, r2
228; CHECK-THUMB2-NEXT:    moveq r1, r3
229; CHECK-THUMB2-NEXT:    add sp, #4
230; CHECK-THUMB2-NEXT:    pop {r4, r5, r6, r7, pc}
231entry:
232    %cmp = icmp ult i64 %a, %b
233    %r1 = select i1 %cmp, i64 %c, i64 %d
234    ret i64 %r1
235}
236
237define {i32, i32} @test_slt_not(i32 %c, i32 %d, i64 %a, i64 %b) {
238; CHECK-ARM-LABEL: test_slt_not:
239; CHECK-ARM:       @ %bb.0: @ %entry
240; CHECK-ARM-NEXT:    ldr r12, [sp]
241; CHECK-ARM-NEXT:    mov r1, #0
242; CHECK-ARM-NEXT:    ldr r0, [sp, #4]
243; CHECK-ARM-NEXT:    subs r2, r2, r12
244; CHECK-ARM-NEXT:    sbcs r0, r3, r0
245; CHECK-ARM-NEXT:    mov r0, #0
246; CHECK-ARM-NEXT:    movwge r1, #1
247; CHECK-ARM-NEXT:    movwlt r0, #1
248; CHECK-ARM-NEXT:    bx lr
249;
250; CHECK-THUMB1-NOMOV-LABEL: test_slt_not:
251; CHECK-THUMB1-NOMOV:       @ %bb.0: @ %entry
252; CHECK-THUMB1-NOMOV-NEXT:    .save {r4, r5, r7, lr}
253; CHECK-THUMB1-NOMOV-NEXT:    push {r4, r5, r7, lr}
254; CHECK-THUMB1-NOMOV-NEXT:    movs r1, #1
255; CHECK-THUMB1-NOMOV-NEXT:    movs r4, #0
256; CHECK-THUMB1-NOMOV-NEXT:    ldr r0, [sp, #20]
257; CHECK-THUMB1-NOMOV-NEXT:    ldr r5, [sp, #16]
258; CHECK-THUMB1-NOMOV-NEXT:    subs r2, r2, r5
259; CHECK-THUMB1-NOMOV-NEXT:    sbcs r3, r0
260; CHECK-THUMB1-NOMOV-NEXT:    push {r1}
261; CHECK-THUMB1-NOMOV-NEXT:    pop {r0}
262; CHECK-THUMB1-NOMOV-NEXT:    blt .LBB3_2
263; CHECK-THUMB1-NOMOV-NEXT:  @ %bb.1: @ %entry
264; CHECK-THUMB1-NOMOV-NEXT:    push {r4}
265; CHECK-THUMB1-NOMOV-NEXT:    pop {r0}
266; CHECK-THUMB1-NOMOV-NEXT:  .LBB3_2: @ %entry
267; CHECK-THUMB1-NOMOV-NEXT:    bge .LBB3_4
268; CHECK-THUMB1-NOMOV-NEXT:  @ %bb.3: @ %entry
269; CHECK-THUMB1-NOMOV-NEXT:    movs r1, r4
270; CHECK-THUMB1-NOMOV-NEXT:  .LBB3_4: @ %entry
271; CHECK-THUMB1-NOMOV-NEXT:    pop {r4, r5, r7}
272; CHECK-THUMB1-NOMOV-NEXT:    pop {r2}
273; CHECK-THUMB1-NOMOV-NEXT:    bx r2
274;
275; CHECK-THUMB1-LABEL: test_slt_not:
276; CHECK-THUMB1:       @ %bb.0: @ %entry
277; CHECK-THUMB1-NEXT:    push {r4, r5, r7, lr}
278; CHECK-THUMB1-NEXT:    movs r1, #1
279; CHECK-THUMB1-NEXT:    movs r4, #0
280; CHECK-THUMB1-NEXT:    ldr r0, [sp, #20]
281; CHECK-THUMB1-NEXT:    ldr r5, [sp, #16]
282; CHECK-THUMB1-NEXT:    subs r2, r2, r5
283; CHECK-THUMB1-NEXT:    sbcs r3, r0
284; CHECK-THUMB1-NEXT:    mov r0, r1
285; CHECK-THUMB1-NEXT:    bge .LBB3_3
286; CHECK-THUMB1-NEXT:  @ %bb.1: @ %entry
287; CHECK-THUMB1-NEXT:    blt .LBB3_4
288; CHECK-THUMB1-NEXT:  .LBB3_2: @ %entry
289; CHECK-THUMB1-NEXT:    pop {r4, r5, r7, pc}
290; CHECK-THUMB1-NEXT:  .LBB3_3: @ %entry
291; CHECK-THUMB1-NEXT:    mov r0, r4
292; CHECK-THUMB1-NEXT:    bge .LBB3_2
293; CHECK-THUMB1-NEXT:  .LBB3_4: @ %entry
294; CHECK-THUMB1-NEXT:    mov r1, r4
295; CHECK-THUMB1-NEXT:    pop {r4, r5, r7, pc}
296;
297; CHECK-THUMB2-LABEL: test_slt_not:
298; CHECK-THUMB2:       @ %bb.0: @ %entry
299; CHECK-THUMB2-NEXT:    ldr.w r12, [sp]
300; CHECK-THUMB2-NEXT:    movs r1, #0
301; CHECK-THUMB2-NEXT:    ldr r0, [sp, #4]
302; CHECK-THUMB2-NEXT:    subs.w r2, r2, r12
303; CHECK-THUMB2-NEXT:    sbcs.w r0, r3, r0
304; CHECK-THUMB2-NEXT:    mov.w r0, #0
305; CHECK-THUMB2-NEXT:    ite lt
306; CHECK-THUMB2-NEXT:    movlt r0, #1
307; CHECK-THUMB2-NEXT:    movge r1, #1
308; CHECK-THUMB2-NEXT:    bx lr
309entry:
310    %cmp = icmp slt i64 %a, %b
311    %not = xor i1 %cmp, true
312    %r1 = zext i1 %cmp to i32
313    %r2 = zext i1 %not to i32
314    %z = insertvalue { i32, i32 } undef, i32 %r1, 0
315    %z2 = insertvalue { i32, i32 } %z, i32 %r2, 1
316    ret { i32, i32 } %z2
317}
318