1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc %s -mtriple=thumbv6m-arm-none-eabi -o - -asm-verbose=false | FileCheck %s --check-prefix=CHECK-V6M
3 ; RUN: llc %s -mtriple=thumbv7m-arm-none-eabi -o - -asm-verbose=false | FileCheck %s --check-prefix=CHECK-V7M
5 define i32 @test_values(i32 %a, i32 %b) minsize optsize {
6 ; CHECK-V6M-LABEL: test_values:
7 ; CHECK-V6M: mov r2, r0
8 ; CHECK-V6M-NEXT: ldr r0, .LCPI0_0
9 ; CHECK-V6M-NEXT: cmp r2, #50
10 ; CHECK-V6M-NEXT: beq .LBB0_5
11 ; CHECK-V6M-NEXT: cmp r2, #1
12 ; CHECK-V6M-NEXT: beq .LBB0_7
13 ; CHECK-V6M-NEXT: cmp r2, #30
14 ; CHECK-V6M-NEXT: beq .LBB0_8
15 ; CHECK-V6M-NEXT: cmp r2, #0
16 ; CHECK-V6M-NEXT: bne .LBB0_6
17 ; CHECK-V6M-NEXT: adds r0, r1, r0
18 ; CHECK-V6M-NEXT: bx lr
19 ; CHECK-V6M-NEXT: .LBB0_5:
20 ; CHECK-V6M-NEXT: adds r0, r0, r1
21 ; CHECK-V6M-NEXT: adds r0, r0, #4
22 ; CHECK-V6M-NEXT: .LBB0_6:
23 ; CHECK-V6M-NEXT: bx lr
24 ; CHECK-V6M-NEXT: .LBB0_7:
25 ; CHECK-V6M-NEXT: adds r0, r0, r1
26 ; CHECK-V6M-NEXT: adds r0, r0, #1
27 ; CHECK-V6M-NEXT: bx lr
28 ; CHECK-V6M-NEXT: .LBB0_8:
29 ; CHECK-V6M-NEXT: adds r0, r0, r1
30 ; CHECK-V6M-NEXT: adds r0, r0, #2
31 ; CHECK-V6M-NEXT: bx lr
32 ; CHECK-V6M-NEXT: .p2align 2
33 ; CHECK-V6M-NEXT: .LCPI0_0:
34 ; CHECK-V6M-NEXT: .long 537923600
36 ; CHECK-V7M-LABEL: test_values:
37 ; CHECK-V7M: mov r2, r0
38 ; CHECK-V7M-NEXT: ldr r0, .LCPI0_0
39 ; CHECK-V7M-NEXT: cmp r2, #50
40 ; CHECK-V7M-NEXT: beq .LBB0_3
41 ; CHECK-V7M-NEXT: cmp r2, #1
42 ; CHECK-V7M-NEXT: ittt eq
43 ; CHECK-V7M-NEXT: addeq r0, r1
44 ; CHECK-V7M-NEXT: addeq r0, #1
45 ; CHECK-V7M-NEXT: bxeq lr
46 ; CHECK-V7M-NEXT: cmp r2, #30
47 ; CHECK-V7M-NEXT: ittt eq
48 ; CHECK-V7M-NEXT: addeq r0, r1
49 ; CHECK-V7M-NEXT: addeq r0, #2
50 ; CHECK-V7M-NEXT: bxeq lr
51 ; CHECK-V7M-NEXT: cbnz r2, .LBB0_4
52 ; CHECK-V7M-NEXT: .LBB0_2:
53 ; CHECK-V7M-NEXT: add r0, r1
54 ; CHECK-V7M-NEXT: bx lr
55 ; CHECK-V7M-NEXT: .LBB0_3:
56 ; CHECK-V7M-NEXT: add r0, r1
57 ; CHECK-V7M-NEXT: adds r0, #4
58 ; CHECK-V7M-NEXT: .LBB0_4:
59 ; CHECK-V7M-NEXT: bx lr
60 ; CHECK-V7M-NEXT: .p2align 2
61 ; CHECK-V7M-NEXT: .LCPI0_0:
62 ; CHECK-V7M-NEXT: .long 537923600
64 switch i32 %a, label %return [
71 sw.bb: ; preds = %entry
72 %add = add nsw i32 %b, 537923600
75 sw.bb1: ; preds = %entry
76 %add2 = add nsw i32 %b, 537923601
79 sw.bb3: ; preds = %entry
80 %add4 = add nsw i32 %b, 537923602
83 sw.bb5: ; preds = %entry
84 %add6 = add nsw i32 %b, 537923604
87 return: ; preds = %entry, %sw.bb5, %sw.bb3, %sw.bb1, %sw.bb
88 %retval.0 = phi i32 [ %add6, %sw.bb5 ], [ %add4, %sw.bb3 ], [ %add2, %sw.bb1 ], [ %add, %sw.bb ], [ 537923600, %entry ]
92 define i32 @test_addr(i32 %a, i8* nocapture readonly %b) {
93 ; CHECK-V6M-LABEL: test_addr:
94 ; CHECK-V6M: mov r2, r0
95 ; CHECK-V6M-NEXT: movs r0, #19
96 ; CHECK-V6M-NEXT: lsls r3, r0, #4
97 ; CHECK-V6M-NEXT: movs r0, #0
98 ; CHECK-V6M-NEXT: cmp r2, #29
99 ; CHECK-V6M-NEXT: bgt .LBB1_4
100 ; CHECK-V6M-NEXT: cmp r2, #0
101 ; CHECK-V6M-NEXT: beq .LBB1_8
102 ; CHECK-V6M-NEXT: cmp r2, #1
103 ; CHECK-V6M-NEXT: bne .LBB1_9
104 ; CHECK-V6M-NEXT: adds r3, r3, #1
105 ; CHECK-V6M-NEXT: b .LBB1_8
106 ; CHECK-V6M-NEXT: .LBB1_4:
107 ; CHECK-V6M-NEXT: cmp r2, #30
108 ; CHECK-V6M-NEXT: beq .LBB1_7
109 ; CHECK-V6M-NEXT: cmp r2, #50
110 ; CHECK-V6M-NEXT: bne .LBB1_9
111 ; CHECK-V6M-NEXT: adds r3, r3, #3
112 ; CHECK-V6M-NEXT: b .LBB1_8
113 ; CHECK-V6M-NEXT: .LBB1_7:
114 ; CHECK-V6M-NEXT: adds r3, r3, #2
115 ; CHECK-V6M-NEXT: .LBB1_8:
116 ; CHECK-V6M-NEXT: ldrb r0, [r1, r3]
117 ; CHECK-V6M-NEXT: .LBB1_9:
118 ; CHECK-V6M-NEXT: bx lr
120 ; CHECK-V7M-LABEL: test_addr:
121 ; CHECK-V7M: mov r2, r0
122 ; CHECK-V7M-NEXT: movs r0, #0
123 ; CHECK-V7M-NEXT: cmp r2, #29
124 ; CHECK-V7M-NEXT: bgt .LBB1_3
125 ; CHECK-V7M-NEXT: cbz r2, .LBB1_6
126 ; CHECK-V7M-NEXT: cmp r2, #1
127 ; CHECK-V7M-NEXT: it ne
128 ; CHECK-V7M-NEXT: bxne lr
129 ; CHECK-V7M-NEXT: movw r0, #305
130 ; CHECK-V7M-NEXT: b .LBB1_8
131 ; CHECK-V7M-NEXT: .LBB1_3:
132 ; CHECK-V7M-NEXT: cmp r2, #30
133 ; CHECK-V7M-NEXT: beq .LBB1_7
134 ; CHECK-V7M-NEXT: cmp r2, #50
135 ; CHECK-V7M-NEXT: bne .LBB1_9
136 ; CHECK-V7M-NEXT: movw r0, #307
137 ; CHECK-V7M-NEXT: b .LBB1_8
138 ; CHECK-V7M-NEXT: .LBB1_6:
139 ; CHECK-V7M-NEXT: mov.w r0, #304
140 ; CHECK-V7M-NEXT: b .LBB1_8
141 ; CHECK-V7M-NEXT: .LBB1_7:
142 ; CHECK-V7M-NEXT: mov.w r0, #306
143 ; CHECK-V7M-NEXT: .LBB1_8:
144 ; CHECK-V7M-NEXT: ldrb r0, [r1, r0]
145 ; CHECK-V7M-NEXT: .LBB1_9:
146 ; CHECK-V7M-NEXT: bx lr
148 switch i32 %a, label %return [
149 i32 0, label %return.sink.split
151 i32 30, label %sw.bb4
152 i32 50, label %sw.bb7
155 sw.bb1: ; preds = %entry
156 br label %return.sink.split
158 sw.bb4: ; preds = %entry
159 br label %return.sink.split
161 sw.bb7: ; preds = %entry
162 br label %return.sink.split
164 return.sink.split: ; preds = %entry, %sw.bb1, %sw.bb4, %sw.bb7
165 %.sink = phi i32 [ 307, %sw.bb7 ], [ 306, %sw.bb4 ], [ 305, %sw.bb1 ], [ 304, %entry ]
166 %arrayidx8 = getelementptr inbounds i8, i8* %b, i32 %.sink
167 %0 = load i8, i8* %arrayidx8, align 1
168 %phitmp = zext i8 %0 to i32
171 return: ; preds = %return.sink.split, %entry
172 %retval.0.shrunk = phi i32 [ 0, %entry ], [ %phitmp, %return.sink.split ]
173 ret i32 %retval.0.shrunk