1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -mtriple=thumbv8m.main < %s -simplifycfg -S -two-entry-phi-node-folding-threshold=4 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-4,CHECK-V8M-TWO-FOLD-4
3; RUN: opt -mtriple=armv8a < %s -simplifycfg -S -two-entry-phi-node-folding-threshold=4 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-4,CHECK-V8A-TWO-FOLD-4
4; RUN: opt -mtriple=thumbv8m.main < %s -simplifycfg -S -two-entry-phi-node-folding-threshold=5 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-5,CHECK-V8M-TWO-FOLD-5
5; RUN: opt -mtriple=armv8a < %s -simplifycfg -S -two-entry-phi-node-folding-threshold=5 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-5,CHECK-V8A-TWO-FOLD-5
6; RUN: opt -mtriple=thumbv8m.main < %s -simplifycfg -S -two-entry-phi-node-folding-threshold=6 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-6,CHECK-V8M-TWO-FOLD-6
7; RUN: opt -mtriple=armv8a < %s -simplifycfg -S -two-entry-phi-node-folding-threshold=6 | FileCheck %s --check-prefixes=CHECK-TWO-FOLD-6,CHECK-V8A-TWO-FOLD-6
8
9define i32 @test_i32(i1 %a, i1 %b, i32 %i, i32 %j, i32 %k) {
10; CHECK-TWO-FOLD-4-LABEL: @test_i32(
11; CHECK-TWO-FOLD-4-NEXT:  entry:
12; CHECK-TWO-FOLD-4-NEXT:    br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
13; CHECK-TWO-FOLD-4:       O:
14; CHECK-TWO-FOLD-4-NEXT:    [[IAJ:%.*]] = add i32 [[I:%.*]], [[J:%.*]]
15; CHECK-TWO-FOLD-4-NEXT:    [[IAJAK:%.*]] = add i32 [[IAJ]], [[K:%.*]]
16; CHECK-TWO-FOLD-4-NEXT:    [[IXJ:%.*]] = xor i32 [[I]], [[J]]
17; CHECK-TWO-FOLD-4-NEXT:    [[IXJXK:%.*]] = xor i32 [[IXJ]], [[K]]
18; CHECK-TWO-FOLD-4-NEXT:    [[WP:%.*]] = select i1 [[B:%.*]], i32 [[IAJAK]], i32 [[IXJXK]]
19; CHECK-TWO-FOLD-4-NEXT:    [[WP2:%.*]] = add i32 [[WP]], [[WP]]
20; CHECK-TWO-FOLD-4-NEXT:    br label [[M]]
21; CHECK-TWO-FOLD-4:       M:
22; CHECK-TWO-FOLD-4-NEXT:    [[W:%.*]] = phi i32 [ [[WP2]], [[O]] ], [ 2, [[ENTRY:%.*]] ]
23; CHECK-TWO-FOLD-4-NEXT:    [[R:%.*]] = add i32 [[W]], 1
24; CHECK-TWO-FOLD-4-NEXT:    ret i32 [[R]]
25;
26; CHECK-TWO-FOLD-5-LABEL: @test_i32(
27; CHECK-TWO-FOLD-5-NEXT:  entry:
28; CHECK-TWO-FOLD-5-NEXT:    br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
29; CHECK-TWO-FOLD-5:       O:
30; CHECK-TWO-FOLD-5-NEXT:    [[IAJ:%.*]] = add i32 [[I:%.*]], [[J:%.*]]
31; CHECK-TWO-FOLD-5-NEXT:    [[IAJAK:%.*]] = add i32 [[IAJ]], [[K:%.*]]
32; CHECK-TWO-FOLD-5-NEXT:    [[IXJ:%.*]] = xor i32 [[I]], [[J]]
33; CHECK-TWO-FOLD-5-NEXT:    [[IXJXK:%.*]] = xor i32 [[IXJ]], [[K]]
34; CHECK-TWO-FOLD-5-NEXT:    [[WP:%.*]] = select i1 [[B:%.*]], i32 [[IAJAK]], i32 [[IXJXK]]
35; CHECK-TWO-FOLD-5-NEXT:    [[WP2:%.*]] = add i32 [[WP]], [[WP]]
36; CHECK-TWO-FOLD-5-NEXT:    br label [[M]]
37; CHECK-TWO-FOLD-5:       M:
38; CHECK-TWO-FOLD-5-NEXT:    [[W:%.*]] = phi i32 [ [[WP2]], [[O]] ], [ 2, [[ENTRY:%.*]] ]
39; CHECK-TWO-FOLD-5-NEXT:    [[R:%.*]] = add i32 [[W]], 1
40; CHECK-TWO-FOLD-5-NEXT:    ret i32 [[R]]
41;
42; CHECK-TWO-FOLD-6-LABEL: @test_i32(
43; CHECK-TWO-FOLD-6-NEXT:  entry:
44; CHECK-TWO-FOLD-6-NEXT:    [[IAJ:%.*]] = add i32 [[I:%.*]], [[J:%.*]]
45; CHECK-TWO-FOLD-6-NEXT:    [[IAJAK:%.*]] = add i32 [[IAJ]], [[K:%.*]]
46; CHECK-TWO-FOLD-6-NEXT:    [[IXJ:%.*]] = xor i32 [[I]], [[J]]
47; CHECK-TWO-FOLD-6-NEXT:    [[IXJXK:%.*]] = xor i32 [[IXJ]], [[K]]
48; CHECK-TWO-FOLD-6-NEXT:    [[WP:%.*]] = select i1 [[B:%.*]], i32 [[IAJAK]], i32 [[IXJXK]]
49; CHECK-TWO-FOLD-6-NEXT:    [[WP2:%.*]] = add i32 [[WP]], [[WP]]
50; CHECK-TWO-FOLD-6-NEXT:    [[W:%.*]] = select i1 [[A:%.*]], i32 2, i32 [[WP2]]
51; CHECK-TWO-FOLD-6-NEXT:    [[R:%.*]] = add i32 [[W]], 1
52; CHECK-TWO-FOLD-6-NEXT:    ret i32 [[R]]
53;
54entry:
55  br i1 %a, label %M, label %O
56O:
57  br i1 %b, label %P, label %Q
58P:
59  %iaj = add i32 %i, %j
60  %iajak = add i32 %iaj, %k
61  br label %N
62Q:
63  %ixj = xor i32 %i, %j
64  %ixjxk = xor i32 %ixj, %k
65  br label %N
66N:
67  %Wp = phi i32 [ %iajak, %P ], [ %ixjxk, %Q ]
68  %Wp2 = add i32 %Wp, %Wp
69  br label %M
70M:
71  %W = phi i32 [ %Wp2, %N ], [ 2, %entry ]
72  %R = add i32 %W, 1
73  ret i32 %R
74}
75
76define i32 @test_i32_minsize(i1 %a, i1 %b, i32 %i, i32 %j, i32 %k) #0 {
77; CHECK-TWO-FOLD-4-LABEL: @test_i32_minsize(
78; CHECK-TWO-FOLD-4-NEXT:  entry:
79; CHECK-TWO-FOLD-4-NEXT:    br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
80; CHECK-TWO-FOLD-4:       O:
81; CHECK-TWO-FOLD-4-NEXT:    [[IAJ:%.*]] = add i32 [[I:%.*]], [[J:%.*]]
82; CHECK-TWO-FOLD-4-NEXT:    [[IAJAK:%.*]] = add i32 [[IAJ]], [[K:%.*]]
83; CHECK-TWO-FOLD-4-NEXT:    [[IXJ:%.*]] = xor i32 [[I]], [[J]]
84; CHECK-TWO-FOLD-4-NEXT:    [[IXJXK:%.*]] = xor i32 [[IXJ]], [[K]]
85; CHECK-TWO-FOLD-4-NEXT:    [[WP:%.*]] = select i1 [[B:%.*]], i32 [[IAJAK]], i32 [[IXJXK]]
86; CHECK-TWO-FOLD-4-NEXT:    [[WP2:%.*]] = add i32 [[WP]], [[WP]]
87; CHECK-TWO-FOLD-4-NEXT:    br label [[M]]
88; CHECK-TWO-FOLD-4:       M:
89; CHECK-TWO-FOLD-4-NEXT:    [[W:%.*]] = phi i32 [ [[WP2]], [[O]] ], [ 2, [[ENTRY:%.*]] ]
90; CHECK-TWO-FOLD-4-NEXT:    [[R:%.*]] = add i32 [[W]], 1
91; CHECK-TWO-FOLD-4-NEXT:    ret i32 [[R]]
92;
93; CHECK-TWO-FOLD-5-LABEL: @test_i32_minsize(
94; CHECK-TWO-FOLD-5-NEXT:  entry:
95; CHECK-TWO-FOLD-5-NEXT:    br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
96; CHECK-TWO-FOLD-5:       O:
97; CHECK-TWO-FOLD-5-NEXT:    [[IAJ:%.*]] = add i32 [[I:%.*]], [[J:%.*]]
98; CHECK-TWO-FOLD-5-NEXT:    [[IAJAK:%.*]] = add i32 [[IAJ]], [[K:%.*]]
99; CHECK-TWO-FOLD-5-NEXT:    [[IXJ:%.*]] = xor i32 [[I]], [[J]]
100; CHECK-TWO-FOLD-5-NEXT:    [[IXJXK:%.*]] = xor i32 [[IXJ]], [[K]]
101; CHECK-TWO-FOLD-5-NEXT:    [[WP:%.*]] = select i1 [[B:%.*]], i32 [[IAJAK]], i32 [[IXJXK]]
102; CHECK-TWO-FOLD-5-NEXT:    [[WP2:%.*]] = add i32 [[WP]], [[WP]]
103; CHECK-TWO-FOLD-5-NEXT:    br label [[M]]
104; CHECK-TWO-FOLD-5:       M:
105; CHECK-TWO-FOLD-5-NEXT:    [[W:%.*]] = phi i32 [ [[WP2]], [[O]] ], [ 2, [[ENTRY:%.*]] ]
106; CHECK-TWO-FOLD-5-NEXT:    [[R:%.*]] = add i32 [[W]], 1
107; CHECK-TWO-FOLD-5-NEXT:    ret i32 [[R]]
108;
109; CHECK-TWO-FOLD-6-LABEL: @test_i32_minsize(
110; CHECK-TWO-FOLD-6-NEXT:  entry:
111; CHECK-TWO-FOLD-6-NEXT:    [[IAJ:%.*]] = add i32 [[I:%.*]], [[J:%.*]]
112; CHECK-TWO-FOLD-6-NEXT:    [[IAJAK:%.*]] = add i32 [[IAJ]], [[K:%.*]]
113; CHECK-TWO-FOLD-6-NEXT:    [[IXJ:%.*]] = xor i32 [[I]], [[J]]
114; CHECK-TWO-FOLD-6-NEXT:    [[IXJXK:%.*]] = xor i32 [[IXJ]], [[K]]
115; CHECK-TWO-FOLD-6-NEXT:    [[WP:%.*]] = select i1 [[B:%.*]], i32 [[IAJAK]], i32 [[IXJXK]]
116; CHECK-TWO-FOLD-6-NEXT:    [[WP2:%.*]] = add i32 [[WP]], [[WP]]
117; CHECK-TWO-FOLD-6-NEXT:    [[W:%.*]] = select i1 [[A:%.*]], i32 2, i32 [[WP2]]
118; CHECK-TWO-FOLD-6-NEXT:    [[R:%.*]] = add i32 [[W]], 1
119; CHECK-TWO-FOLD-6-NEXT:    ret i32 [[R]]
120;
121entry:
122  br i1 %a, label %M, label %O
123O:
124  br i1 %b, label %P, label %Q
125P:
126  %iaj = add i32 %i, %j
127  %iajak = add i32 %iaj, %k
128  br label %N
129Q:
130  %ixj = xor i32 %i, %j
131  %ixjxk = xor i32 %ixj, %k
132  br label %N
133N:
134  %Wp = phi i32 [ %iajak, %P ], [ %ixjxk, %Q ]
135  %Wp2 = add i32 %Wp, %Wp
136  br label %M
137M:
138  %W = phi i32 [ %Wp2, %N ], [ 2, %entry ]
139  %R = add i32 %W, 1
140  ret i32 %R
141}
142
143define i64 @test_i64(i1 %a, i1 %b, i64 %i, i64 %j, i64 %k) {
144; CHECK-V8M-TWO-FOLD-4-LABEL: @test_i64(
145; CHECK-V8M-TWO-FOLD-4-NEXT:  entry:
146; CHECK-V8M-TWO-FOLD-4-NEXT:    br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
147; CHECK-V8M-TWO-FOLD-4:       O:
148; CHECK-V8M-TWO-FOLD-4-NEXT:    br i1 [[B:%.*]], label [[P:%.*]], label [[Q:%.*]]
149; CHECK-V8M-TWO-FOLD-4:       P:
150; CHECK-V8M-TWO-FOLD-4-NEXT:    [[IAJ:%.*]] = add i64 [[I:%.*]], [[J:%.*]]
151; CHECK-V8M-TWO-FOLD-4-NEXT:    [[IAJAK:%.*]] = add i64 [[IAJ]], [[K:%.*]]
152; CHECK-V8M-TWO-FOLD-4-NEXT:    br label [[N:%.*]]
153; CHECK-V8M-TWO-FOLD-4:       Q:
154; CHECK-V8M-TWO-FOLD-4-NEXT:    [[IXJ:%.*]] = xor i64 [[I]], [[J]]
155; CHECK-V8M-TWO-FOLD-4-NEXT:    [[IXJXK:%.*]] = xor i64 [[IXJ]], [[K]]
156; CHECK-V8M-TWO-FOLD-4-NEXT:    br label [[N]]
157; CHECK-V8M-TWO-FOLD-4:       N:
158; CHECK-V8M-TWO-FOLD-4-NEXT:    [[WP:%.*]] = phi i64 [ [[IAJAK]], [[P]] ], [ [[IXJXK]], [[Q]] ]
159; CHECK-V8M-TWO-FOLD-4-NEXT:    [[WP2:%.*]] = add i64 [[WP]], [[WP]]
160; CHECK-V8M-TWO-FOLD-4-NEXT:    br label [[M]]
161; CHECK-V8M-TWO-FOLD-4:       M:
162; CHECK-V8M-TWO-FOLD-4-NEXT:    [[W:%.*]] = phi i64 [ [[WP2]], [[N]] ], [ 2, [[ENTRY:%.*]] ]
163; CHECK-V8M-TWO-FOLD-4-NEXT:    [[R:%.*]] = add i64 [[W]], 1
164; CHECK-V8M-TWO-FOLD-4-NEXT:    ret i64 [[R]]
165;
166; CHECK-V8A-TWO-FOLD-4-LABEL: @test_i64(
167; CHECK-V8A-TWO-FOLD-4-NEXT:  entry:
168; CHECK-V8A-TWO-FOLD-4-NEXT:    br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
169; CHECK-V8A-TWO-FOLD-4:       O:
170; CHECK-V8A-TWO-FOLD-4-NEXT:    [[IAJ:%.*]] = add i64 [[I:%.*]], [[J:%.*]]
171; CHECK-V8A-TWO-FOLD-4-NEXT:    [[IAJAK:%.*]] = add i64 [[IAJ]], [[K:%.*]]
172; CHECK-V8A-TWO-FOLD-4-NEXT:    [[IXJ:%.*]] = xor i64 [[I]], [[J]]
173; CHECK-V8A-TWO-FOLD-4-NEXT:    [[IXJXK:%.*]] = xor i64 [[IXJ]], [[K]]
174; CHECK-V8A-TWO-FOLD-4-NEXT:    [[WP:%.*]] = select i1 [[B:%.*]], i64 [[IAJAK]], i64 [[IXJXK]]
175; CHECK-V8A-TWO-FOLD-4-NEXT:    [[WP2:%.*]] = add i64 [[WP]], [[WP]]
176; CHECK-V8A-TWO-FOLD-4-NEXT:    br label [[M]]
177; CHECK-V8A-TWO-FOLD-4:       M:
178; CHECK-V8A-TWO-FOLD-4-NEXT:    [[W:%.*]] = phi i64 [ [[WP2]], [[O]] ], [ 2, [[ENTRY:%.*]] ]
179; CHECK-V8A-TWO-FOLD-4-NEXT:    [[R:%.*]] = add i64 [[W]], 1
180; CHECK-V8A-TWO-FOLD-4-NEXT:    ret i64 [[R]]
181;
182; CHECK-V8M-TWO-FOLD-5-LABEL: @test_i64(
183; CHECK-V8M-TWO-FOLD-5-NEXT:  entry:
184; CHECK-V8M-TWO-FOLD-5-NEXT:    br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
185; CHECK-V8M-TWO-FOLD-5:       O:
186; CHECK-V8M-TWO-FOLD-5-NEXT:    br i1 [[B:%.*]], label [[P:%.*]], label [[Q:%.*]]
187; CHECK-V8M-TWO-FOLD-5:       P:
188; CHECK-V8M-TWO-FOLD-5-NEXT:    [[IAJ:%.*]] = add i64 [[I:%.*]], [[J:%.*]]
189; CHECK-V8M-TWO-FOLD-5-NEXT:    [[IAJAK:%.*]] = add i64 [[IAJ]], [[K:%.*]]
190; CHECK-V8M-TWO-FOLD-5-NEXT:    br label [[N:%.*]]
191; CHECK-V8M-TWO-FOLD-5:       Q:
192; CHECK-V8M-TWO-FOLD-5-NEXT:    [[IXJ:%.*]] = xor i64 [[I]], [[J]]
193; CHECK-V8M-TWO-FOLD-5-NEXT:    [[IXJXK:%.*]] = xor i64 [[IXJ]], [[K]]
194; CHECK-V8M-TWO-FOLD-5-NEXT:    br label [[N]]
195; CHECK-V8M-TWO-FOLD-5:       N:
196; CHECK-V8M-TWO-FOLD-5-NEXT:    [[WP:%.*]] = phi i64 [ [[IAJAK]], [[P]] ], [ [[IXJXK]], [[Q]] ]
197; CHECK-V8M-TWO-FOLD-5-NEXT:    [[WP2:%.*]] = add i64 [[WP]], [[WP]]
198; CHECK-V8M-TWO-FOLD-5-NEXT:    br label [[M]]
199; CHECK-V8M-TWO-FOLD-5:       M:
200; CHECK-V8M-TWO-FOLD-5-NEXT:    [[W:%.*]] = phi i64 [ [[WP2]], [[N]] ], [ 2, [[ENTRY:%.*]] ]
201; CHECK-V8M-TWO-FOLD-5-NEXT:    [[R:%.*]] = add i64 [[W]], 1
202; CHECK-V8M-TWO-FOLD-5-NEXT:    ret i64 [[R]]
203;
204; CHECK-V8A-TWO-FOLD-5-LABEL: @test_i64(
205; CHECK-V8A-TWO-FOLD-5-NEXT:  entry:
206; CHECK-V8A-TWO-FOLD-5-NEXT:    br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
207; CHECK-V8A-TWO-FOLD-5:       O:
208; CHECK-V8A-TWO-FOLD-5-NEXT:    [[IAJ:%.*]] = add i64 [[I:%.*]], [[J:%.*]]
209; CHECK-V8A-TWO-FOLD-5-NEXT:    [[IAJAK:%.*]] = add i64 [[IAJ]], [[K:%.*]]
210; CHECK-V8A-TWO-FOLD-5-NEXT:    [[IXJ:%.*]] = xor i64 [[I]], [[J]]
211; CHECK-V8A-TWO-FOLD-5-NEXT:    [[IXJXK:%.*]] = xor i64 [[IXJ]], [[K]]
212; CHECK-V8A-TWO-FOLD-5-NEXT:    [[WP:%.*]] = select i1 [[B:%.*]], i64 [[IAJAK]], i64 [[IXJXK]]
213; CHECK-V8A-TWO-FOLD-5-NEXT:    [[WP2:%.*]] = add i64 [[WP]], [[WP]]
214; CHECK-V8A-TWO-FOLD-5-NEXT:    br label [[M]]
215; CHECK-V8A-TWO-FOLD-5:       M:
216; CHECK-V8A-TWO-FOLD-5-NEXT:    [[W:%.*]] = phi i64 [ [[WP2]], [[O]] ], [ 2, [[ENTRY:%.*]] ]
217; CHECK-V8A-TWO-FOLD-5-NEXT:    [[R:%.*]] = add i64 [[W]], 1
218; CHECK-V8A-TWO-FOLD-5-NEXT:    ret i64 [[R]]
219;
220; CHECK-V8M-TWO-FOLD-6-LABEL: @test_i64(
221; CHECK-V8M-TWO-FOLD-6-NEXT:  entry:
222; CHECK-V8M-TWO-FOLD-6-NEXT:    br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
223; CHECK-V8M-TWO-FOLD-6:       O:
224; CHECK-V8M-TWO-FOLD-6-NEXT:    br i1 [[B:%.*]], label [[P:%.*]], label [[Q:%.*]]
225; CHECK-V8M-TWO-FOLD-6:       P:
226; CHECK-V8M-TWO-FOLD-6-NEXT:    [[IAJ:%.*]] = add i64 [[I:%.*]], [[J:%.*]]
227; CHECK-V8M-TWO-FOLD-6-NEXT:    [[IAJAK:%.*]] = add i64 [[IAJ]], [[K:%.*]]
228; CHECK-V8M-TWO-FOLD-6-NEXT:    br label [[N:%.*]]
229; CHECK-V8M-TWO-FOLD-6:       Q:
230; CHECK-V8M-TWO-FOLD-6-NEXT:    [[IXJ:%.*]] = xor i64 [[I]], [[J]]
231; CHECK-V8M-TWO-FOLD-6-NEXT:    [[IXJXK:%.*]] = xor i64 [[IXJ]], [[K]]
232; CHECK-V8M-TWO-FOLD-6-NEXT:    br label [[N]]
233; CHECK-V8M-TWO-FOLD-6:       N:
234; CHECK-V8M-TWO-FOLD-6-NEXT:    [[WP:%.*]] = phi i64 [ [[IAJAK]], [[P]] ], [ [[IXJXK]], [[Q]] ]
235; CHECK-V8M-TWO-FOLD-6-NEXT:    [[WP2:%.*]] = add i64 [[WP]], [[WP]]
236; CHECK-V8M-TWO-FOLD-6-NEXT:    br label [[M]]
237; CHECK-V8M-TWO-FOLD-6:       M:
238; CHECK-V8M-TWO-FOLD-6-NEXT:    [[W:%.*]] = phi i64 [ [[WP2]], [[N]] ], [ 2, [[ENTRY:%.*]] ]
239; CHECK-V8M-TWO-FOLD-6-NEXT:    [[R:%.*]] = add i64 [[W]], 1
240; CHECK-V8M-TWO-FOLD-6-NEXT:    ret i64 [[R]]
241;
242; CHECK-V8A-TWO-FOLD-6-LABEL: @test_i64(
243; CHECK-V8A-TWO-FOLD-6-NEXT:  entry:
244; CHECK-V8A-TWO-FOLD-6-NEXT:    [[IAJ:%.*]] = add i64 [[I:%.*]], [[J:%.*]]
245; CHECK-V8A-TWO-FOLD-6-NEXT:    [[IAJAK:%.*]] = add i64 [[IAJ]], [[K:%.*]]
246; CHECK-V8A-TWO-FOLD-6-NEXT:    [[IXJ:%.*]] = xor i64 [[I]], [[J]]
247; CHECK-V8A-TWO-FOLD-6-NEXT:    [[IXJXK:%.*]] = xor i64 [[IXJ]], [[K]]
248; CHECK-V8A-TWO-FOLD-6-NEXT:    [[WP:%.*]] = select i1 [[B:%.*]], i64 [[IAJAK]], i64 [[IXJXK]]
249; CHECK-V8A-TWO-FOLD-6-NEXT:    [[WP2:%.*]] = add i64 [[WP]], [[WP]]
250; CHECK-V8A-TWO-FOLD-6-NEXT:    [[W:%.*]] = select i1 [[A:%.*]], i64 2, i64 [[WP2]]
251; CHECK-V8A-TWO-FOLD-6-NEXT:    [[R:%.*]] = add i64 [[W]], 1
252; CHECK-V8A-TWO-FOLD-6-NEXT:    ret i64 [[R]]
253;
254entry:
255  br i1 %a, label %M, label %O
256O:
257  br i1 %b, label %P, label %Q
258P:
259  %iaj = add i64 %i, %j
260  %iajak = add i64 %iaj, %k
261  br label %N
262Q:
263  %ixj = xor i64 %i, %j
264  %ixjxk = xor i64 %ixj, %k
265  br label %N
266N:
267  %Wp = phi i64 [ %iajak, %P ], [ %ixjxk, %Q ]
268  %Wp2 = add i64 %Wp, %Wp
269  br label %M
270M:
271  %W = phi i64 [ %Wp2, %N ], [ 2, %entry ]
272  %R = add i64 %W, 1
273  ret i64 %R
274}
275
276define i64 @test_i64_minsize(i1 %a, i1 %b, i64 %i, i64 %j, i64 %k) #0 {
277; CHECK-V8M-TWO-FOLD-4-LABEL: @test_i64_minsize(
278; CHECK-V8M-TWO-FOLD-4-NEXT:  entry:
279; CHECK-V8M-TWO-FOLD-4-NEXT:    br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
280; CHECK-V8M-TWO-FOLD-4:       O:
281; CHECK-V8M-TWO-FOLD-4-NEXT:    br i1 [[B:%.*]], label [[P:%.*]], label [[Q:%.*]]
282; CHECK-V8M-TWO-FOLD-4:       P:
283; CHECK-V8M-TWO-FOLD-4-NEXT:    [[IAJ:%.*]] = add i64 [[I:%.*]], [[J:%.*]]
284; CHECK-V8M-TWO-FOLD-4-NEXT:    [[IAJAK:%.*]] = add i64 [[IAJ]], [[K:%.*]]
285; CHECK-V8M-TWO-FOLD-4-NEXT:    br label [[N:%.*]]
286; CHECK-V8M-TWO-FOLD-4:       Q:
287; CHECK-V8M-TWO-FOLD-4-NEXT:    [[IXJ:%.*]] = xor i64 [[I]], [[J]]
288; CHECK-V8M-TWO-FOLD-4-NEXT:    [[IXJXK:%.*]] = xor i64 [[IXJ]], [[K]]
289; CHECK-V8M-TWO-FOLD-4-NEXT:    br label [[N]]
290; CHECK-V8M-TWO-FOLD-4:       N:
291; CHECK-V8M-TWO-FOLD-4-NEXT:    [[WP:%.*]] = phi i64 [ [[IAJAK]], [[P]] ], [ [[IXJXK]], [[Q]] ]
292; CHECK-V8M-TWO-FOLD-4-NEXT:    [[WP2:%.*]] = add i64 [[WP]], [[WP]]
293; CHECK-V8M-TWO-FOLD-4-NEXT:    br label [[M]]
294; CHECK-V8M-TWO-FOLD-4:       M:
295; CHECK-V8M-TWO-FOLD-4-NEXT:    [[W:%.*]] = phi i64 [ [[WP2]], [[N]] ], [ 2, [[ENTRY:%.*]] ]
296; CHECK-V8M-TWO-FOLD-4-NEXT:    [[R:%.*]] = add i64 [[W]], 1
297; CHECK-V8M-TWO-FOLD-4-NEXT:    ret i64 [[R]]
298;
299; CHECK-V8A-TWO-FOLD-4-LABEL: @test_i64_minsize(
300; CHECK-V8A-TWO-FOLD-4-NEXT:  entry:
301; CHECK-V8A-TWO-FOLD-4-NEXT:    br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
302; CHECK-V8A-TWO-FOLD-4:       O:
303; CHECK-V8A-TWO-FOLD-4-NEXT:    [[IAJ:%.*]] = add i64 [[I:%.*]], [[J:%.*]]
304; CHECK-V8A-TWO-FOLD-4-NEXT:    [[IAJAK:%.*]] = add i64 [[IAJ]], [[K:%.*]]
305; CHECK-V8A-TWO-FOLD-4-NEXT:    [[IXJ:%.*]] = xor i64 [[I]], [[J]]
306; CHECK-V8A-TWO-FOLD-4-NEXT:    [[IXJXK:%.*]] = xor i64 [[IXJ]], [[K]]
307; CHECK-V8A-TWO-FOLD-4-NEXT:    [[WP:%.*]] = select i1 [[B:%.*]], i64 [[IAJAK]], i64 [[IXJXK]]
308; CHECK-V8A-TWO-FOLD-4-NEXT:    [[WP2:%.*]] = add i64 [[WP]], [[WP]]
309; CHECK-V8A-TWO-FOLD-4-NEXT:    br label [[M]]
310; CHECK-V8A-TWO-FOLD-4:       M:
311; CHECK-V8A-TWO-FOLD-4-NEXT:    [[W:%.*]] = phi i64 [ [[WP2]], [[O]] ], [ 2, [[ENTRY:%.*]] ]
312; CHECK-V8A-TWO-FOLD-4-NEXT:    [[R:%.*]] = add i64 [[W]], 1
313; CHECK-V8A-TWO-FOLD-4-NEXT:    ret i64 [[R]]
314;
315; CHECK-V8M-TWO-FOLD-5-LABEL: @test_i64_minsize(
316; CHECK-V8M-TWO-FOLD-5-NEXT:  entry:
317; CHECK-V8M-TWO-FOLD-5-NEXT:    br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
318; CHECK-V8M-TWO-FOLD-5:       O:
319; CHECK-V8M-TWO-FOLD-5-NEXT:    br i1 [[B:%.*]], label [[P:%.*]], label [[Q:%.*]]
320; CHECK-V8M-TWO-FOLD-5:       P:
321; CHECK-V8M-TWO-FOLD-5-NEXT:    [[IAJ:%.*]] = add i64 [[I:%.*]], [[J:%.*]]
322; CHECK-V8M-TWO-FOLD-5-NEXT:    [[IAJAK:%.*]] = add i64 [[IAJ]], [[K:%.*]]
323; CHECK-V8M-TWO-FOLD-5-NEXT:    br label [[N:%.*]]
324; CHECK-V8M-TWO-FOLD-5:       Q:
325; CHECK-V8M-TWO-FOLD-5-NEXT:    [[IXJ:%.*]] = xor i64 [[I]], [[J]]
326; CHECK-V8M-TWO-FOLD-5-NEXT:    [[IXJXK:%.*]] = xor i64 [[IXJ]], [[K]]
327; CHECK-V8M-TWO-FOLD-5-NEXT:    br label [[N]]
328; CHECK-V8M-TWO-FOLD-5:       N:
329; CHECK-V8M-TWO-FOLD-5-NEXT:    [[WP:%.*]] = phi i64 [ [[IAJAK]], [[P]] ], [ [[IXJXK]], [[Q]] ]
330; CHECK-V8M-TWO-FOLD-5-NEXT:    [[WP2:%.*]] = add i64 [[WP]], [[WP]]
331; CHECK-V8M-TWO-FOLD-5-NEXT:    br label [[M]]
332; CHECK-V8M-TWO-FOLD-5:       M:
333; CHECK-V8M-TWO-FOLD-5-NEXT:    [[W:%.*]] = phi i64 [ [[WP2]], [[N]] ], [ 2, [[ENTRY:%.*]] ]
334; CHECK-V8M-TWO-FOLD-5-NEXT:    [[R:%.*]] = add i64 [[W]], 1
335; CHECK-V8M-TWO-FOLD-5-NEXT:    ret i64 [[R]]
336;
337; CHECK-V8A-TWO-FOLD-5-LABEL: @test_i64_minsize(
338; CHECK-V8A-TWO-FOLD-5-NEXT:  entry:
339; CHECK-V8A-TWO-FOLD-5-NEXT:    br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
340; CHECK-V8A-TWO-FOLD-5:       O:
341; CHECK-V8A-TWO-FOLD-5-NEXT:    [[IAJ:%.*]] = add i64 [[I:%.*]], [[J:%.*]]
342; CHECK-V8A-TWO-FOLD-5-NEXT:    [[IAJAK:%.*]] = add i64 [[IAJ]], [[K:%.*]]
343; CHECK-V8A-TWO-FOLD-5-NEXT:    [[IXJ:%.*]] = xor i64 [[I]], [[J]]
344; CHECK-V8A-TWO-FOLD-5-NEXT:    [[IXJXK:%.*]] = xor i64 [[IXJ]], [[K]]
345; CHECK-V8A-TWO-FOLD-5-NEXT:    [[WP:%.*]] = select i1 [[B:%.*]], i64 [[IAJAK]], i64 [[IXJXK]]
346; CHECK-V8A-TWO-FOLD-5-NEXT:    [[WP2:%.*]] = add i64 [[WP]], [[WP]]
347; CHECK-V8A-TWO-FOLD-5-NEXT:    br label [[M]]
348; CHECK-V8A-TWO-FOLD-5:       M:
349; CHECK-V8A-TWO-FOLD-5-NEXT:    [[W:%.*]] = phi i64 [ [[WP2]], [[O]] ], [ 2, [[ENTRY:%.*]] ]
350; CHECK-V8A-TWO-FOLD-5-NEXT:    [[R:%.*]] = add i64 [[W]], 1
351; CHECK-V8A-TWO-FOLD-5-NEXT:    ret i64 [[R]]
352;
353; CHECK-V8M-TWO-FOLD-6-LABEL: @test_i64_minsize(
354; CHECK-V8M-TWO-FOLD-6-NEXT:  entry:
355; CHECK-V8M-TWO-FOLD-6-NEXT:    br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
356; CHECK-V8M-TWO-FOLD-6:       O:
357; CHECK-V8M-TWO-FOLD-6-NEXT:    br i1 [[B:%.*]], label [[P:%.*]], label [[Q:%.*]]
358; CHECK-V8M-TWO-FOLD-6:       P:
359; CHECK-V8M-TWO-FOLD-6-NEXT:    [[IAJ:%.*]] = add i64 [[I:%.*]], [[J:%.*]]
360; CHECK-V8M-TWO-FOLD-6-NEXT:    [[IAJAK:%.*]] = add i64 [[IAJ]], [[K:%.*]]
361; CHECK-V8M-TWO-FOLD-6-NEXT:    br label [[N:%.*]]
362; CHECK-V8M-TWO-FOLD-6:       Q:
363; CHECK-V8M-TWO-FOLD-6-NEXT:    [[IXJ:%.*]] = xor i64 [[I]], [[J]]
364; CHECK-V8M-TWO-FOLD-6-NEXT:    [[IXJXK:%.*]] = xor i64 [[IXJ]], [[K]]
365; CHECK-V8M-TWO-FOLD-6-NEXT:    br label [[N]]
366; CHECK-V8M-TWO-FOLD-6:       N:
367; CHECK-V8M-TWO-FOLD-6-NEXT:    [[WP:%.*]] = phi i64 [ [[IAJAK]], [[P]] ], [ [[IXJXK]], [[Q]] ]
368; CHECK-V8M-TWO-FOLD-6-NEXT:    [[WP2:%.*]] = add i64 [[WP]], [[WP]]
369; CHECK-V8M-TWO-FOLD-6-NEXT:    br label [[M]]
370; CHECK-V8M-TWO-FOLD-6:       M:
371; CHECK-V8M-TWO-FOLD-6-NEXT:    [[W:%.*]] = phi i64 [ [[WP2]], [[N]] ], [ 2, [[ENTRY:%.*]] ]
372; CHECK-V8M-TWO-FOLD-6-NEXT:    [[R:%.*]] = add i64 [[W]], 1
373; CHECK-V8M-TWO-FOLD-6-NEXT:    ret i64 [[R]]
374;
375; CHECK-V8A-TWO-FOLD-6-LABEL: @test_i64_minsize(
376; CHECK-V8A-TWO-FOLD-6-NEXT:  entry:
377; CHECK-V8A-TWO-FOLD-6-NEXT:    [[IAJ:%.*]] = add i64 [[I:%.*]], [[J:%.*]]
378; CHECK-V8A-TWO-FOLD-6-NEXT:    [[IAJAK:%.*]] = add i64 [[IAJ]], [[K:%.*]]
379; CHECK-V8A-TWO-FOLD-6-NEXT:    [[IXJ:%.*]] = xor i64 [[I]], [[J]]
380; CHECK-V8A-TWO-FOLD-6-NEXT:    [[IXJXK:%.*]] = xor i64 [[IXJ]], [[K]]
381; CHECK-V8A-TWO-FOLD-6-NEXT:    [[WP:%.*]] = select i1 [[B:%.*]], i64 [[IAJAK]], i64 [[IXJXK]]
382; CHECK-V8A-TWO-FOLD-6-NEXT:    [[WP2:%.*]] = add i64 [[WP]], [[WP]]
383; CHECK-V8A-TWO-FOLD-6-NEXT:    [[W:%.*]] = select i1 [[A:%.*]], i64 2, i64 [[WP2]]
384; CHECK-V8A-TWO-FOLD-6-NEXT:    [[R:%.*]] = add i64 [[W]], 1
385; CHECK-V8A-TWO-FOLD-6-NEXT:    ret i64 [[R]]
386;
387entry:
388  br i1 %a, label %M, label %O
389O:
390  br i1 %b, label %P, label %Q
391P:
392  %iaj = add i64 %i, %j
393  %iajak = add i64 %iaj, %k
394  br label %N
395Q:
396  %ixj = xor i64 %i, %j
397  %ixjxk = xor i64 %ixj, %k
398  br label %N
399N:
400  %Wp = phi i64 [ %iajak, %P ], [ %ixjxk, %Q ]
401  %Wp2 = add i64 %Wp, %Wp
402  br label %M
403M:
404  %W = phi i64 [ %Wp2, %N ], [ 2, %entry ]
405  %R = add i64 %W, 1
406  ret i64 %R
407}
408
409attributes #0 = { minsize optsize }
410