Skip to content

Commit 9a4a6d2

Browse files
committed
Add test case
1 parent 8c6c525 commit 9a4a6d2

File tree

2 files changed

+727
-0
lines changed

2 files changed

+727
-0
lines changed
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -O3 -mtriple=arm64-apple-macosx -o - %s | FileCheck %s
3+
4+
define i32 @switch_with_matching_dests_0_and_pow2_3_cases(i8 %v) {
5+
; CHECK-LABEL: switch_with_matching_dests_0_and_pow2_3_cases:
6+
; CHECK: ; %bb.0: ; %entry
7+
; CHECK-NEXT: mov w9, #100 ; =0x64
8+
; CHECK-NEXT: mov w8, #20 ; =0x14
9+
; CHECK-NEXT: LBB0_1: ; %loop.header
10+
; CHECK-NEXT: ; =>This Inner Loop Header: Depth=1
11+
; CHECK-NEXT: ands w10, w0, #0xff
12+
; CHECK-NEXT: b.eq LBB0_6
13+
; CHECK-NEXT: ; %bb.2: ; %loop.header
14+
; CHECK-NEXT: ; in Loop: Header=BB0_1 Depth=1
15+
; CHECK-NEXT: cmp w10, #32
16+
; CHECK-NEXT: b.eq LBB0_6
17+
; CHECK-NEXT: ; %bb.3: ; %loop.header
18+
; CHECK-NEXT: ; in Loop: Header=BB0_1 Depth=1
19+
; CHECK-NEXT: cmp w10, #124
20+
; CHECK-NEXT: b.eq LBB0_7
21+
; CHECK-NEXT: ; %bb.4: ; %loop.latch
22+
; CHECK-NEXT: ; in Loop: Header=BB0_1 Depth=1
23+
; CHECK-NEXT: subs w9, w9, #1
24+
; CHECK-NEXT: b.ne LBB0_1
25+
; CHECK-NEXT: ; %bb.5:
26+
; CHECK-NEXT: mov w8, #20 ; =0x14
27+
; CHECK-NEXT: LBB0_6: ; %common.ret
28+
; CHECK-NEXT: mov w0, w8
29+
; CHECK-NEXT: ret
30+
; CHECK-NEXT: LBB0_7: ; %e2
31+
; CHECK-NEXT: mov w0, #30 ; =0x1e
32+
; CHECK-NEXT: ret
33+
entry:
34+
br label %loop.header
35+
36+
loop.header:
37+
%iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]
38+
switch i8 %v, label %loop.latch [
39+
i8 32, label %e1
40+
i8 0, label %e1
41+
i8 124, label %e2
42+
]
43+
44+
loop.latch:
45+
%iv.next = add i32 %iv, 1
46+
%c = icmp eq i32 %iv.next, 100
47+
br i1 %c, label %e1, label %loop.header
48+
49+
e1:
50+
ret i32 20
51+
52+
e2:
53+
ret i32 30
54+
}
55+
56+
define i64 @consecutive_match_both(ptr %p, i32 %param) {
57+
; CHECK-LABEL: consecutive_match_both:
58+
; CHECK: ; %bb.0: ; %entry
59+
; CHECK-NEXT: mov w8, #1 ; =0x1
60+
; CHECK-NEXT: mov w9, #100 ; =0x64
61+
; CHECK-NEXT: mov w10, #249 ; =0xf9
62+
; CHECK-NEXT: lsl w8, w8, w1
63+
; CHECK-NEXT: b LBB1_2
64+
; CHECK-NEXT: LBB1_1: ; %loop.latch
65+
; CHECK-NEXT: ; in Loop: Header=BB1_2 Depth=1
66+
; CHECK-NEXT: subs w9, w9, #1
67+
; CHECK-NEXT: b.eq LBB1_5
68+
; CHECK-NEXT: LBB1_2: ; %loop.header
69+
; CHECK-NEXT: ; =>This Inner Loop Header: Depth=1
70+
; CHECK-NEXT: cmp w1, #7
71+
; CHECK-NEXT: b.hi LBB1_1
72+
; CHECK-NEXT: ; %bb.3: ; %loop.header
73+
; CHECK-NEXT: ; in Loop: Header=BB1_2 Depth=1
74+
; CHECK-NEXT: tst w8, w10
75+
; CHECK-NEXT: b.eq LBB1_1
76+
; CHECK-NEXT: ; %bb.4: ; %e0
77+
; CHECK-NEXT: mov x0, xzr
78+
; CHECK-NEXT: ret
79+
; CHECK-NEXT: LBB1_5:
80+
; CHECK-NEXT: mov x0, #-42 ; =0xffffffffffffffd6
81+
; CHECK-NEXT: ret
82+
entry:
83+
br label %loop.header
84+
85+
loop.header:
86+
%iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]
87+
switch i32 %param, label %loop.latch [
88+
i32 7, label %e0
89+
i32 6, label %e0
90+
i32 5, label %e0
91+
i32 4, label %e0
92+
i32 3, label %e0
93+
i32 0, label %e0
94+
]
95+
96+
loop.latch:
97+
%iv.next = add i32 %iv, 1
98+
%ec = icmp eq i32 %iv.next, 100
99+
br i1 %ec, label %e1, label %loop.header
100+
101+
e0:
102+
%m = getelementptr i8, ptr %p, i64 20
103+
br label %e1
104+
105+
e1:
106+
%res = phi i64 [ 0, %e0 ], [ -42, %loop.latch ]
107+
ret i64 %res
108+
}
109+
110+
define i64 @consecutive_match_before(ptr %p, i32 %param) {
111+
; CHECK-LABEL: consecutive_match_before:
112+
; CHECK: ; %bb.0: ; %entry
113+
; CHECK-NEXT: mov w8, #1 ; =0x1
114+
; CHECK-NEXT: mov w9, #100 ; =0x64
115+
; CHECK-NEXT: mov w10, #25 ; =0x19
116+
; CHECK-NEXT: lsl w8, w8, w1
117+
; CHECK-NEXT: b LBB2_2
118+
; CHECK-NEXT: LBB2_1: ; %loop.latch
119+
; CHECK-NEXT: ; in Loop: Header=BB2_2 Depth=1
120+
; CHECK-NEXT: subs w9, w9, #1
121+
; CHECK-NEXT: b.eq LBB2_5
122+
; CHECK-NEXT: LBB2_2: ; %loop.header
123+
; CHECK-NEXT: ; =>This Inner Loop Header: Depth=1
124+
; CHECK-NEXT: cmp w1, #4
125+
; CHECK-NEXT: b.hi LBB2_1
126+
; CHECK-NEXT: ; %bb.3: ; %loop.header
127+
; CHECK-NEXT: ; in Loop: Header=BB2_2 Depth=1
128+
; CHECK-NEXT: tst w8, w10
129+
; CHECK-NEXT: b.eq LBB2_1
130+
; CHECK-NEXT: ; %bb.4: ; %e0
131+
; CHECK-NEXT: mov x0, xzr
132+
; CHECK-NEXT: ret
133+
; CHECK-NEXT: LBB2_5:
134+
; CHECK-NEXT: mov x0, #-42 ; =0xffffffffffffffd6
135+
; CHECK-NEXT: ret
136+
entry:
137+
br label %loop.header
138+
139+
loop.header:
140+
%iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]
141+
switch i32 %param, label %loop.latch [
142+
i32 4, label %e0
143+
i32 3, label %e0
144+
i32 0, label %e0
145+
]
146+
147+
loop.latch:
148+
%iv.next = add i32 %iv, 1
149+
%ec = icmp eq i32 %iv.next, 100
150+
br i1 %ec, label %e1, label %loop.header
151+
152+
e0:
153+
%m = getelementptr i8, ptr %p, i64 20
154+
br label %e1
155+
156+
e1:
157+
%res = phi i64 [ 0, %e0 ], [ -42, %loop.latch ]
158+
ret i64 %res
159+
}
160+
161+
define i64 @consecutive_match_after(ptr %p, i32 %param) {
162+
; CHECK-LABEL: consecutive_match_after:
163+
; CHECK: ; %bb.0: ; %entry
164+
; CHECK-NEXT: mov w8, #1 ; =0x1
165+
; CHECK-NEXT: mov w9, #100 ; =0x64
166+
; CHECK-NEXT: mov w10, #49 ; =0x31
167+
; CHECK-NEXT: lsl w8, w8, w1
168+
; CHECK-NEXT: b LBB3_2
169+
; CHECK-NEXT: LBB3_1: ; %loop.latch
170+
; CHECK-NEXT: ; in Loop: Header=BB3_2 Depth=1
171+
; CHECK-NEXT: subs w9, w9, #1
172+
; CHECK-NEXT: b.eq LBB3_5
173+
; CHECK-NEXT: LBB3_2: ; %loop.header
174+
; CHECK-NEXT: ; =>This Inner Loop Header: Depth=1
175+
; CHECK-NEXT: cmp w1, #5
176+
; CHECK-NEXT: b.hi LBB3_1
177+
; CHECK-NEXT: ; %bb.3: ; %loop.header
178+
; CHECK-NEXT: ; in Loop: Header=BB3_2 Depth=1
179+
; CHECK-NEXT: tst w8, w10
180+
; CHECK-NEXT: b.eq LBB3_1
181+
; CHECK-NEXT: ; %bb.4: ; %e0
182+
; CHECK-NEXT: mov x0, xzr
183+
; CHECK-NEXT: ret
184+
; CHECK-NEXT: LBB3_5:
185+
; CHECK-NEXT: mov x0, #-42 ; =0xffffffffffffffd6
186+
; CHECK-NEXT: ret
187+
entry:
188+
br label %loop.header
189+
190+
loop.header:
191+
%iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]
192+
switch i32 %param, label %loop.latch [
193+
i32 5, label %e0
194+
i32 4, label %e0
195+
i32 0, label %e0
196+
]
197+
198+
loop.latch:
199+
%iv.next = add i32 %iv, 1
200+
%ec = icmp eq i32 %iv.next, 100
201+
br i1 %ec, label %e1, label %loop.header
202+
203+
e0:
204+
%m = getelementptr i8, ptr %p, i64 20
205+
br label %e1
206+
207+
e1:
208+
%res = phi i64 [ 0, %e0 ], [ -42, %loop.latch ]
209+
ret i64 %res
210+
}

0 commit comments

Comments
 (0)