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

Side by Side Diff: test/NaCl/Bitcode/bitcast-elide.ll

Issue 1151093004: Changes from 3.7 merge to files not in upstream (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Created 5 years, 7 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
1 ; Test how we handle eliding (pointer) bitcast instructions. 1 ; Test how we handle eliding (pointer) bitcast instructions.
2 2
3 ; RUN: llvm-as < %s | pnacl-freeze \ 3 ; RUN: llvm-as < %s | pnacl-freeze \
4 ; RUN: | pnacl-bcanalyzer -dump-records \ 4 ; RUN: | pnacl-bcanalyzer -dump-records \
5 ; RUN: | FileCheck %s -check-prefix=PF2 5 ; RUN: | FileCheck %s -check-prefix=PF2
6 6
7 ; RUN: llvm-as < %s | pnacl-freeze -allow-local-symbol-tables \ 7 ; RUN: llvm-as < %s | pnacl-freeze -allow-local-symbol-tables \
8 ; RUN: | pnacl-thaw -allow-local-symbol-tables \ 8 ; RUN: | pnacl-thaw -allow-local-symbol-tables \
9 ; RUN: | llvm-dis - | FileCheck %s -check-prefix=TD2 9 ; RUN: | llvm-dis - | FileCheck %s -check-prefix=TD2
10 10
11 ; ------------------------------------------------------ 11 ; ------------------------------------------------------
12 12
13 @bytes = internal global [4 x i8] c"abcd" 13 @bytes = internal global [4 x i8] c"abcd"
14 14
15 ; ------------------------------------------------------ 15 ; ------------------------------------------------------
16 16
17 ; Test that we elide the simple case of global. 17 ; Test that we elide the simple case of global.
18 define void @SimpleLoad() { 18 define void @SimpleLoad() {
19 %1 = bitcast [4 x i8]* @bytes to i32* 19 %1 = bitcast [4 x i8]* @bytes to i32*
20 %2 = load i32* %1, align 4 20 %2 = load i32, i32* %1, align 4
21 ret void 21 ret void
22 } 22 }
23 23
24 ; TD2: define void @SimpleLoad() { 24 ; TD2: define void @SimpleLoad() {
25 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32* 25 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32*
26 ; TD2-NEXT: %2 = load i32* %1, align 4 26 ; TD2-NEXT: %2 = load i32, i32* %1, align 4
27 ; TD2-NEXT: ret void 27 ; TD2-NEXT: ret void
28 ; TD2-NEXT: } 28 ; TD2-NEXT: }
29 29
30 ; PF2: <FUNCTION_BLOCK> 30 ; PF2: <FUNCTION_BLOCK>
31 ; PF2-NEXT: <DECLAREBLOCKS op0=1/> 31 ; PF2-NEXT: <DECLAREBLOCKS op0=1/>
32 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> 32 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/>
33 ; PF2-NEXT: <INST_RET/> 33 ; PF2-NEXT: <INST_RET/>
34 ; PF2-NEXT: </FUNCTION_BLOCK> 34 ; PF2-NEXT: </FUNCTION_BLOCK>
35 35
36 ; ------------------------------------------------------ 36 ; ------------------------------------------------------
37 37
38 ; Test that we elide the simple case of an alloca. 38 ; Test that we elide the simple case of an alloca.
39 define void @SimpleLoadAlloca() { 39 define void @SimpleLoadAlloca() {
40 %1 = alloca i8, i32 4, align 4 40 %1 = alloca i8, i32 4, align 4
41 %2 = bitcast i8* %1 to i32* 41 %2 = bitcast i8* %1 to i32*
42 %3 = load i32* %2, align 4 42 %3 = load i32, i32* %2, align 4
43 ret void 43 ret void
44 } 44 }
45 45
46 ; TD2: define void @SimpleLoadAlloca() { 46 ; TD2: define void @SimpleLoadAlloca() {
47 ; TD2-NEXT: %1 = alloca i8, i32 4, align 4 47 ; TD2-NEXT: %1 = alloca i8, i32 4, align 4
48 ; TD2-NEXT: %2 = bitcast i8* %1 to i32* 48 ; TD2-NEXT: %2 = bitcast i8* %1 to i32*
49 ; TD2-NEXT: %3 = load i32* %2, align 4 49 ; TD2-NEXT: %3 = load i32, i32* %2, align 4
50 ; TD2-NEXT: ret void 50 ; TD2-NEXT: ret void
51 ; TD2-NEXT: } 51 ; TD2-NEXT: }
52 52
53 ; PF2: <FUNCTION_BLOCK> 53 ; PF2: <FUNCTION_BLOCK>
54 ; PF2: </CONSTANTS_BLOCK> 54 ; PF2: </CONSTANTS_BLOCK>
55 ; PF2-NEXT: <INST_ALLOCA op0=1 op1=3/> 55 ; PF2-NEXT: <INST_ALLOCA op0=1 op1=3/>
56 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> 56 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/>
57 ; PF2-NEXT: <INST_RET/> 57 ; PF2-NEXT: <INST_RET/>
58 ; PF2-NEXT: </FUNCTION_BLOCK> 58 ; PF2-NEXT: </FUNCTION_BLOCK>
59 59
60 ; ------------------------------------------------------ 60 ; ------------------------------------------------------
61 61
62 ; Test that we can handle multiple bitcasts. 62 ; Test that we can handle multiple bitcasts.
63 define i32 @TwoLoads(i32 %i) { 63 define i32 @TwoLoads(i32 %i) {
64 %1 = bitcast [4 x i8]* @bytes to i32* 64 %1 = bitcast [4 x i8]* @bytes to i32*
65 %2 = load i32* %1, align 4 65 %2 = load i32, i32* %1, align 4
66 %3 = bitcast [4 x i8]* @bytes to i32* 66 %3 = bitcast [4 x i8]* @bytes to i32*
67 %4 = load i32* %3, align 4 67 %4 = load i32, i32* %3, align 4
68 %5 = add i32 %2, %4 68 %5 = add i32 %2, %4
69 ret i32 %5 69 ret i32 %5
70 } 70 }
71 71
72 ; TD2: define i32 @TwoLoads(i32 %i) { 72 ; TD2: define i32 @TwoLoads(i32 %i) {
73 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32* 73 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32*
74 ; TD2-NEXT: %2 = load i32* %1, align 4 74 ; TD2-NEXT: %2 = load i32, i32* %1, align 4
75 ; TD2-NEXT: %3 = load i32* %1, align 4 75 ; TD2-NEXT: %3 = load i32, i32* %1, align 4
76 ; TD2-NEXT: %4 = add i32 %2, %3 76 ; TD2-NEXT: %4 = add i32 %2, %3
77 ; TD2-NEXT: ret i32 %4 77 ; TD2-NEXT: ret i32 %4
78 ; TD2-NEXT: } 78 ; TD2-NEXT: }
79 79
80 ; PF2: <FUNCTION_BLOCK> 80 ; PF2: <FUNCTION_BLOCK>
81 ; PF2-NEXT: <DECLAREBLOCKS op0=1/> 81 ; PF2-NEXT: <DECLAREBLOCKS op0=1/>
82 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> 82 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/>
83 ; PF2-NEXT: <INST_LOAD op0=3 op1=3 op2=0/> 83 ; PF2-NEXT: <INST_LOAD op0=3 op1=3 op2=0/>
84 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> 84 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/>
85 ; PF2-NEXT: <INST_RET op0=1/> 85 ; PF2-NEXT: <INST_RET op0=1/>
86 ; PF2: </FUNCTION_BLOCK> 86 ; PF2: </FUNCTION_BLOCK>
87 87
88 ; ------------------------------------------------------ 88 ; ------------------------------------------------------
89 89
90 ; Test how we handle bitcasts if optimized in the input file. This 90 ; Test how we handle bitcasts if optimized in the input file. This
91 ; case tests within a single block. 91 ; case tests within a single block.
92 define i32 @TwoLoadOptOneBlock(i32 %i) { 92 define i32 @TwoLoadOptOneBlock(i32 %i) {
93 %1 = bitcast [4 x i8]* @bytes to i32* 93 %1 = bitcast [4 x i8]* @bytes to i32*
94 %2 = load i32* %1, align 4 94 %2 = load i32, i32* %1, align 4
95 %3 = load i32* %1, align 4 95 %3 = load i32, i32* %1, align 4
96 %4 = add i32 %2, %3 96 %4 = add i32 %2, %3
97 ret i32 %4 97 ret i32 %4
98 } 98 }
99 99
100 ; TD2: define i32 @TwoLoadOptOneBlock(i32 %i) { 100 ; TD2: define i32 @TwoLoadOptOneBlock(i32 %i) {
101 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32* 101 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32*
102 ; TD2-NEXT: %2 = load i32* %1, align 4 102 ; TD2-NEXT: %2 = load i32, i32* %1, align 4
103 ; TD2-NEXT: %3 = load i32* %1, align 4 103 ; TD2-NEXT: %3 = load i32, i32* %1, align 4
104 ; TD2-NEXT: %4 = add i32 %2, %3 104 ; TD2-NEXT: %4 = add i32 %2, %3
105 ; TD2-NEXT: ret i32 %4 105 ; TD2-NEXT: ret i32 %4
106 ; TD2-NEXT: } 106 ; TD2-NEXT: }
107 107
108 ; PF2: <FUNCTION_BLOCK> 108 ; PF2: <FUNCTION_BLOCK>
109 ; PF2-NEXT: <DECLAREBLOCKS op0=1/> 109 ; PF2-NEXT: <DECLAREBLOCKS op0=1/>
110 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> 110 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/>
111 ; PF2-NEXT: <INST_LOAD op0=3 op1=3 op2=0/> 111 ; PF2-NEXT: <INST_LOAD op0=3 op1=3 op2=0/>
112 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> 112 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/>
113 ; PF2-NEXT: <INST_RET op0=1/> 113 ; PF2-NEXT: <INST_RET op0=1/>
114 ; PF2: </FUNCTION_BLOCK> 114 ; PF2: </FUNCTION_BLOCK>
115 115
116 ; ------------------------------------------------------ 116 ; ------------------------------------------------------
117 117
118 ; Test how we handle bitcasts if optimized in the input file. This 118 ; Test how we handle bitcasts if optimized in the input file. This
119 ; case tests accross blocks. 119 ; case tests accross blocks.
120 define i32 @TwoLoadOptTwoBlocks(i32 %i) { 120 define i32 @TwoLoadOptTwoBlocks(i32 %i) {
121 %1 = bitcast [4 x i8]* @bytes to i32* 121 %1 = bitcast [4 x i8]* @bytes to i32*
122 %2 = load i32* %1, align 4 122 %2 = load i32, i32* %1, align 4
123 %3 = load i32* %1, align 4 123 %3 = load i32, i32* %1, align 4
124 %4 = add i32 %2, %3 124 %4 = add i32 %2, %3
125 br label %BB 125 br label %BB
126 126
127 BB: 127 BB:
128 %5 = load i32* %1, align 4 128 %5 = load i32, i32* %1, align 4
129 %6 = load i32* %1, align 4 129 %6 = load i32, i32* %1, align 4
130 %7 = add i32 %5, %6 130 %7 = add i32 %5, %6
131 ret i32 %4 131 ret i32 %4
132 } 132 }
133 133
134 ; TD2: define i32 @TwoLoadOptTwoBlocks(i32 %i) { 134 ; TD2: define i32 @TwoLoadOptTwoBlocks(i32 %i) {
135 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32* 135 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32*
136 ; TD2-NEXT: %2 = load i32* %1, align 4 136 ; TD2-NEXT: %2 = load i32, i32* %1, align 4
137 ; TD2-NEXT: %3 = load i32* %1, align 4 137 ; TD2-NEXT: %3 = load i32, i32* %1, align 4
138 ; TD2-NEXT: %4 = add i32 %2, %3 138 ; TD2-NEXT: %4 = add i32 %2, %3
139 ; TD2-NEXT: br label %BB 139 ; TD2-NEXT: br label %BB
140 ; TD2: BB: 140 ; TD2: BB:
141 ; TD2-NEXT: %5 = bitcast [4 x i8]* @bytes to i32* 141 ; TD2-NEXT: %5 = bitcast [4 x i8]* @bytes to i32*
142 ; TD2-NEXT: %6 = load i32* %5, align 4 142 ; TD2-NEXT: %6 = load i32, i32* %5, align 4
143 ; TD2-NEXT: %7 = load i32* %5, align 4 143 ; TD2-NEXT: %7 = load i32, i32* %5, align 4
144 ; TD2-NEXT: %8 = add i32 %6, %7 144 ; TD2-NEXT: %8 = add i32 %6, %7
145 ; TD2-NEXT: ret i32 %4 145 ; TD2-NEXT: ret i32 %4
146 ; TD2-NEXT: } 146 ; TD2-NEXT: }
147 147
148 ; PF2: <FUNCTION_BLOCK> 148 ; PF2: <FUNCTION_BLOCK>
149 ; PF2-NEXT: <DECLAREBLOCKS op0=2/> 149 ; PF2-NEXT: <DECLAREBLOCKS op0=2/>
150 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> 150 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/>
151 ; PF2-NEXT: <INST_LOAD op0=3 op1=3 op2=0/> 151 ; PF2-NEXT: <INST_LOAD op0=3 op1=3 op2=0/>
152 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> 152 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/>
153 ; PF2-NEXT: <INST_BR op0=1/> 153 ; PF2-NEXT: <INST_BR op0=1/>
(...skipping 16 matching lines...) Expand all
170 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32* 170 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32*
171 ; TD2-NEXT: store i32 %i, i32* %1, align 4 171 ; TD2-NEXT: store i32 %i, i32* %1, align 4
172 ; TD2-NEXT: ret void 172 ; TD2-NEXT: ret void
173 ; TD2-NEXT: } 173 ; TD2-NEXT: }
174 174
175 ; PF2: <FUNCTION_BLOCK> 175 ; PF2: <FUNCTION_BLOCK>
176 ; PF2-NEXT: <DECLAREBLOCKS op0=1/> 176 ; PF2-NEXT: <DECLAREBLOCKS op0=1/>
177 ; PF2-NEXT: <INST_STORE op0=2 op1=1 op2=3/> 177 ; PF2-NEXT: <INST_STORE op0=2 op1=1 op2=3/>
178 ; PF2-NEXT: <INST_RET/> 178 ; PF2-NEXT: <INST_RET/>
179 ; PF2: </FUNCTION_BLOCK> 179 ; PF2: </FUNCTION_BLOCK>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698