Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(993)

Side by Side Diff: test/Transforms/NaCl/expand-constantexpr.ll

Issue 12792011: PNaCl: Add ExpandConstantExpr pass for converting ConstantExprs to Instructions (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 ; RUN: opt < %s -expand-constant-expr -S | FileCheck %s
2
3 @global_var1 = global i32 123
4 @global_var2 = global i32 123
5
6
7 define i8* @constantexpr_bitcast() {
8 ret i8* bitcast (i32* @global_var1 to i8*)
9 }
10 ; CHECK: @constantexpr_bitcast()
11 ; CHECK: %expanded = bitcast i32* @global_var1 to i8*
12 ; CHECK: ret i8* %expanded
13
14
15 define i32 @constantexpr_nested() {
16 ret i32 add (i32 ptrtoint (i32* @global_var1 to i32),
17 i32 ptrtoint (i32* @global_var2 to i32))
18 }
19 ; CHECK: @constantexpr_nested
20 ; CHECK: %expanded1 = ptrtoint i32* @global_var1 to i32
21 ; CHECK: %expanded2 = ptrtoint i32* @global_var2 to i32
22 ; CHECK: %expanded = add i32 %expanded1, %expanded2
23 ; CHECK: ret i32 %expanded
24
25
26 define i32 @constantexpr_phi() {
27 entry:
28 br label %label
29 label:
30 %result = phi i32 [ ptrtoint (i32* @global_var1 to i32), %entry ]
31 ret i32 %result
32 }
33 ; CHECK: @constantexpr_phi
34 ; CHECK: entry:
35 ; CHECK: %expanded = ptrtoint i32* @global_var1 to i32
36 ; CHECK: br label %label
37 ; CHECK: label:
38 ; CHECK: %result = phi i32 [ %expanded, %entry ]
39
40
41 ; This tests that ExpandConstantExpr correctly handles a PHI node that
42 ; contains the same ConstantExpr twice.
43 ; Using replaceAllUsesWith() is not correct on a PHI node when the
44 ; new instruction has to be added to an incoming block.
45 define i32 @constantexpr_phi_twice(i1 %arg) {
46 entry:
47 br i1 %arg, label %iftrue, label %iffalse
48 iftrue:
49 br label %exit
50 iffalse:
51 br label %exit
52 exit:
53 %result = phi i32 [ ptrtoint (i32* @global_var1 to i32), %iftrue ],
54 [ ptrtoint (i32* @global_var1 to i32), %iffalse ]
55 ret i32 %result
56 }
57 ; CHECK: @constantexpr_phi_twice
58 ; CHECK: iftrue:
59 ; CHECK: %expanded = ptrtoint i32* @global_var1 to i32
60 ; CHECK: iffalse:
61 ; CHECK: %expanded1 = ptrtoint i32* @global_var1 to i32
62 ; CHECK: exit:
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698