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

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

Issue 599383002: [turbofan] add some simplifications in the machine operator reducer (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review fix 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 "test/cctest/cctest.h" 5 #include "test/cctest/cctest.h"
6 6
7 #include "src/base/utils/random-number-generator.h" 7 #include "src/base/utils/random-number-generator.h"
8 #include "src/compiler/graph-inl.h" 8 #include "src/compiler/graph-inl.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/machine-operator-reducer.h" 10 #include "src/compiler/machine-operator-reducer.h"
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 680
681 static void CheckNans(ReducerTester* R) { 681 static void CheckNans(ReducerTester* R) {
682 Node* x = R->Parameter(); 682 Node* x = R->Parameter();
683 std::vector<double> nans = ValueHelper::nan_vector(); 683 std::vector<double> nans = ValueHelper::nan_vector();
684 for (std::vector<double>::const_iterator pl = nans.begin(); pl != nans.end(); 684 for (std::vector<double>::const_iterator pl = nans.begin(); pl != nans.end();
685 ++pl) { 685 ++pl) {
686 for (std::vector<double>::const_iterator pr = nans.begin(); 686 for (std::vector<double>::const_iterator pr = nans.begin();
687 pr != nans.end(); ++pr) { 687 pr != nans.end(); ++pr) {
688 Node* nan1 = R->Constant<double>(*pl); 688 Node* nan1 = R->Constant<double>(*pl);
689 Node* nan2 = R->Constant<double>(*pr); 689 Node* nan2 = R->Constant<double>(*pr);
690 R->CheckBinop(nan1, x, nan1); // x % NaN => NaN 690 R->CheckBinop(nan1, x, nan1); // x op NaN => NaN
691 R->CheckBinop(nan1, nan1, x); // NaN % x => NaN 691 R->CheckBinop(nan1, nan1, x); // NaN op x => NaN
692 R->CheckBinop(nan1, nan2, nan1); // NaN % NaN => NaN 692 R->CheckBinop(nan1, nan2, nan1); // NaN op NaN => NaN
693 } 693 }
694 } 694 }
695 } 695 }
696 696
697 697
698 TEST(ReduceFloat64Add) { 698 TEST(ReduceFloat64Add) {
699 ReducerTester R; 699 ReducerTester R;
700 R.binop = R.machine.Float64Add(); 700 R.binop = R.machine.Float64Add();
701 701
702 FOR_FLOAT64_INPUTS(pl) { 702 FOR_FLOAT64_INPUTS(pl) {
703 FOR_FLOAT64_INPUTS(pr) { 703 FOR_FLOAT64_INPUTS(pr) {
704 double x = *pl, y = *pr; 704 double x = *pl, y = *pr;
705 R.CheckFoldBinop<double>(x + y, x, y); 705 R.CheckFoldBinop<double>(x + y, x, y);
706 } 706 }
707 } 707 }
708 708
709 FOR_FLOAT64_INPUTS(i) { R.CheckPutConstantOnRight(*i); } 709 FOR_FLOAT64_INPUTS(i) {
710 // TODO(titzer): CheckNans(&R); 710 Double tmp(*i);
711 if (!tmp.IsSpecial() || tmp.IsInfinite()) {
712 // Don't check NaNs as they are reduced more.
713 R.CheckPutConstantOnRight(*i);
714 }
715 }
716
717 CheckNans(&R);
711 } 718 }
712 719
713 720
714 TEST(ReduceFloat64Sub) { 721 TEST(ReduceFloat64Sub) {
715 ReducerTester R; 722 ReducerTester R;
716 R.binop = R.machine.Float64Sub(); 723 R.binop = R.machine.Float64Sub();
717 724
718 FOR_FLOAT64_INPUTS(pl) { 725 FOR_FLOAT64_INPUTS(pl) {
719 FOR_FLOAT64_INPUTS(pr) { 726 FOR_FLOAT64_INPUTS(pr) {
720 double x = *pl, y = *pr; 727 double x = *pl, y = *pr;
721 R.CheckFoldBinop<double>(x - y, x, y); 728 R.CheckFoldBinop<double>(x - y, x, y);
722 } 729 }
723 } 730 }
724 // TODO(titzer): CheckNans(&R); 731
732 Node* zero = R.Constant<double>(0.0);
733 Node* x = R.Parameter();
734
735 R.CheckBinop(x, x, zero); // x - 0.0 => x
736
737 CheckNans(&R);
725 } 738 }
726 739
727 740
728 TEST(ReduceFloat64Mul) { 741 TEST(ReduceFloat64Mul) {
729 ReducerTester R; 742 ReducerTester R;
730 R.binop = R.machine.Float64Mul(); 743 R.binop = R.machine.Float64Mul();
731 744
732 FOR_FLOAT64_INPUTS(pl) { 745 FOR_FLOAT64_INPUTS(pl) {
733 FOR_FLOAT64_INPUTS(pr) { 746 FOR_FLOAT64_INPUTS(pr) {
734 double x = *pl, y = *pr; 747 double x = *pl, y = *pr;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 ReducerTester R; 789 ReducerTester R;
777 R.binop = R.machine.Float64Mod(); 790 R.binop = R.machine.Float64Mod();
778 791
779 FOR_FLOAT64_INPUTS(pl) { 792 FOR_FLOAT64_INPUTS(pl) {
780 FOR_FLOAT64_INPUTS(pr) { 793 FOR_FLOAT64_INPUTS(pr) {
781 double x = *pl, y = *pr; 794 double x = *pl, y = *pr;
782 R.CheckFoldBinop<double>(modulo(x, y), x, y); 795 R.CheckFoldBinop<double>(modulo(x, y), x, y);
783 } 796 }
784 } 797 }
785 798
799 Node* x = R.Parameter();
800 Node* zero = R.Constant<double>(0.0);
801
802 R.CheckFoldBinop<double>(v8::base::OS::nan_value(), x, zero);
803
786 CheckNans(&R); 804 CheckNans(&R);
787 } 805 }
788 806
789 807
790 // TODO(titzer): test MachineOperatorReducer for Word64And 808 // TODO(titzer): test MachineOperatorReducer for Word64And
791 // TODO(titzer): test MachineOperatorReducer for Word64Or 809 // TODO(titzer): test MachineOperatorReducer for Word64Or
792 // TODO(titzer): test MachineOperatorReducer for Word64Xor 810 // TODO(titzer): test MachineOperatorReducer for Word64Xor
793 // TODO(titzer): test MachineOperatorReducer for Word64Shl 811 // TODO(titzer): test MachineOperatorReducer for Word64Shl
794 // TODO(titzer): test MachineOperatorReducer for Word64Shr 812 // TODO(titzer): test MachineOperatorReducer for Word64Shr
795 // TODO(titzer): test MachineOperatorReducer for Word64Sar 813 // TODO(titzer): test MachineOperatorReducer for Word64Sar
796 // TODO(titzer): test MachineOperatorReducer for Word64Equal 814 // TODO(titzer): test MachineOperatorReducer for Word64Equal
797 // TODO(titzer): test MachineOperatorReducer for Word64Not 815 // TODO(titzer): test MachineOperatorReducer for Word64Not
798 // TODO(titzer): test MachineOperatorReducer for Int64Add 816 // TODO(titzer): test MachineOperatorReducer for Int64Add
799 // TODO(titzer): test MachineOperatorReducer for Int64Sub 817 // TODO(titzer): test MachineOperatorReducer for Int64Sub
800 // TODO(titzer): test MachineOperatorReducer for Int64Mul 818 // TODO(titzer): test MachineOperatorReducer for Int64Mul
801 // TODO(titzer): test MachineOperatorReducer for Int64UMul 819 // TODO(titzer): test MachineOperatorReducer for Int64UMul
802 // TODO(titzer): test MachineOperatorReducer for Int64Div 820 // TODO(titzer): test MachineOperatorReducer for Int64Div
803 // TODO(titzer): test MachineOperatorReducer for Int64UDiv 821 // TODO(titzer): test MachineOperatorReducer for Int64UDiv
804 // TODO(titzer): test MachineOperatorReducer for Int64Mod 822 // TODO(titzer): test MachineOperatorReducer for Int64Mod
805 // TODO(titzer): test MachineOperatorReducer for Int64UMod 823 // TODO(titzer): test MachineOperatorReducer for Int64UMod
806 // TODO(titzer): test MachineOperatorReducer for Int64Neg 824 // TODO(titzer): test MachineOperatorReducer for Int64Neg
807 // TODO(titzer): test MachineOperatorReducer for ChangeInt32ToFloat64 825 // TODO(titzer): test MachineOperatorReducer for ChangeInt32ToFloat64
808 // TODO(titzer): test MachineOperatorReducer for ChangeFloat64ToInt32 826 // TODO(titzer): test MachineOperatorReducer for ChangeFloat64ToInt32
809 // TODO(titzer): test MachineOperatorReducer for Float64Compare 827 // TODO(titzer): test MachineOperatorReducer for Float64Compare
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