1 ; RUN: opt -S -loop-unroll -unroll-force-peel-count=1 -verify-dom-info <%s
3 ; Check if loop composed of several BBs is peeled correctly.
6 @Comma = external global i8
7 define void @funca(i8* readnone %b, i8* readnone %e) {
9 %cmp2 = icmp eq i8* %b, %e
10 br i1 %cmp2, label %for.end, label %for.body.preheader
16 %b.addr.03 = phi i8* [ %incdec.ptr, %for.inc ], [ %b, %for.body.preheader ]
17 %0 = load i8, i8* @Comma
18 %tobool = icmp eq i8 %0, 0
19 br i1 %tobool, label %for.inc, label %if.then
22 tail call void @funcb()
23 store i8 1, i8* @Comma
27 %incdec.ptr = getelementptr inbounds i8, i8* %b.addr.03, i64 1
28 %cmp = icmp eq i8* %incdec.ptr, %e
29 br i1 %cmp, label %for.end, label %for.body
38 ; CHECK: %[[REG1:[0-9]+]] = load i8, i8* @Comma
39 ; CHECK: %[[REG2:.*]] = icmp eq i8 %[[REG1]], 0
40 ; CHECK: br i1 %[[REG2]], label %{{.*}}, label %[[IFTHEN:.*]]
42 ; CHECK: call void @funcb()
43 ; CHECK: store i8 1, i8* @Comma
44 ; CHECK: br label %[[FORINC]]
46 ; CHECK: %[[REG3:.*]] = getelementptr inbounds i8, i8* %b, i64 1
47 ; CHECK: %[[REG4:.*]] = icmp eq i8* %[[REG3]], %e
48 ; CHECK: br i1 %[[REG4]]
51 ; CHECK: %[[REG1b:.*]] = load i8, i8* @Comma
52 ; CHECK: %[[REG2b:.*]] = icmp eq i8 %[[REG1b]], 0
53 ; CHECK: br i1 %[[REG2b]], label %{{.*}}, label %[[IFTHENb:.*]]
55 ; CHECK: call void @funcb()
56 ; CHECK: store i8 1, i8* @Comma
57 ; CHECK: br label %[[FORINCb]]
59 ; CHECK: %[[REG3b:.*]] = getelementptr inbounds i8, i8* %b, i64 1
60 ; CHECK: %[[REG4b:.*]] = icmp eq i8* %[[REG3b]], %e
61 ; CHECK: br i1 %[[REG4b]]