blob: 36af1ffa8badd012efd7f9c6e40f1e9e7c81a1e0 [file] [log] [blame]
Chuang-Yu Chengf0eba832016-04-05 14:21:32 +00001; RUN: opt -codegenprepare -S < %s | FileCheck %s
2; CHECK: for.body.preheader
3
4@N = common global i32 0, align 4
5@E = common global i8** null, align 8
6@B = common global i8** null, align 8
7
8; Function Attrs: nounwind
9define i32 @foo() {
10entry:
11 %0 = load i32, i32* @N, align 4
12 %1 = load i8**, i8*** @E, align 8
13 %2 = load i8**, i8*** @B, align 8
14 %cmp7 = icmp eq i8** %2, %1
15 br i1 %cmp7, label %for.cond.cleanup, label %for.body.preheader
16
17for.body.preheader: ; preds = %entry
18 br label %for.body
19
20for.cond.cleanup.loopexit: ; preds = %for.body
21 %add.lcssa = phi i32 [ %add, %for.body ]
22 br label %for.cond.cleanup
23
24for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
25 %n.0.lcssa = phi i32 [ %0, %entry ], [ %add.lcssa, %for.cond.cleanup.loopexit ]
26 ret i32 %n.0.lcssa
27
28for.body: ; preds = %for.body.preheader, %for.body
29 %I.09 = phi i8** [ %incdec.ptr, %for.body ], [ %2, %for.body.preheader ]
30 %n.08 = phi i32 [ %add, %for.body ], [ %0, %for.body.preheader ]
31 %3 = load i8*, i8** %I.09, align 8
32 %call = tail call i32 @map(i8* %3)
33 %add = add nsw i32 %call, %n.08
34 %incdec.ptr = getelementptr inbounds i8*, i8** %I.09, i64 1
35 %cmp = icmp eq i8** %incdec.ptr, %1
36 br i1 %cmp, label %for.cond.cleanup.loopexit, label %for.body
37}
38
39declare i32 @map(i8*)