1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -loop-unroll -unroll-peel-count=2 -S %s | FileCheck --check-prefix=PEEL2 %s
3; RUN: opt -loop-unroll -unroll-peel-count=8 -S %s | FileCheck --check-prefix=PEEL8 %s
4; RUN: opt -loop-unroll -unroll-peel-count=2 -unroll-count=2 -S %s | FileCheck --check-prefix=PEEL2UNROLL2 %s
5
6; Test case for PR45939. Make sure unroll count is adjusted when loop is peeled and unrolled.
7
8@a = global [8 x i32] zeroinitializer, align 16
9
10define void @test1() {
11; PEEL2-LABEL: @test1(
12; PEEL2-NEXT:  entry:
13; PEEL2-NEXT:    br label [[FOR_BODY_PEEL_BEGIN:%.*]]
14; PEEL2:       for.body.peel.begin:
15; PEEL2-NEXT:    br label [[FOR_BODY_PEEL:%.*]]
16; PEEL2:       for.body.peel:
17; PEEL2-NEXT:    [[ARRAYIDX_PEEL:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 0
18; PEEL2-NEXT:    [[TMP0:%.*]] = trunc i64 0 to i32
19; PEEL2-NEXT:    store i32 [[TMP0]], i32* [[ARRAYIDX_PEEL]], align 4
20; PEEL2-NEXT:    [[INDVARS_IV_NEXT_PEEL:%.*]] = add nuw nsw i64 0, 1
21; PEEL2-NEXT:    [[EXITCOND_PEEL:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT_PEEL]], 8
22; PEEL2-NEXT:    br i1 [[EXITCOND_PEEL]], label [[FOR_BODY_PEEL_NEXT:%.*]], label [[FOR_EXIT:%.*]]
23; PEEL2:       for.body.peel.next:
24; PEEL2-NEXT:    br label [[FOR_BODY_PEEL2:%.*]]
25; PEEL2:       for.body.peel2:
26; PEEL2-NEXT:    [[ARRAYIDX_PEEL3:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_PEEL]]
27; PEEL2-NEXT:    [[TMP1:%.*]] = trunc i64 [[INDVARS_IV_NEXT_PEEL]] to i32
28; PEEL2-NEXT:    store i32 [[TMP1]], i32* [[ARRAYIDX_PEEL3]], align 4
29; PEEL2-NEXT:    [[INDVARS_IV_NEXT_PEEL4:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_PEEL]], 1
30; PEEL2-NEXT:    [[EXITCOND_PEEL5:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT_PEEL4]], 8
31; PEEL2-NEXT:    br i1 [[EXITCOND_PEEL5]], label [[FOR_BODY_PEEL_NEXT1:%.*]], label [[FOR_EXIT]]
32; PEEL2:       for.body.peel.next1:
33; PEEL2-NEXT:    br label [[FOR_BODY_PEEL_NEXT6:%.*]]
34; PEEL2:       for.body.peel.next6:
35; PEEL2-NEXT:    br label [[ENTRY_PEEL_NEWPH:%.*]]
36; PEEL2:       entry.peel.newph:
37; PEEL2-NEXT:    br label [[FOR_BODY:%.*]]
38; PEEL2:       for.body:
39; PEEL2-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_PEEL4]]
40; PEEL2-NEXT:    [[TMP2:%.*]] = trunc i64 [[INDVARS_IV_NEXT_PEEL4]] to i32
41; PEEL2-NEXT:    store i32 [[TMP2]], i32* [[ARRAYIDX]], align 4
42; PEEL2-NEXT:    store i32 3, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @a, i64 0, i64 3), align 4
43; PEEL2-NEXT:    store i32 4, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @a, i64 0, i64 4), align 4
44; PEEL2-NEXT:    store i32 5, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @a, i64 0, i64 5), align 4
45; PEEL2-NEXT:    store i32 6, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @a, i64 0, i64 6), align 4
46; PEEL2-NEXT:    store i32 7, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @a, i64 0, i64 7), align 4
47; PEEL2-NEXT:    store i32 8, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @a, i64 1, i64 0), align 4
48; PEEL2-NEXT:    store i32 9, i32* getelementptr ([8 x i32], [8 x i32]* @a, i64 1, i64 1), align 4
49; PEEL2-NEXT:    br label [[FOR_EXIT]]
50; PEEL2:       for.exit:
51; PEEL2-NEXT:    ret void
52;
53; PEEL8-LABEL: @test1(
54; PEEL8-NEXT:  entry:
55; PEEL8-NEXT:    br label [[FOR_BODY_PEEL_BEGIN:%.*]]
56; PEEL8:       for.body.peel.begin:
57; PEEL8-NEXT:    br label [[FOR_BODY_PEEL:%.*]]
58; PEEL8:       for.body.peel:
59; PEEL8-NEXT:    [[ARRAYIDX_PEEL:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 0
60; PEEL8-NEXT:    [[TMP0:%.*]] = trunc i64 0 to i32
61; PEEL8-NEXT:    store i32 [[TMP0]], i32* [[ARRAYIDX_PEEL]], align 4
62; PEEL8-NEXT:    [[INDVARS_IV_NEXT_PEEL:%.*]] = add nuw nsw i64 0, 1
63; PEEL8-NEXT:    [[EXITCOND_PEEL:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT_PEEL]], 8
64; PEEL8-NEXT:    br i1 [[EXITCOND_PEEL]], label [[FOR_BODY_PEEL_NEXT:%.*]], label [[FOR_EXIT:%.*]]
65; PEEL8:       for.body.peel.next:
66; PEEL8-NEXT:    br label [[FOR_BODY_PEEL2:%.*]]
67; PEEL8:       for.body.peel2:
68; PEEL8-NEXT:    [[ARRAYIDX_PEEL3:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_PEEL]]
69; PEEL8-NEXT:    [[TMP1:%.*]] = trunc i64 [[INDVARS_IV_NEXT_PEEL]] to i32
70; PEEL8-NEXT:    store i32 [[TMP1]], i32* [[ARRAYIDX_PEEL3]], align 4
71; PEEL8-NEXT:    [[INDVARS_IV_NEXT_PEEL4:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_PEEL]], 1
72; PEEL8-NEXT:    [[EXITCOND_PEEL5:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT_PEEL4]], 8
73; PEEL8-NEXT:    br i1 [[EXITCOND_PEEL5]], label [[FOR_BODY_PEEL_NEXT1:%.*]], label [[FOR_EXIT]]
74; PEEL8:       for.body.peel.next1:
75; PEEL8-NEXT:    br label [[FOR_BODY_PEEL7:%.*]]
76; PEEL8:       for.body.peel7:
77; PEEL8-NEXT:    [[ARRAYIDX_PEEL8:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_PEEL4]]
78; PEEL8-NEXT:    [[TMP2:%.*]] = trunc i64 [[INDVARS_IV_NEXT_PEEL4]] to i32
79; PEEL8-NEXT:    store i32 [[TMP2]], i32* [[ARRAYIDX_PEEL8]], align 4
80; PEEL8-NEXT:    [[INDVARS_IV_NEXT_PEEL9:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_PEEL4]], 1
81; PEEL8-NEXT:    [[EXITCOND_PEEL10:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT_PEEL9]], 8
82; PEEL8-NEXT:    br i1 [[EXITCOND_PEEL10]], label [[FOR_BODY_PEEL_NEXT6:%.*]], label [[FOR_EXIT]]
83; PEEL8:       for.body.peel.next6:
84; PEEL8-NEXT:    br label [[FOR_BODY_PEEL12:%.*]]
85; PEEL8:       for.body.peel12:
86; PEEL8-NEXT:    [[ARRAYIDX_PEEL13:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_PEEL9]]
87; PEEL8-NEXT:    [[TMP3:%.*]] = trunc i64 [[INDVARS_IV_NEXT_PEEL9]] to i32
88; PEEL8-NEXT:    store i32 [[TMP3]], i32* [[ARRAYIDX_PEEL13]], align 4
89; PEEL8-NEXT:    [[INDVARS_IV_NEXT_PEEL14:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_PEEL9]], 1
90; PEEL8-NEXT:    [[EXITCOND_PEEL15:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT_PEEL14]], 8
91; PEEL8-NEXT:    br i1 [[EXITCOND_PEEL15]], label [[FOR_BODY_PEEL_NEXT11:%.*]], label [[FOR_EXIT]]
92; PEEL8:       for.body.peel.next11:
93; PEEL8-NEXT:    br label [[FOR_BODY_PEEL17:%.*]]
94; PEEL8:       for.body.peel17:
95; PEEL8-NEXT:    [[ARRAYIDX_PEEL18:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_PEEL14]]
96; PEEL8-NEXT:    [[TMP4:%.*]] = trunc i64 [[INDVARS_IV_NEXT_PEEL14]] to i32
97; PEEL8-NEXT:    store i32 [[TMP4]], i32* [[ARRAYIDX_PEEL18]], align 4
98; PEEL8-NEXT:    [[INDVARS_IV_NEXT_PEEL19:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_PEEL14]], 1
99; PEEL8-NEXT:    [[EXITCOND_PEEL20:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT_PEEL19]], 8
100; PEEL8-NEXT:    br i1 [[EXITCOND_PEEL20]], label [[FOR_BODY_PEEL_NEXT16:%.*]], label [[FOR_EXIT]]
101; PEEL8:       for.body.peel.next16:
102; PEEL8-NEXT:    br label [[FOR_BODY_PEEL22:%.*]]
103; PEEL8:       for.body.peel22:
104; PEEL8-NEXT:    [[ARRAYIDX_PEEL23:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_PEEL19]]
105; PEEL8-NEXT:    [[TMP5:%.*]] = trunc i64 [[INDVARS_IV_NEXT_PEEL19]] to i32
106; PEEL8-NEXT:    store i32 [[TMP5]], i32* [[ARRAYIDX_PEEL23]], align 4
107; PEEL8-NEXT:    [[INDVARS_IV_NEXT_PEEL24:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_PEEL19]], 1
108; PEEL8-NEXT:    [[EXITCOND_PEEL25:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT_PEEL24]], 8
109; PEEL8-NEXT:    br i1 [[EXITCOND_PEEL25]], label [[FOR_BODY_PEEL_NEXT21:%.*]], label [[FOR_EXIT]]
110; PEEL8:       for.body.peel.next21:
111; PEEL8-NEXT:    br label [[FOR_BODY_PEEL27:%.*]]
112; PEEL8:       for.body.peel27:
113; PEEL8-NEXT:    [[ARRAYIDX_PEEL28:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_PEEL24]]
114; PEEL8-NEXT:    [[TMP6:%.*]] = trunc i64 [[INDVARS_IV_NEXT_PEEL24]] to i32
115; PEEL8-NEXT:    store i32 [[TMP6]], i32* [[ARRAYIDX_PEEL28]], align 4
116; PEEL8-NEXT:    [[INDVARS_IV_NEXT_PEEL29:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_PEEL24]], 1
117; PEEL8-NEXT:    [[EXITCOND_PEEL30:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT_PEEL29]], 8
118; PEEL8-NEXT:    br i1 [[EXITCOND_PEEL30]], label [[FOR_BODY_PEEL_NEXT26:%.*]], label [[FOR_EXIT]]
119; PEEL8:       for.body.peel.next26:
120; PEEL8-NEXT:    br label [[FOR_BODY_PEEL32:%.*]]
121; PEEL8:       for.body.peel32:
122; PEEL8-NEXT:    [[ARRAYIDX_PEEL33:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_PEEL29]]
123; PEEL8-NEXT:    [[TMP7:%.*]] = trunc i64 [[INDVARS_IV_NEXT_PEEL29]] to i32
124; PEEL8-NEXT:    store i32 [[TMP7]], i32* [[ARRAYIDX_PEEL33]], align 4
125; PEEL8-NEXT:    [[INDVARS_IV_NEXT_PEEL34:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_PEEL29]], 1
126; PEEL8-NEXT:    [[EXITCOND_PEEL35:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT_PEEL34]], 8
127; PEEL8-NEXT:    br i1 [[EXITCOND_PEEL35]], label [[FOR_BODY_PEEL_NEXT31:%.*]], label [[FOR_EXIT]]
128; PEEL8:       for.body.peel.next31:
129; PEEL8-NEXT:    br label [[FOR_BODY_PEEL_NEXT36:%.*]]
130; PEEL8:       for.body.peel.next36:
131; PEEL8-NEXT:    br label [[ENTRY_PEEL_NEWPH:%.*]]
132; PEEL8:       entry.peel.newph:
133; PEEL8-NEXT:    br label [[FOR_BODY:%.*]]
134; PEEL8:       for.body:
135; PEEL8-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_PEEL34]]
136; PEEL8-NEXT:    [[TMP8:%.*]] = trunc i64 [[INDVARS_IV_NEXT_PEEL34]] to i32
137; PEEL8-NEXT:    store i32 [[TMP8]], i32* [[ARRAYIDX]], align 4
138; PEEL8-NEXT:    [[INDVARS_IV_NEXT:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_PEEL34]], 1
139; PEEL8-NEXT:    [[ARRAYIDX_1:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT]]
140; PEEL8-NEXT:    [[TMP9:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
141; PEEL8-NEXT:    store i32 [[TMP9]], i32* [[ARRAYIDX_1]], align 4
142; PEEL8-NEXT:    [[INDVARS_IV_NEXT_1:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT]], 1
143; PEEL8-NEXT:    [[ARRAYIDX_2:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_1]]
144; PEEL8-NEXT:    [[TMP10:%.*]] = trunc i64 [[INDVARS_IV_NEXT_1]] to i32
145; PEEL8-NEXT:    store i32 [[TMP10]], i32* [[ARRAYIDX_2]], align 4
146; PEEL8-NEXT:    [[INDVARS_IV_NEXT_2:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_1]], 1
147; PEEL8-NEXT:    [[ARRAYIDX_3:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_2]]
148; PEEL8-NEXT:    [[TMP11:%.*]] = trunc i64 [[INDVARS_IV_NEXT_2]] to i32
149; PEEL8-NEXT:    store i32 [[TMP11]], i32* [[ARRAYIDX_3]], align 4
150; PEEL8-NEXT:    [[INDVARS_IV_NEXT_3:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_2]], 1
151; PEEL8-NEXT:    [[ARRAYIDX_4:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_3]]
152; PEEL8-NEXT:    [[TMP12:%.*]] = trunc i64 [[INDVARS_IV_NEXT_3]] to i32
153; PEEL8-NEXT:    store i32 [[TMP12]], i32* [[ARRAYIDX_4]], align 4
154; PEEL8-NEXT:    [[INDVARS_IV_NEXT_4:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_3]], 1
155; PEEL8-NEXT:    [[ARRAYIDX_5:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_4]]
156; PEEL8-NEXT:    [[TMP13:%.*]] = trunc i64 [[INDVARS_IV_NEXT_4]] to i32
157; PEEL8-NEXT:    store i32 [[TMP13]], i32* [[ARRAYIDX_5]], align 4
158; PEEL8-NEXT:    [[INDVARS_IV_NEXT_5:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_4]], 1
159; PEEL8-NEXT:    [[ARRAYIDX_6:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_5]]
160; PEEL8-NEXT:    [[TMP14:%.*]] = trunc i64 [[INDVARS_IV_NEXT_5]] to i32
161; PEEL8-NEXT:    store i32 [[TMP14]], i32* [[ARRAYIDX_6]], align 4
162; PEEL8-NEXT:    [[INDVARS_IV_NEXT_6:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_5]], 1
163; PEEL8-NEXT:    [[ARRAYIDX_7:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_6]]
164; PEEL8-NEXT:    [[TMP15:%.*]] = trunc i64 [[INDVARS_IV_NEXT_6]] to i32
165; PEEL8-NEXT:    store i32 [[TMP15]], i32* [[ARRAYIDX_7]], align 4
166; PEEL8-NEXT:    [[INDVARS_IV_NEXT_7:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_6]], 1
167; PEEL8-NEXT:    br label [[FOR_EXIT]]
168; PEEL8:       for.exit:
169; PEEL8-NEXT:    ret void
170;
171; PEEL2UNROLL2-LABEL: @test1(
172; PEEL2UNROLL2-NEXT:  entry:
173; PEEL2UNROLL2-NEXT:    br label [[FOR_BODY_PEEL_BEGIN:%.*]]
174; PEEL2UNROLL2:       for.body.peel.begin:
175; PEEL2UNROLL2-NEXT:    br label [[FOR_BODY_PEEL:%.*]]
176; PEEL2UNROLL2:       for.body.peel:
177; PEEL2UNROLL2-NEXT:    [[ARRAYIDX_PEEL:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 0
178; PEEL2UNROLL2-NEXT:    [[TMP0:%.*]] = trunc i64 0 to i32
179; PEEL2UNROLL2-NEXT:    store i32 [[TMP0]], i32* [[ARRAYIDX_PEEL]], align 4
180; PEEL2UNROLL2-NEXT:    [[INDVARS_IV_NEXT_PEEL:%.*]] = add nuw nsw i64 0, 1
181; PEEL2UNROLL2-NEXT:    [[EXITCOND_PEEL:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT_PEEL]], 8
182; PEEL2UNROLL2-NEXT:    br i1 [[EXITCOND_PEEL]], label [[FOR_BODY_PEEL_NEXT:%.*]], label [[FOR_EXIT:%.*]]
183; PEEL2UNROLL2:       for.body.peel.next:
184; PEEL2UNROLL2-NEXT:    br label [[FOR_BODY_PEEL2:%.*]]
185; PEEL2UNROLL2:       for.body.peel2:
186; PEEL2UNROLL2-NEXT:    [[ARRAYIDX_PEEL3:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT_PEEL]]
187; PEEL2UNROLL2-NEXT:    [[TMP1:%.*]] = trunc i64 [[INDVARS_IV_NEXT_PEEL]] to i32
188; PEEL2UNROLL2-NEXT:    store i32 [[TMP1]], i32* [[ARRAYIDX_PEEL3]], align 4
189; PEEL2UNROLL2-NEXT:    [[INDVARS_IV_NEXT_PEEL4:%.*]] = add nuw nsw i64 [[INDVARS_IV_NEXT_PEEL]], 1
190; PEEL2UNROLL2-NEXT:    [[EXITCOND_PEEL5:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT_PEEL4]], 8
191; PEEL2UNROLL2-NEXT:    br i1 [[EXITCOND_PEEL5]], label [[FOR_BODY_PEEL_NEXT1:%.*]], label [[FOR_EXIT]]
192; PEEL2UNROLL2:       for.body.peel.next1:
193; PEEL2UNROLL2-NEXT:    br label [[FOR_BODY_PEEL_NEXT6:%.*]]
194; PEEL2UNROLL2:       for.body.peel.next6:
195; PEEL2UNROLL2-NEXT:    br label [[ENTRY_PEEL_NEWPH:%.*]]
196; PEEL2UNROLL2:       entry.peel.newph:
197; PEEL2UNROLL2-NEXT:    br label [[FOR_BODY:%.*]]
198; PEEL2UNROLL2:       for.body:
199; PEEL2UNROLL2-NEXT:    [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT_PEEL4]], [[ENTRY_PEEL_NEWPH]] ], [ [[INDVARS_IV_NEXT_1:%.*]], [[FOR_BODY]] ]
200; PEEL2UNROLL2-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV]]
201; PEEL2UNROLL2-NEXT:    [[TMP2:%.*]] = trunc i64 [[INDVARS_IV]] to i32
202; PEEL2UNROLL2-NEXT:    store i32 [[TMP2]], i32* [[ARRAYIDX]], align 4
203; PEEL2UNROLL2-NEXT:    [[INDVARS_IV_NEXT:%.*]] = add nuw nsw i64 [[INDVARS_IV]], 1
204; PEEL2UNROLL2-NEXT:    [[ARRAYIDX_1:%.*]] = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 [[INDVARS_IV_NEXT]]
205; PEEL2UNROLL2-NEXT:    [[TMP3:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
206; PEEL2UNROLL2-NEXT:    store i32 [[TMP3]], i32* [[ARRAYIDX_1]], align 4
207; PEEL2UNROLL2-NEXT:    [[INDVARS_IV_NEXT_1]] = add nuw nsw i64 [[INDVARS_IV_NEXT]], 1
208; PEEL2UNROLL2-NEXT:    [[EXITCOND_1:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT_1]], 8
209; PEEL2UNROLL2-NEXT:    br i1 [[EXITCOND_1]], label [[FOR_BODY]], label [[FOR_EXIT_LOOPEXIT:%.*]], !llvm.loop !0
210; PEEL2UNROLL2:       for.exit.loopexit:
211; PEEL2UNROLL2-NEXT:    br label [[FOR_EXIT]]
212; PEEL2UNROLL2:       for.exit:
213; PEEL2UNROLL2-NEXT:    ret void
214;
215entry:
216  br label %for.body
217
218for.body:                                         ; preds = %entry, %for.body
219  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
220  %arrayidx = getelementptr inbounds [8 x i32], [8 x i32]* @a, i64 0, i64 %indvars.iv
221  %0 = trunc i64 %indvars.iv to i32
222  store i32 %0, i32* %arrayidx, align 4
223  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
224  %exitcond = icmp ne i64 %indvars.iv.next, 8
225  br i1 %exitcond, label %for.body, label %for.exit
226
227for.exit:                        ; preds = %for.body
228  ret void
229}
230