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

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

Issue 598083007: [turbofan] Reduce shl with sar/shr and same shift amount to bit-and. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: file naming. 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') | test/mjsunit/asm/int32array-unaligned.js » ('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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 Reduction reduction = Reduce(node); 514 Reduction reduction = Reduce(node);
515 EXPECT_TRUE(reduction.Changed()); 515 EXPECT_TRUE(reduction.Changed());
516 EXPECT_THAT(reduction.replacement(), 516 EXPECT_THAT(reduction.replacement(),
517 IsInt32Constant(base::bits::RotateRight32(x, y))); 517 IsInt32Constant(base::bits::RotateRight32(x, y)));
518 } 518 }
519 } 519 }
520 } 520 }
521 521
522 522
523 // ----------------------------------------------------------------------------- 523 // -----------------------------------------------------------------------------
524 // Word32Shl
525
526
527 TEST_F(MachineOperatorReducerTest, Word32ShlWithZeroShift) {
528 Node* p0 = Parameter(0);
529 Node* node = graph()->NewNode(machine()->Word32Shl(), p0, Int32Constant(0));
530 Reduction r = Reduce(node);
531 ASSERT_TRUE(r.Changed());
532 EXPECT_EQ(p0, r.replacement());
533 }
534
535
536 TEST_F(MachineOperatorReducerTest, Word32ShlWithWord32Sar) {
537 Node* p0 = Parameter(0);
538 TRACED_FORRANGE(int32_t, x, 1, 31) {
539 Node* node = graph()->NewNode(
540 machine()->Word32Shl(),
541 graph()->NewNode(machine()->Word32Sar(), p0, Int32Constant(x)),
542 Int32Constant(x));
543 Reduction r = Reduce(node);
544 ASSERT_TRUE(r.Changed());
545 int32_t m = bit_cast<int32_t>(~((1U << x) - 1U));
546 EXPECT_THAT(r.replacement(), IsWord32And(p0, IsInt32Constant(m)));
547 }
548 }
549
550
551 TEST_F(MachineOperatorReducerTest, Word32ShlWithWord32Shr) {
552 Node* p0 = Parameter(0);
553 TRACED_FORRANGE(int32_t, x, 1, 31) {
554 Node* node = graph()->NewNode(
555 machine()->Word32Shl(),
556 graph()->NewNode(machine()->Word32Shr(), p0, Int32Constant(x)),
557 Int32Constant(x));
558 Reduction r = Reduce(node);
559 ASSERT_TRUE(r.Changed());
560 int32_t m = bit_cast<int32_t>(~((1U << x) - 1U));
561 EXPECT_THAT(r.replacement(), IsWord32And(p0, IsInt32Constant(m)));
562 }
563 }
564
565
566 // -----------------------------------------------------------------------------
524 // Int32AddWithOverflow 567 // Int32AddWithOverflow
525 568
526 569
527 TEST_F(MachineOperatorReducerTest, Int32AddWithOverflowWithZero) { 570 TEST_F(MachineOperatorReducerTest, Int32AddWithOverflowWithZero) {
528 Node* p0 = Parameter(0); 571 Node* p0 = Parameter(0);
529 { 572 {
530 Node* add = graph()->NewNode(machine()->Int32AddWithOverflow(), 573 Node* add = graph()->NewNode(machine()->Int32AddWithOverflow(),
531 Int32Constant(0), p0); 574 Int32Constant(0), p0);
532 575
533 Reduction r = Reduce(graph()->NewNode(common()->Projection(1), add)); 576 Reduction r = Reduce(graph()->NewNode(common()->Projection(1), add));
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 r = Reduce(graph()->NewNode(common()->Projection(0), add)); 650 r = Reduce(graph()->NewNode(common()->Projection(0), add));
608 ASSERT_TRUE(r.Changed()); 651 ASSERT_TRUE(r.Changed());
609 EXPECT_THAT(r.replacement(), IsInt32Constant(z)); 652 EXPECT_THAT(r.replacement(), IsInt32Constant(z));
610 } 653 }
611 } 654 }
612 } 655 }
613 656
614 } // namespace compiler 657 } // namespace compiler
615 } // namespace internal 658 } // namespace internal
616 } // namespace v8 659 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/machine-operator-reducer.cc ('k') | test/mjsunit/asm/int32array-unaligned.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698