llvm-project
39 строк · 1.3 Кб
1; RUN: opt < %s -passes=licm -S | FileCheck %s
2@b = external global i32, align 4
3@fn3.i = external global i32, align 4
4
5declare i32 @g() nounwind
6
7define i32 @f() {
8entry:
9br label %for.cond
10
11for.cond: ; preds = %for.end, %entry
12; CHECK-LABEL: for.cond:
13; CHECK: store i32 0, ptr @b
14store i32 0, ptr @b, align 4
15br i1 true, label %for.body.preheader, label %for.end
16
17for.body.preheader: ; preds = %for.cond
18br label %for.body
19
20for.body: ; preds = %for.body, %for.body.preheader
21%g.15 = phi i32 [ undef, %for.body ], [ 0, %for.body.preheader ]
22%0 = load i32, ptr @fn3.i, align 4
23%call = call i32 @g()
24br i1 false, label %for.body, label %for.end.loopexit
25
26for.end.loopexit: ; preds = %for.body
27br label %for.end
28
29for.end: ; preds = %for.end.loopexit, %for.cond
30%whatever = phi i32 [ %call, %for.end.loopexit ], [ undef, %for.cond ]
31br i1 false, label %for.cond, label %if.then
32
33if.then: ; preds = %for.end
34; CHECK-LABEL: if.then:
35; CHECK: phi i32 [ {{.*}}, %for.end ]
36; CHECK-NOT: store i32 0, ptr @b
37; CHECK: ret i32
38ret i32 %whatever
39}
40