forked from glycerine/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
edge.ll
60 lines (56 loc) · 1.08 KB
/
edge.ll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
; RUN: opt -gvn -S < %s | FileCheck %s
define i32 @f1(i32 %x) {
; CHECK: define i32 @f1(
bb0:
%cmp = icmp eq i32 %x, 0
br i1 %cmp, label %bb2, label %bb1
bb1:
br label %bb2
bb2:
%cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ]
%foo = add i32 %cond, %x
ret i32 %foo
; CHECK: bb2:
; CHECK: ret i32 %x
}
define i32 @f2(i32 %x) {
; CHECK: define i32 @f2(
bb0:
%cmp = icmp ne i32 %x, 0
br i1 %cmp, label %bb1, label %bb2
bb1:
br label %bb2
bb2:
%cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ]
%foo = add i32 %cond, %x
ret i32 %foo
; CHECK: bb2:
; CHECK: ret i32 %x
}
define i32 @f3(i32 %x) {
; CHECK: define i32 @f3(
bb0:
switch i32 %x, label %bb1 [ i32 0, label %bb2]
bb1:
br label %bb2
bb2:
%cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ]
%foo = add i32 %cond, %x
ret i32 %foo
; CHECK: bb2:
; CHECK: ret i32 %x
}
declare void @g(i1)
define void @f4(i8 * %x) {
; CHECK: define void @f4(
bb0:
%y = icmp eq i8* null, %x
br i1 %y, label %bb2, label %bb1
bb1:
br label %bb2
bb2:
%zed = icmp eq i8* null, %x
call void @g(i1 %zed)
; CHECK: call void @g(i1 %y)
ret void
}