File: PhiEliminate.ll

package info (click to toggle)
llvm 2.2-12
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 38,648 kB
  • ctags: 28,258
  • sloc: cpp: 215,479; sh: 12,132; ansic: 10,002; yacc: 5,525; perl: 2,352; ml: 1,580; makefile: 956; pascal: 718; lex: 602; exp: 320; ada: 193; lisp: 160; csh: 116; objc: 59; python: 59; tcl: 20
file content (38 lines) | stat: -rw-r--r-- 956 bytes parent folder | download
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
; Test a bunch of cases where the cfg simplification code should
; be able to fold PHI nodes into computation in common cases.  Folding the PHI
; nodes away allows the branches to be eliminated, performing a simple form of
; 'if conversion'.

; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis > %t.xform
; RUN:   not grep phi %t.xform 
; RUN:   grep ret %t.xform

declare void %use(bool)
declare void %use(int)


void %test2(bool %c, bool %d, int %V, int %V2) {
	br bool %d, label %X, label %F
X:
	br bool %c, label %T, label %F
T:
	br label %F
F:
	%B1 = phi bool [true, %0], [false, %T], [false, %X]
	%I7 = phi int  [%V, %0], [%V2, %T], [%V2, %X]
	call void %use(bool %B1)
	call void %use(int  %I7)
	ret void
}

void %test(bool %c, int %V, int %V2) {
	br bool %c, label %T, label %F
T:
	br label %F
F:
	%B1 = phi bool [true, %0], [false, %T]
	%I6 = phi int  [%V, %0], [0, %T]
	call void %use(bool %B1)
	call void %use(int  %I6)
	ret void
}