OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // TODO(jochen): Remove this after the setting is turned on globally. | 5 // TODO(jochen): Remove this after the setting is turned on globally. |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include "test/cctest/cctest.h" | 8 #include "test/cctest/cctest.h" |
9 #include "test/cctest/compiler/codegen-tester.h" | 9 #include "test/cctest/compiler/codegen-tester.h" |
10 #include "test/cctest/compiler/value-helper.h" | 10 #include "test/cctest/compiler/value-helper.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 namespace compiler { | 14 namespace compiler { |
15 | 15 |
16 typedef RawMachineAssembler::Label MLabel; | |
17 | |
18 static IrOpcode::Value int32cmp_opcodes[] = { | 16 static IrOpcode::Value int32cmp_opcodes[] = { |
19 IrOpcode::kWord32Equal, IrOpcode::kInt32LessThan, | 17 IrOpcode::kWord32Equal, IrOpcode::kInt32LessThan, |
20 IrOpcode::kInt32LessThanOrEqual, IrOpcode::kUint32LessThan, | 18 IrOpcode::kInt32LessThanOrEqual, IrOpcode::kUint32LessThan, |
21 IrOpcode::kUint32LessThanOrEqual}; | 19 IrOpcode::kUint32LessThanOrEqual}; |
22 | 20 |
23 | 21 |
24 TEST(BranchCombineWord32EqualZero_1) { | 22 TEST(BranchCombineWord32EqualZero_1) { |
25 // Test combining a branch with x == 0 | 23 // Test combining a branch with x == 0 |
26 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 24 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
27 int32_t eq_constant = -1033; | 25 int32_t eq_constant = -1033; |
28 int32_t ne_constant = 825118; | 26 int32_t ne_constant = 825118; |
29 Node* p0 = m.Parameter(0); | 27 Node* p0 = m.Parameter(0); |
30 | 28 |
31 MLabel blocka, blockb; | 29 RawMachineLabel blocka, blockb; |
32 m.Branch(m.Word32Equal(p0, m.Int32Constant(0)), &blocka, &blockb); | 30 m.Branch(m.Word32Equal(p0, m.Int32Constant(0)), &blocka, &blockb); |
33 m.Bind(&blocka); | 31 m.Bind(&blocka); |
34 m.Return(m.Int32Constant(eq_constant)); | 32 m.Return(m.Int32Constant(eq_constant)); |
35 m.Bind(&blockb); | 33 m.Bind(&blockb); |
36 m.Return(m.Int32Constant(ne_constant)); | 34 m.Return(m.Int32Constant(ne_constant)); |
37 | 35 |
38 FOR_INT32_INPUTS(i) { | 36 FOR_INT32_INPUTS(i) { |
39 int32_t a = *i; | 37 int32_t a = *i; |
40 int32_t expect = a == 0 ? eq_constant : ne_constant; | 38 int32_t expect = a == 0 ? eq_constant : ne_constant; |
41 CHECK_EQ(expect, m.Call(a)); | 39 CHECK_EQ(expect, m.Call(a)); |
42 } | 40 } |
43 } | 41 } |
44 | 42 |
45 | 43 |
46 TEST(BranchCombineWord32EqualZero_chain) { | 44 TEST(BranchCombineWord32EqualZero_chain) { |
47 // Test combining a branch with a chain of x == 0 == 0 == 0 ... | 45 // Test combining a branch with a chain of x == 0 == 0 == 0 ... |
48 int32_t eq_constant = -1133; | 46 int32_t eq_constant = -1133; |
49 int32_t ne_constant = 815118; | 47 int32_t ne_constant = 815118; |
50 | 48 |
51 for (int k = 0; k < 6; k++) { | 49 for (int k = 0; k < 6; k++) { |
52 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 50 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
53 Node* p0 = m.Parameter(0); | 51 Node* p0 = m.Parameter(0); |
54 MLabel blocka, blockb; | 52 RawMachineLabel blocka, blockb; |
55 Node* cond = p0; | 53 Node* cond = p0; |
56 for (int j = 0; j < k; j++) { | 54 for (int j = 0; j < k; j++) { |
57 cond = m.Word32Equal(cond, m.Int32Constant(0)); | 55 cond = m.Word32Equal(cond, m.Int32Constant(0)); |
58 } | 56 } |
59 m.Branch(cond, &blocka, &blockb); | 57 m.Branch(cond, &blocka, &blockb); |
60 m.Bind(&blocka); | 58 m.Bind(&blocka); |
61 m.Return(m.Int32Constant(eq_constant)); | 59 m.Return(m.Int32Constant(eq_constant)); |
62 m.Bind(&blockb); | 60 m.Bind(&blockb); |
63 m.Return(m.Int32Constant(ne_constant)); | 61 m.Return(m.Int32Constant(ne_constant)); |
64 | 62 |
65 FOR_INT32_INPUTS(i) { | 63 FOR_INT32_INPUTS(i) { |
66 int32_t a = *i; | 64 int32_t a = *i; |
67 int32_t expect = (k & 1) == 1 ? (a == 0 ? eq_constant : ne_constant) | 65 int32_t expect = (k & 1) == 1 ? (a == 0 ? eq_constant : ne_constant) |
68 : (a == 0 ? ne_constant : eq_constant); | 66 : (a == 0 ? ne_constant : eq_constant); |
69 CHECK_EQ(expect, m.Call(a)); | 67 CHECK_EQ(expect, m.Call(a)); |
70 } | 68 } |
71 } | 69 } |
72 } | 70 } |
73 | 71 |
74 | 72 |
75 TEST(BranchCombineInt32LessThanZero_1) { | 73 TEST(BranchCombineInt32LessThanZero_1) { |
76 // Test combining a branch with x < 0 | 74 // Test combining a branch with x < 0 |
77 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 75 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
78 int32_t eq_constant = -1433; | 76 int32_t eq_constant = -1433; |
79 int32_t ne_constant = 845118; | 77 int32_t ne_constant = 845118; |
80 Node* p0 = m.Parameter(0); | 78 Node* p0 = m.Parameter(0); |
81 | 79 |
82 MLabel blocka, blockb; | 80 RawMachineLabel blocka, blockb; |
83 m.Branch(m.Int32LessThan(p0, m.Int32Constant(0)), &blocka, &blockb); | 81 m.Branch(m.Int32LessThan(p0, m.Int32Constant(0)), &blocka, &blockb); |
84 m.Bind(&blocka); | 82 m.Bind(&blocka); |
85 m.Return(m.Int32Constant(eq_constant)); | 83 m.Return(m.Int32Constant(eq_constant)); |
86 m.Bind(&blockb); | 84 m.Bind(&blockb); |
87 m.Return(m.Int32Constant(ne_constant)); | 85 m.Return(m.Int32Constant(ne_constant)); |
88 | 86 |
89 FOR_INT32_INPUTS(i) { | 87 FOR_INT32_INPUTS(i) { |
90 int32_t a = *i; | 88 int32_t a = *i; |
91 int32_t expect = a < 0 ? eq_constant : ne_constant; | 89 int32_t expect = a < 0 ? eq_constant : ne_constant; |
92 CHECK_EQ(expect, m.Call(a)); | 90 CHECK_EQ(expect, m.Call(a)); |
93 } | 91 } |
94 } | 92 } |
95 | 93 |
96 | 94 |
97 TEST(BranchCombineUint32LessThan100_1) { | 95 TEST(BranchCombineUint32LessThan100_1) { |
98 // Test combining a branch with x < 100 | 96 // Test combining a branch with x < 100 |
99 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 97 RawMachineAssemblerTester<int32_t> m(kMachUint32); |
100 int32_t eq_constant = 1471; | 98 int32_t eq_constant = 1471; |
101 int32_t ne_constant = 88845718; | 99 int32_t ne_constant = 88845718; |
102 Node* p0 = m.Parameter(0); | 100 Node* p0 = m.Parameter(0); |
103 | 101 |
104 MLabel blocka, blockb; | 102 RawMachineLabel blocka, blockb; |
105 m.Branch(m.Uint32LessThan(p0, m.Int32Constant(100)), &blocka, &blockb); | 103 m.Branch(m.Uint32LessThan(p0, m.Int32Constant(100)), &blocka, &blockb); |
106 m.Bind(&blocka); | 104 m.Bind(&blocka); |
107 m.Return(m.Int32Constant(eq_constant)); | 105 m.Return(m.Int32Constant(eq_constant)); |
108 m.Bind(&blockb); | 106 m.Bind(&blockb); |
109 m.Return(m.Int32Constant(ne_constant)); | 107 m.Return(m.Int32Constant(ne_constant)); |
110 | 108 |
111 FOR_UINT32_INPUTS(i) { | 109 FOR_UINT32_INPUTS(i) { |
112 uint32_t a = *i; | 110 uint32_t a = *i; |
113 int32_t expect = a < 100 ? eq_constant : ne_constant; | 111 int32_t expect = a < 100 ? eq_constant : ne_constant; |
114 CHECK_EQ(expect, m.Call(a)); | 112 CHECK_EQ(expect, m.Call(a)); |
115 } | 113 } |
116 } | 114 } |
117 | 115 |
118 | 116 |
119 TEST(BranchCombineUint32LessThanOrEqual100_1) { | 117 TEST(BranchCombineUint32LessThanOrEqual100_1) { |
120 // Test combining a branch with x <= 100 | 118 // Test combining a branch with x <= 100 |
121 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 119 RawMachineAssemblerTester<int32_t> m(kMachUint32); |
122 int32_t eq_constant = 1479; | 120 int32_t eq_constant = 1479; |
123 int32_t ne_constant = 77845719; | 121 int32_t ne_constant = 77845719; |
124 Node* p0 = m.Parameter(0); | 122 Node* p0 = m.Parameter(0); |
125 | 123 |
126 MLabel blocka, blockb; | 124 RawMachineLabel blocka, blockb; |
127 m.Branch(m.Uint32LessThanOrEqual(p0, m.Int32Constant(100)), &blocka, &blockb); | 125 m.Branch(m.Uint32LessThanOrEqual(p0, m.Int32Constant(100)), &blocka, &blockb); |
128 m.Bind(&blocka); | 126 m.Bind(&blocka); |
129 m.Return(m.Int32Constant(eq_constant)); | 127 m.Return(m.Int32Constant(eq_constant)); |
130 m.Bind(&blockb); | 128 m.Bind(&blockb); |
131 m.Return(m.Int32Constant(ne_constant)); | 129 m.Return(m.Int32Constant(ne_constant)); |
132 | 130 |
133 FOR_UINT32_INPUTS(i) { | 131 FOR_UINT32_INPUTS(i) { |
134 uint32_t a = *i; | 132 uint32_t a = *i; |
135 int32_t expect = a <= 100 ? eq_constant : ne_constant; | 133 int32_t expect = a <= 100 ? eq_constant : ne_constant; |
136 CHECK_EQ(expect, m.Call(a)); | 134 CHECK_EQ(expect, m.Call(a)); |
137 } | 135 } |
138 } | 136 } |
139 | 137 |
140 | 138 |
141 TEST(BranchCombineZeroLessThanInt32_1) { | 139 TEST(BranchCombineZeroLessThanInt32_1) { |
142 // Test combining a branch with 0 < x | 140 // Test combining a branch with 0 < x |
143 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 141 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
144 int32_t eq_constant = -2033; | 142 int32_t eq_constant = -2033; |
145 int32_t ne_constant = 225118; | 143 int32_t ne_constant = 225118; |
146 Node* p0 = m.Parameter(0); | 144 Node* p0 = m.Parameter(0); |
147 | 145 |
148 MLabel blocka, blockb; | 146 RawMachineLabel blocka, blockb; |
149 m.Branch(m.Int32LessThan(m.Int32Constant(0), p0), &blocka, &blockb); | 147 m.Branch(m.Int32LessThan(m.Int32Constant(0), p0), &blocka, &blockb); |
150 m.Bind(&blocka); | 148 m.Bind(&blocka); |
151 m.Return(m.Int32Constant(eq_constant)); | 149 m.Return(m.Int32Constant(eq_constant)); |
152 m.Bind(&blockb); | 150 m.Bind(&blockb); |
153 m.Return(m.Int32Constant(ne_constant)); | 151 m.Return(m.Int32Constant(ne_constant)); |
154 | 152 |
155 FOR_INT32_INPUTS(i) { | 153 FOR_INT32_INPUTS(i) { |
156 int32_t a = *i; | 154 int32_t a = *i; |
157 int32_t expect = 0 < a ? eq_constant : ne_constant; | 155 int32_t expect = 0 < a ? eq_constant : ne_constant; |
158 CHECK_EQ(expect, m.Call(a)); | 156 CHECK_EQ(expect, m.Call(a)); |
159 } | 157 } |
160 } | 158 } |
161 | 159 |
162 | 160 |
163 TEST(BranchCombineInt32GreaterThanZero_1) { | 161 TEST(BranchCombineInt32GreaterThanZero_1) { |
164 // Test combining a branch with x > 0 | 162 // Test combining a branch with x > 0 |
165 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 163 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
166 int32_t eq_constant = -1073; | 164 int32_t eq_constant = -1073; |
167 int32_t ne_constant = 825178; | 165 int32_t ne_constant = 825178; |
168 Node* p0 = m.Parameter(0); | 166 Node* p0 = m.Parameter(0); |
169 | 167 |
170 MLabel blocka, blockb; | 168 RawMachineLabel blocka, blockb; |
171 m.Branch(m.Int32GreaterThan(p0, m.Int32Constant(0)), &blocka, &blockb); | 169 m.Branch(m.Int32GreaterThan(p0, m.Int32Constant(0)), &blocka, &blockb); |
172 m.Bind(&blocka); | 170 m.Bind(&blocka); |
173 m.Return(m.Int32Constant(eq_constant)); | 171 m.Return(m.Int32Constant(eq_constant)); |
174 m.Bind(&blockb); | 172 m.Bind(&blockb); |
175 m.Return(m.Int32Constant(ne_constant)); | 173 m.Return(m.Int32Constant(ne_constant)); |
176 | 174 |
177 FOR_INT32_INPUTS(i) { | 175 FOR_INT32_INPUTS(i) { |
178 int32_t a = *i; | 176 int32_t a = *i; |
179 int32_t expect = a > 0 ? eq_constant : ne_constant; | 177 int32_t expect = a > 0 ? eq_constant : ne_constant; |
180 CHECK_EQ(expect, m.Call(a)); | 178 CHECK_EQ(expect, m.Call(a)); |
181 } | 179 } |
182 } | 180 } |
183 | 181 |
184 | 182 |
185 TEST(BranchCombineWord32EqualP) { | 183 TEST(BranchCombineWord32EqualP) { |
186 // Test combining a branch with an Word32Equal. | 184 // Test combining a branch with an Word32Equal. |
187 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); | 185 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); |
188 int32_t eq_constant = -1035; | 186 int32_t eq_constant = -1035; |
189 int32_t ne_constant = 825018; | 187 int32_t ne_constant = 825018; |
190 Node* p0 = m.Parameter(0); | 188 Node* p0 = m.Parameter(0); |
191 Node* p1 = m.Parameter(1); | 189 Node* p1 = m.Parameter(1); |
192 | 190 |
193 MLabel blocka, blockb; | 191 RawMachineLabel blocka, blockb; |
194 m.Branch(m.Word32Equal(p0, p1), &blocka, &blockb); | 192 m.Branch(m.Word32Equal(p0, p1), &blocka, &blockb); |
195 m.Bind(&blocka); | 193 m.Bind(&blocka); |
196 m.Return(m.Int32Constant(eq_constant)); | 194 m.Return(m.Int32Constant(eq_constant)); |
197 m.Bind(&blockb); | 195 m.Bind(&blockb); |
198 m.Return(m.Int32Constant(ne_constant)); | 196 m.Return(m.Int32Constant(ne_constant)); |
199 | 197 |
200 FOR_INT32_INPUTS(i) { | 198 FOR_INT32_INPUTS(i) { |
201 FOR_INT32_INPUTS(j) { | 199 FOR_INT32_INPUTS(j) { |
202 int32_t a = *i; | 200 int32_t a = *i; |
203 int32_t b = *j; | 201 int32_t b = *j; |
204 int32_t expect = a == b ? eq_constant : ne_constant; | 202 int32_t expect = a == b ? eq_constant : ne_constant; |
205 CHECK_EQ(expect, m.Call(a, b)); | 203 CHECK_EQ(expect, m.Call(a, b)); |
206 } | 204 } |
207 } | 205 } |
208 } | 206 } |
209 | 207 |
210 | 208 |
211 TEST(BranchCombineWord32EqualI) { | 209 TEST(BranchCombineWord32EqualI) { |
212 int32_t eq_constant = -1135; | 210 int32_t eq_constant = -1135; |
213 int32_t ne_constant = 925718; | 211 int32_t ne_constant = 925718; |
214 | 212 |
215 for (int left = 0; left < 2; left++) { | 213 for (int left = 0; left < 2; left++) { |
216 FOR_INT32_INPUTS(i) { | 214 FOR_INT32_INPUTS(i) { |
217 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 215 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
218 int32_t a = *i; | 216 int32_t a = *i; |
219 | 217 |
220 Node* p0 = m.Int32Constant(a); | 218 Node* p0 = m.Int32Constant(a); |
221 Node* p1 = m.Parameter(0); | 219 Node* p1 = m.Parameter(0); |
222 | 220 |
223 MLabel blocka, blockb; | 221 RawMachineLabel blocka, blockb; |
224 if (left == 1) m.Branch(m.Word32Equal(p0, p1), &blocka, &blockb); | 222 if (left == 1) m.Branch(m.Word32Equal(p0, p1), &blocka, &blockb); |
225 if (left == 0) m.Branch(m.Word32Equal(p1, p0), &blocka, &blockb); | 223 if (left == 0) m.Branch(m.Word32Equal(p1, p0), &blocka, &blockb); |
226 m.Bind(&blocka); | 224 m.Bind(&blocka); |
227 m.Return(m.Int32Constant(eq_constant)); | 225 m.Return(m.Int32Constant(eq_constant)); |
228 m.Bind(&blockb); | 226 m.Bind(&blockb); |
229 m.Return(m.Int32Constant(ne_constant)); | 227 m.Return(m.Int32Constant(ne_constant)); |
230 | 228 |
231 FOR_INT32_INPUTS(j) { | 229 FOR_INT32_INPUTS(j) { |
232 int32_t b = *j; | 230 int32_t b = *j; |
233 int32_t expect = a == b ? eq_constant : ne_constant; | 231 int32_t expect = a == b ? eq_constant : ne_constant; |
234 CHECK_EQ(expect, m.Call(b)); | 232 CHECK_EQ(expect, m.Call(b)); |
235 } | 233 } |
236 } | 234 } |
237 } | 235 } |
238 } | 236 } |
239 | 237 |
240 | 238 |
241 TEST(BranchCombineInt32CmpP) { | 239 TEST(BranchCombineInt32CmpP) { |
242 int32_t eq_constant = -1235; | 240 int32_t eq_constant = -1235; |
243 int32_t ne_constant = 725018; | 241 int32_t ne_constant = 725018; |
244 | 242 |
245 for (int op = 0; op < 2; op++) { | 243 for (int op = 0; op < 2; op++) { |
246 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); | 244 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); |
247 Node* p0 = m.Parameter(0); | 245 Node* p0 = m.Parameter(0); |
248 Node* p1 = m.Parameter(1); | 246 Node* p1 = m.Parameter(1); |
249 | 247 |
250 MLabel blocka, blockb; | 248 RawMachineLabel blocka, blockb; |
251 if (op == 0) m.Branch(m.Int32LessThan(p0, p1), &blocka, &blockb); | 249 if (op == 0) m.Branch(m.Int32LessThan(p0, p1), &blocka, &blockb); |
252 if (op == 1) m.Branch(m.Int32LessThanOrEqual(p0, p1), &blocka, &blockb); | 250 if (op == 1) m.Branch(m.Int32LessThanOrEqual(p0, p1), &blocka, &blockb); |
253 m.Bind(&blocka); | 251 m.Bind(&blocka); |
254 m.Return(m.Int32Constant(eq_constant)); | 252 m.Return(m.Int32Constant(eq_constant)); |
255 m.Bind(&blockb); | 253 m.Bind(&blockb); |
256 m.Return(m.Int32Constant(ne_constant)); | 254 m.Return(m.Int32Constant(ne_constant)); |
257 | 255 |
258 FOR_INT32_INPUTS(i) { | 256 FOR_INT32_INPUTS(i) { |
259 FOR_INT32_INPUTS(j) { | 257 FOR_INT32_INPUTS(j) { |
260 int32_t a = *i; | 258 int32_t a = *i; |
(...skipping 12 matching lines...) Expand all Loading... |
273 int32_t eq_constant = -1175; | 271 int32_t eq_constant = -1175; |
274 int32_t ne_constant = 927711; | 272 int32_t ne_constant = 927711; |
275 | 273 |
276 for (int op = 0; op < 2; op++) { | 274 for (int op = 0; op < 2; op++) { |
277 FOR_INT32_INPUTS(i) { | 275 FOR_INT32_INPUTS(i) { |
278 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 276 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
279 int32_t a = *i; | 277 int32_t a = *i; |
280 Node* p0 = m.Int32Constant(a); | 278 Node* p0 = m.Int32Constant(a); |
281 Node* p1 = m.Parameter(0); | 279 Node* p1 = m.Parameter(0); |
282 | 280 |
283 MLabel blocka, blockb; | 281 RawMachineLabel blocka, blockb; |
284 if (op == 0) m.Branch(m.Int32LessThan(p0, p1), &blocka, &blockb); | 282 if (op == 0) m.Branch(m.Int32LessThan(p0, p1), &blocka, &blockb); |
285 if (op == 1) m.Branch(m.Int32LessThanOrEqual(p0, p1), &blocka, &blockb); | 283 if (op == 1) m.Branch(m.Int32LessThanOrEqual(p0, p1), &blocka, &blockb); |
286 m.Bind(&blocka); | 284 m.Bind(&blocka); |
287 m.Return(m.Int32Constant(eq_constant)); | 285 m.Return(m.Int32Constant(eq_constant)); |
288 m.Bind(&blockb); | 286 m.Bind(&blockb); |
289 m.Return(m.Int32Constant(ne_constant)); | 287 m.Return(m.Int32Constant(ne_constant)); |
290 | 288 |
291 FOR_INT32_INPUTS(j) { | 289 FOR_INT32_INPUTS(j) { |
292 int32_t b = *j; | 290 int32_t b = *j; |
293 int32_t expect = 0; | 291 int32_t expect = 0; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 CompareWrapper w; | 327 CompareWrapper w; |
330 bool invert; | 328 bool invert; |
331 bool true_first; | 329 bool true_first; |
332 int32_t eq_constant; | 330 int32_t eq_constant; |
333 int32_t ne_constant; | 331 int32_t ne_constant; |
334 | 332 |
335 CmpBranchGen(IrOpcode::Value opcode, bool i, bool t, int32_t eq, int32_t ne) | 333 CmpBranchGen(IrOpcode::Value opcode, bool i, bool t, int32_t eq, int32_t ne) |
336 : w(opcode), invert(i), true_first(t), eq_constant(eq), ne_constant(ne) {} | 334 : w(opcode), invert(i), true_first(t), eq_constant(eq), ne_constant(ne) {} |
337 | 335 |
338 virtual void gen(RawMachineAssemblerTester<int32_t>* m, Node* a, Node* b) { | 336 virtual void gen(RawMachineAssemblerTester<int32_t>* m, Node* a, Node* b) { |
339 MLabel blocka, blockb; | 337 RawMachineLabel blocka, blockb; |
340 Node* cond = w.MakeNode(m, a, b); | 338 Node* cond = w.MakeNode(m, a, b); |
341 if (invert) cond = m->Word32Equal(cond, m->Int32Constant(0)); | 339 if (invert) cond = m->Word32Equal(cond, m->Int32Constant(0)); |
342 m->Branch(cond, &blocka, &blockb); | 340 m->Branch(cond, &blocka, &blockb); |
343 if (true_first) { | 341 if (true_first) { |
344 m->Bind(&blocka); | 342 m->Bind(&blocka); |
345 m->Return(m->Int32Constant(eq_constant)); | 343 m->Return(m->Int32Constant(eq_constant)); |
346 m->Bind(&blockb); | 344 m->Bind(&blockb); |
347 m->Return(m->Int32Constant(ne_constant)); | 345 m->Return(m->Int32Constant(ne_constant)); |
348 } else { | 346 } else { |
349 m->Bind(&blockb); | 347 m->Bind(&blockb); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 CompareWrapper(IrOpcode::kFloat64LessThan), | 426 CompareWrapper(IrOpcode::kFloat64LessThan), |
429 CompareWrapper(IrOpcode::kFloat64LessThanOrEqual)}; | 427 CompareWrapper(IrOpcode::kFloat64LessThanOrEqual)}; |
430 | 428 |
431 for (size_t c = 0; c < arraysize(cmps); c++) { | 429 for (size_t c = 0; c < arraysize(cmps); c++) { |
432 CompareWrapper cmp = cmps[c]; | 430 CompareWrapper cmp = cmps[c]; |
433 for (int invert = 0; invert < 2; invert++) { | 431 for (int invert = 0; invert < 2; invert++) { |
434 RawMachineAssemblerTester<int32_t> m; | 432 RawMachineAssemblerTester<int32_t> m; |
435 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); | 433 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); |
436 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); | 434 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); |
437 | 435 |
438 MLabel blocka, blockb; | 436 RawMachineLabel blocka, blockb; |
439 Node* cond = cmp.MakeNode(&m, a, b); | 437 Node* cond = cmp.MakeNode(&m, a, b); |
440 if (invert) cond = m.Word32Equal(cond, m.Int32Constant(0)); | 438 if (invert) cond = m.Word32Equal(cond, m.Int32Constant(0)); |
441 m.Branch(cond, &blocka, &blockb); | 439 m.Branch(cond, &blocka, &blockb); |
442 m.Bind(&blocka); | 440 m.Bind(&blocka); |
443 m.Return(m.Int32Constant(eq_constant)); | 441 m.Return(m.Int32Constant(eq_constant)); |
444 m.Bind(&blockb); | 442 m.Bind(&blockb); |
445 m.Return(m.Int32Constant(ne_constant)); | 443 m.Return(m.Int32Constant(ne_constant)); |
446 | 444 |
447 for (size_t i = 0; i < arraysize(inputs); ++i) { | 445 for (size_t i = 0; i < arraysize(inputs); ++i) { |
448 for (size_t j = 0; j < arraysize(inputs); ++j) { | 446 for (size_t j = 0; j < arraysize(inputs); ++j) { |
449 input_a = inputs[i]; | 447 input_a = inputs[i]; |
450 input_b = inputs[j]; | 448 input_b = inputs[j]; |
451 int32_t expected = | 449 int32_t expected = |
452 invert ? (cmp.Float64Compare(input_a, input_b) ? ne_constant | 450 invert ? (cmp.Float64Compare(input_a, input_b) ? ne_constant |
453 : eq_constant) | 451 : eq_constant) |
454 : (cmp.Float64Compare(input_a, input_b) ? eq_constant | 452 : (cmp.Float64Compare(input_a, input_b) ? eq_constant |
455 : ne_constant); | 453 : ne_constant); |
456 CHECK_EQ(expected, m.Call()); | 454 CHECK_EQ(expected, m.Call()); |
457 } | 455 } |
458 } | 456 } |
459 } | 457 } |
460 } | 458 } |
461 } | 459 } |
462 | 460 |
463 } // namespace compiler | 461 } // namespace compiler |
464 } // namespace internal | 462 } // namespace internal |
465 } // namespace v8 | 463 } // namespace v8 |
OLD | NEW |