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

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

Issue 666723005: [turbofan] Reduce ~~x to x. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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/machine-operator-reducer.cc ('k') | no next file » | 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/base/division-by-constant.h" 6 #include "src/base/division-by-constant.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 #include "test/unittests/compiler/graph-unittest.h" 10 #include "test/unittests/compiler/graph-unittest.h"
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 graph()->NewNode(machine()->TruncateInt64ToInt32(), Int64Constant(x))); 475 graph()->NewNode(machine()->TruncateInt64ToInt32(), Int64Constant(x)));
476 ASSERT_TRUE(reduction.Changed()); 476 ASSERT_TRUE(reduction.Changed());
477 EXPECT_THAT(reduction.replacement(), 477 EXPECT_THAT(reduction.replacement(),
478 IsInt32Constant(bit_cast<int32_t>( 478 IsInt32Constant(bit_cast<int32_t>(
479 static_cast<uint32_t>(bit_cast<uint64_t>(x))))); 479 static_cast<uint32_t>(bit_cast<uint64_t>(x)))));
480 } 480 }
481 } 481 }
482 482
483 483
484 // ----------------------------------------------------------------------------- 484 // -----------------------------------------------------------------------------
485 // Word32Xor
486
487
488 TEST_F(MachineOperatorReducerTest, Word32XorWithWord32XorAndMinusOne) {
489 Node* const p0 = Parameter(0);
490
491 // (x ^ -1) ^ -1 => x
492 Reduction r1 = Reduce(graph()->NewNode(
493 machine()->Word32Xor(),
494 graph()->NewNode(machine()->Word32Xor(), p0, Int32Constant(-1)),
495 Int32Constant(-1)));
496 ASSERT_TRUE(r1.Changed());
497 EXPECT_EQ(r1.replacement(), p0);
498
499 // -1 ^ (x ^ -1) => x
500 Reduction r2 = Reduce(graph()->NewNode(
501 machine()->Word32Xor(), Int32Constant(-1),
502 graph()->NewNode(machine()->Word32Xor(), p0, Int32Constant(-1))));
503 ASSERT_TRUE(r2.Changed());
504 EXPECT_EQ(r2.replacement(), p0);
505
506 // (-1 ^ x) ^ -1 => x
507 Reduction r3 = Reduce(graph()->NewNode(
508 machine()->Word32Xor(),
509 graph()->NewNode(machine()->Word32Xor(), Int32Constant(-1), p0),
510 Int32Constant(-1)));
511 ASSERT_TRUE(r3.Changed());
512 EXPECT_EQ(r3.replacement(), p0);
513
514 // -1 ^ (-1 ^ x) => x
515 Reduction r4 = Reduce(graph()->NewNode(
516 machine()->Word32Xor(), Int32Constant(-1),
517 graph()->NewNode(machine()->Word32Xor(), Int32Constant(-1), p0)));
518 ASSERT_TRUE(r4.Changed());
519 EXPECT_EQ(r4.replacement(), p0);
520 }
521
522
523 // -----------------------------------------------------------------------------
485 // Word32Ror 524 // Word32Ror
486 525
487 526
488 TEST_F(MachineOperatorReducerTest, ReduceToWord32RorWithParameters) { 527 TEST_F(MachineOperatorReducerTest, ReduceToWord32RorWithParameters) {
489 Node* value = Parameter(0); 528 Node* value = Parameter(0);
490 Node* shift = Parameter(1); 529 Node* shift = Parameter(1);
491 Node* shl = graph()->NewNode(machine()->Word32Shl(), value, shift); 530 Node* shl = graph()->NewNode(machine()->Word32Shl(), value, shift);
492 Node* shr = graph()->NewNode( 531 Node* shr = graph()->NewNode(
493 machine()->Word32Shr(), value, 532 machine()->Word32Shr(), value,
494 graph()->NewNode(machine()->Int32Sub(), Int32Constant(32), shift)); 533 graph()->NewNode(machine()->Int32Sub(), Int32Constant(32), shift));
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 Reduction r = Reduce(node); 955 Reduction r = Reduce(node);
917 ASSERT_TRUE(r.Changed()); 956 ASSERT_TRUE(r.Changed());
918 EXPECT_THAT(r.replacement(), 957 EXPECT_THAT(r.replacement(),
919 IsStore(rep, base, index, value, effect, control)); 958 IsStore(rep, base, index, value, effect, control));
920 } 959 }
921 } 960 }
922 961
923 } // namespace compiler 962 } // namespace compiler
924 } // namespace internal 963 } // namespace internal
925 } // namespace v8 964 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/machine-operator-reducer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698