aboutsummaryrefslogtreecommitdiff
path: root/test/Transforms/SimplifyCFG/branch-phi-thread.ll
blob: 3b8d1885443656b5899a05893589b6cc2eeab77f (plain)
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
61
62
63
; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -adce | llvm-dis | not grep 'call void %f1' &&
; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg -adce -disable-output
declare void %f1()
declare void %f2()
declare void %f3()
declare void %f4()

implementation

int %test1(int %X, bool %D) {
E:
	%C = seteq int %X, 0
	br bool %C, label %T, label %F
T:
	br bool %C, label %B, label %A
A:
	call void %f1()
	br bool %D, label %T, label %F
B:
	call void %f2()
	ret int 345
F:
	call void %f3()
	ret int 123
}

int %test2(int %X, bool %D) {
E:
	%C = seteq int %X, 0
	br bool %C, label %T, label %F
T:
	%P = phi bool [true, %E], [%C, %A]
	br bool %P, label %B, label %A
A:
	call void %f1()
	br bool %D, label %T, label %F
B:
	call void %f2()
	ret int 345
F:
	call void %f3()
	ret int 123
}

int %test3(int %X, bool %D, int* %AP, int* %BP) {
E:
	%C = seteq int %X, 0
	br bool %C, label %T, label %F
T:
	call void %f3()  ;; Inst in block.
	%XX = load int* %AP
	store int %XX, int* %BP
	br bool %C, label %B, label %A
A:
	call void %f1()
	br bool %D, label %T, label %F
B:
	call void %f2()
	ret int 345
F:
	call void %f3()
	ret int 123
}