Mercurial > hg > CbC > CbC_llvm
comparison test/Transforms/SimplifyCFG/multiple-phis.ll @ 0:95c75e76d11b LLVM3.4
LLVM 3.4
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 12 Dec 2013 13:56:28 +0900 |
parents | |
children | afa8332a0e37 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:95c75e76d11b |
---|---|
1 ; RUN: opt -simplifycfg -S < %s | FileCheck %s | |
2 | |
3 ; It's not worthwhile to if-convert one of the phi nodes and leave | |
4 ; the other behind, because that still requires a branch. If | |
5 ; SimplifyCFG if-converts one of the phis, it should do both. | |
6 | |
7 ; CHECK: %div.high.addr.0 = select i1 %cmp1, i32 %div, i32 %high.addr.0 | |
8 ; CHECK-NEXT: %low.0.add2 = select i1 %cmp1, i32 %low.0, i32 %add2 | |
9 ; CHECK-NEXT: br label %while.cond | |
10 | |
11 define i32 @upper_bound(i32* %r, i32 %high, i32 %k) nounwind { | |
12 entry: | |
13 br label %while.cond | |
14 | |
15 while.cond: ; preds = %if.then, %if.else, %entry | |
16 %high.addr.0 = phi i32 [ %high, %entry ], [ %div, %if.then ], [ %high.addr.0, %if.else ] | |
17 %low.0 = phi i32 [ 0, %entry ], [ %low.0, %if.then ], [ %add2, %if.else ] | |
18 %cmp = icmp ult i32 %low.0, %high.addr.0 | |
19 br i1 %cmp, label %while.body, label %while.end | |
20 | |
21 while.body: ; preds = %while.cond | |
22 %add = add i32 %low.0, %high.addr.0 | |
23 %div = udiv i32 %add, 2 | |
24 %idxprom = zext i32 %div to i64 | |
25 %arrayidx = getelementptr inbounds i32* %r, i64 %idxprom | |
26 %0 = load i32* %arrayidx | |
27 %cmp1 = icmp ult i32 %k, %0 | |
28 br i1 %cmp1, label %if.then, label %if.else | |
29 | |
30 if.then: ; preds = %while.body | |
31 br label %while.cond | |
32 | |
33 if.else: ; preds = %while.body | |
34 %add2 = add i32 %div, 1 | |
35 br label %while.cond | |
36 | |
37 while.end: ; preds = %while.cond | |
38 ret i32 %low.0 | |
39 } |