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

Side by Side Diff: src/compiler/machine-operator-reducer-unittest.cc

Issue 553843002: Replace our home-grown BitCast with bit_cast from Chrome/Google3. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/js-graph.cc ('k') | src/compiler/node-cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "src/base/bits.h" 5 #include "src/base/bits.h"
6 #include "src/compiler/graph-unittest.h" 6 #include "src/compiler/graph-unittest.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/machine-operator-reducer.h" 8 #include "src/compiler/machine-operator-reducer.h"
9 #include "src/compiler/typer.h" 9 #include "src/compiler/typer.h"
10 10
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 ASSERT_TRUE(reduction.Changed()); 242 ASSERT_TRUE(reduction.Changed());
243 EXPECT_EQ(value, reduction.replacement()); 243 EXPECT_EQ(value, reduction.replacement());
244 } 244 }
245 245
246 246
247 TEST_F(MachineOperatorReducerTest, ChangeFloat64ToUint32WithConstant) { 247 TEST_F(MachineOperatorReducerTest, ChangeFloat64ToUint32WithConstant) {
248 TRACED_FOREACH(uint32_t, x, kUint32Values) { 248 TRACED_FOREACH(uint32_t, x, kUint32Values) {
249 Reduction reduction = Reduce(graph()->NewNode( 249 Reduction reduction = Reduce(graph()->NewNode(
250 machine()->ChangeFloat64ToUint32(), Float64Constant(FastUI2D(x)))); 250 machine()->ChangeFloat64ToUint32(), Float64Constant(FastUI2D(x))));
251 ASSERT_TRUE(reduction.Changed()); 251 ASSERT_TRUE(reduction.Changed());
252 EXPECT_THAT(reduction.replacement(), IsInt32Constant(BitCast<int32_t>(x))); 252 EXPECT_THAT(reduction.replacement(), IsInt32Constant(bit_cast<int32_t>(x)));
253 } 253 }
254 } 254 }
255 255
256 256
257 // ----------------------------------------------------------------------------- 257 // -----------------------------------------------------------------------------
258 // ChangeInt32ToFloat64 258 // ChangeInt32ToFloat64
259 259
260 260
261 TEST_F(MachineOperatorReducerTest, ChangeInt32ToFloat64WithConstant) { 261 TEST_F(MachineOperatorReducerTest, ChangeInt32ToFloat64WithConstant) {
262 TRACED_FOREACH(int32_t, x, kInt32Values) { 262 TRACED_FOREACH(int32_t, x, kInt32Values) {
(...skipping 20 matching lines...) Expand all
283 283
284 284
285 // ----------------------------------------------------------------------------- 285 // -----------------------------------------------------------------------------
286 // ChangeUint32ToFloat64 286 // ChangeUint32ToFloat64
287 287
288 288
289 TEST_F(MachineOperatorReducerTest, ChangeUint32ToFloat64WithConstant) { 289 TEST_F(MachineOperatorReducerTest, ChangeUint32ToFloat64WithConstant) {
290 TRACED_FOREACH(uint32_t, x, kUint32Values) { 290 TRACED_FOREACH(uint32_t, x, kUint32Values) {
291 Reduction reduction = 291 Reduction reduction =
292 Reduce(graph()->NewNode(machine()->ChangeUint32ToFloat64(), 292 Reduce(graph()->NewNode(machine()->ChangeUint32ToFloat64(),
293 Int32Constant(BitCast<int32_t>(x)))); 293 Int32Constant(bit_cast<int32_t>(x))));
294 ASSERT_TRUE(reduction.Changed()); 294 ASSERT_TRUE(reduction.Changed());
295 EXPECT_THAT(reduction.replacement(), IsFloat64Constant(FastUI2D(x))); 295 EXPECT_THAT(reduction.replacement(), IsFloat64Constant(FastUI2D(x)));
296 } 296 }
297 } 297 }
298 298
299 299
300 // ----------------------------------------------------------------------------- 300 // -----------------------------------------------------------------------------
301 // ChangeUint32ToUint64 301 // ChangeUint32ToUint64
302 302
303 303
304 TEST_F(MachineOperatorReducerTest, ChangeUint32ToUint64WithConstant) { 304 TEST_F(MachineOperatorReducerTest, ChangeUint32ToUint64WithConstant) {
305 TRACED_FOREACH(uint32_t, x, kUint32Values) { 305 TRACED_FOREACH(uint32_t, x, kUint32Values) {
306 Reduction reduction = Reduce(graph()->NewNode( 306 Reduction reduction =
307 machine()->ChangeUint32ToUint64(), Int32Constant(BitCast<int32_t>(x)))); 307 Reduce(graph()->NewNode(machine()->ChangeUint32ToUint64(),
308 Int32Constant(bit_cast<int32_t>(x))));
308 ASSERT_TRUE(reduction.Changed()); 309 ASSERT_TRUE(reduction.Changed());
309 EXPECT_THAT(reduction.replacement(), 310 EXPECT_THAT(reduction.replacement(),
310 IsInt64Constant(BitCast<int64_t>(static_cast<uint64_t>(x)))); 311 IsInt64Constant(bit_cast<int64_t>(static_cast<uint64_t>(x))));
311 } 312 }
312 } 313 }
313 314
314 315
315 // ----------------------------------------------------------------------------- 316 // -----------------------------------------------------------------------------
316 // TruncateFloat64ToInt32 317 // TruncateFloat64ToInt32
317 318
318 319
319 TEST_F(MachineOperatorReducerTest, 320 TEST_F(MachineOperatorReducerTest,
320 TruncateFloat64ToInt32WithChangeInt32ToFloat64) { 321 TruncateFloat64ToInt32WithChangeInt32ToFloat64) {
(...skipping 29 matching lines...) Expand all
350 EXPECT_EQ(value, reduction.replacement()); 351 EXPECT_EQ(value, reduction.replacement());
351 } 352 }
352 353
353 354
354 TEST_F(MachineOperatorReducerTest, TruncateInt64ToInt32WithConstant) { 355 TEST_F(MachineOperatorReducerTest, TruncateInt64ToInt32WithConstant) {
355 TRACED_FOREACH(int64_t, x, kInt64Values) { 356 TRACED_FOREACH(int64_t, x, kInt64Values) {
356 Reduction reduction = Reduce( 357 Reduction reduction = Reduce(
357 graph()->NewNode(machine()->TruncateInt64ToInt32(), Int64Constant(x))); 358 graph()->NewNode(machine()->TruncateInt64ToInt32(), Int64Constant(x)));
358 ASSERT_TRUE(reduction.Changed()); 359 ASSERT_TRUE(reduction.Changed());
359 EXPECT_THAT(reduction.replacement(), 360 EXPECT_THAT(reduction.replacement(),
360 IsInt32Constant(BitCast<int32_t>( 361 IsInt32Constant(bit_cast<int32_t>(
361 static_cast<uint32_t>(BitCast<uint64_t>(x))))); 362 static_cast<uint32_t>(bit_cast<uint64_t>(x)))));
362 } 363 }
363 } 364 }
364 365
365 366
366 // ----------------------------------------------------------------------------- 367 // -----------------------------------------------------------------------------
367 // Word32Ror 368 // Word32Ror
368 369
369 370
370 TEST_F(MachineOperatorReducerTest, ReduceToWord32RorWithParameters) { 371 TEST_F(MachineOperatorReducerTest, ReduceToWord32RorWithParameters) {
371 Node* value = Parameter(0); 372 Node* value = Parameter(0);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 EXPECT_TRUE(reduction.Changed()); 438 EXPECT_TRUE(reduction.Changed());
438 EXPECT_THAT(reduction.replacement(), 439 EXPECT_THAT(reduction.replacement(),
439 IsInt32Constant(base::bits::RotateRight32(x, y))); 440 IsInt32Constant(base::bits::RotateRight32(x, y)));
440 } 441 }
441 } 442 }
442 } 443 }
443 444
444 } // namespace compiler 445 } // namespace compiler
445 } // namespace internal 446 } // namespace internal
446 } // namespace v8 447 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-graph.cc ('k') | src/compiler/node-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698