• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -loop-unroll -unroll-force-peel-count=1 -verify-dom-info <%s
2
3; Check if loop composed of several BBs is peeled correctly.
4
5declare void @funcb()
6@Comma = external global i8
7define void @funca(i8* readnone %b, i8* readnone %e) {
8entry:
9  %cmp2 = icmp eq i8* %b, %e
10  br i1 %cmp2, label %for.end, label %for.body.preheader
11
12for.body.preheader:
13  br label %for.body
14
15for.body:
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
20
21if.then:
22  tail call void @funcb()
23  store i8 1, i8* @Comma
24  br label %for.inc
25
26for.inc:
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
30
31for.end:
32  ret void
33}
34
35; CHECK_LABEL: @funca
36
37; Peeled iteration
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:.*]]
41; CHECK: [[IFTHEN]]:
42; CHECK: call void @funcb()
43; CHECK: store i8 1, i8* @Comma
44; CHECK: br label %[[FORINC]]
45; CHECK: [[FORINC]]:
46; CHECK: %[[REG3:.*]] = getelementptr inbounds i8, i8* %b, i64 1
47; CHECK: %[[REG4:.*]] = icmp eq i8* %[[REG3]], %e
48; CHECK: br i1 %[[REG4]]
49
50; main body
51; CHECK: %[[REG1b:.*]] = load i8, i8* @Comma
52; CHECK: %[[REG2b:.*]] = icmp eq i8 %[[REG1b]], 0
53; CHECK: br i1 %[[REG2b]], label %{{.*}}, label %[[IFTHENb:.*]]
54; CHECK: [[IFTHENb]]:
55; CHECK: call void @funcb()
56; CHECK: store i8 1, i8* @Comma
57; CHECK: br label %[[FORINCb]]
58; CHECK: [[FORINCb]]:
59; CHECK: %[[REG3b:.*]] = getelementptr inbounds i8, i8* %b, i64 1
60; CHECK: %[[REG4b:.*]] = icmp eq i8* %[[REG3b]], %e
61; CHECK: br i1 %[[REG4b]]
62