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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 | 7 |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
10 #include "src/compiler/control-reducer.h" | 10 #include "src/compiler/control-reducer.h" |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 TEST(CMergeReduce_edit_phi1) { | 765 TEST(CMergeReduce_edit_phi1) { |
766 ControlReducerTester R; | 766 ControlReducerTester R; |
767 | 767 |
768 for (int i = 0; i < 3; i++) { | 768 for (int i = 0; i < 3; i++) { |
769 Node* merge = R.graph.NewNode(R.common.Merge(3), R.start, R.start, R.start); | 769 Node* merge = R.graph.NewNode(R.common.Merge(3), R.start, R.start, R.start); |
770 merge->ReplaceInput(i, R.dead); | 770 merge->ReplaceInput(i, R.dead); |
771 Node* phi = R.graph.NewNode(R.common.Phi(kMachAnyTagged, 3), R.leaf[0], | 771 Node* phi = R.graph.NewNode(R.common.Phi(kMachAnyTagged, 3), R.leaf[0], |
772 R.leaf[1], R.leaf[2], merge); | 772 R.leaf[1], R.leaf[2], merge); |
773 R.ReduceMerge(merge, merge); | 773 R.ReduceMerge(merge, merge); |
774 CHECK_EQ(IrOpcode::kPhi, phi->opcode()); | 774 CHECK_EQ(IrOpcode::kPhi, phi->opcode()); |
775 CHECK_EQ(2, phi->op()->InputCount()); | 775 CHECK_EQ(2, phi->op()->ValueInputCount()); |
776 CHECK_EQ(3, phi->InputCount()); | 776 CHECK_EQ(3, phi->InputCount()); |
777 CHECK_EQ(R.leaf[i < 1 ? 1 : 0], phi->InputAt(0)); | 777 CHECK_EQ(R.leaf[i < 1 ? 1 : 0], phi->InputAt(0)); |
778 CHECK_EQ(R.leaf[i < 2 ? 2 : 1], phi->InputAt(1)); | 778 CHECK_EQ(R.leaf[i < 2 ? 2 : 1], phi->InputAt(1)); |
779 CHECK_EQ(merge, phi->InputAt(2)); | 779 CHECK_EQ(merge, phi->InputAt(2)); |
780 } | 780 } |
781 } | 781 } |
782 | 782 |
783 | 783 |
784 TEST(CMergeReduce_edit_effect_phi1) { | 784 TEST(CMergeReduce_edit_effect_phi1) { |
785 ControlReducerTester R; | 785 ControlReducerTester R; |
786 | 786 |
787 for (int i = 0; i < 3; i++) { | 787 for (int i = 0; i < 3; i++) { |
788 Node* merge = R.graph.NewNode(R.common.Merge(3), R.start, R.start, R.start); | 788 Node* merge = R.graph.NewNode(R.common.Merge(3), R.start, R.start, R.start); |
789 merge->ReplaceInput(i, R.dead); | 789 merge->ReplaceInput(i, R.dead); |
790 Node* phi = R.graph.NewNode(R.common.EffectPhi(3), R.leaf[0], R.leaf[1], | 790 Node* phi = R.graph.NewNode(R.common.EffectPhi(3), R.leaf[0], R.leaf[1], |
791 R.leaf[2], merge); | 791 R.leaf[2], merge); |
792 R.ReduceMerge(merge, merge); | 792 R.ReduceMerge(merge, merge); |
793 CHECK_EQ(IrOpcode::kEffectPhi, phi->opcode()); | 793 CHECK_EQ(IrOpcode::kEffectPhi, phi->opcode()); |
794 CHECK_EQ(0, phi->op()->InputCount()); | 794 CHECK_EQ(0, phi->op()->ValueInputCount()); |
795 CHECK_EQ(2, phi->op()->EffectInputCount()); | 795 CHECK_EQ(2, phi->op()->EffectInputCount()); |
796 CHECK_EQ(3, phi->InputCount()); | 796 CHECK_EQ(3, phi->InputCount()); |
797 CHECK_EQ(R.leaf[i < 1 ? 1 : 0], phi->InputAt(0)); | 797 CHECK_EQ(R.leaf[i < 1 ? 1 : 0], phi->InputAt(0)); |
798 CHECK_EQ(R.leaf[i < 2 ? 2 : 1], phi->InputAt(1)); | 798 CHECK_EQ(R.leaf[i < 2 ? 2 : 1], phi->InputAt(1)); |
799 CHECK_EQ(merge, phi->InputAt(2)); | 799 CHECK_EQ(merge, phi->InputAt(2)); |
800 } | 800 } |
801 } | 801 } |
802 | 802 |
803 | 803 |
804 static const int kSelectorSize = 4; | 804 static const int kSelectorSize = 4; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 CHECK_EQ(values[selector.single_index()], phi_use->InputAt(0)); | 876 CHECK_EQ(values[selector.single_index()], phi_use->InputAt(0)); |
877 CHECK_EQ(effects[selector.single_index()], ephi_use->InputAt(0)); | 877 CHECK_EQ(effects[selector.single_index()], ephi_use->InputAt(0)); |
878 } else { | 878 } else { |
879 // Otherwise, nodes should be edited in place. | 879 // Otherwise, nodes should be edited in place. |
880 CHECK_EQ(merge, result); | 880 CHECK_EQ(merge, result); |
881 selector.CheckNode(merge, IrOpcode::kMerge, controls, NULL); | 881 selector.CheckNode(merge, IrOpcode::kMerge, controls, NULL); |
882 selector.CheckNode(phi, IrOpcode::kPhi, values, merge); | 882 selector.CheckNode(phi, IrOpcode::kPhi, values, merge); |
883 selector.CheckNode(ephi, IrOpcode::kEffectPhi, effects, merge); | 883 selector.CheckNode(ephi, IrOpcode::kEffectPhi, effects, merge); |
884 CHECK_EQ(phi, phi_use->InputAt(0)); | 884 CHECK_EQ(phi, phi_use->InputAt(0)); |
885 CHECK_EQ(ephi, ephi_use->InputAt(0)); | 885 CHECK_EQ(ephi, ephi_use->InputAt(0)); |
886 CHECK_EQ(count, phi->op()->InputCount()); | 886 CHECK_EQ(count, phi->op()->ValueInputCount()); |
887 CHECK_EQ(count + 1, phi->InputCount()); | 887 CHECK_EQ(count + 1, phi->InputCount()); |
888 CHECK_EQ(count, ephi->op()->EffectInputCount()); | 888 CHECK_EQ(count, ephi->op()->EffectInputCount()); |
889 CHECK_EQ(count + 1, ephi->InputCount()); | 889 CHECK_EQ(count + 1, ephi->InputCount()); |
890 } | 890 } |
891 } | 891 } |
892 } | 892 } |
893 | 893 |
894 | 894 |
895 TEST(CMergeReduce_edit_many_phis1) { | 895 TEST(CMergeReduce_edit_many_phis1) { |
896 ControlReducerTester R; | 896 ControlReducerTester R; |
897 | 897 |
898 const int kPhiCount = 10; | 898 const int kPhiCount = 10; |
899 Node* phis[kPhiCount]; | 899 Node* phis[kPhiCount]; |
900 | 900 |
901 for (int i = 0; i < 3; i++) { | 901 for (int i = 0; i < 3; i++) { |
902 Node* merge = R.graph.NewNode(R.common.Merge(3), R.start, R.start, R.start); | 902 Node* merge = R.graph.NewNode(R.common.Merge(3), R.start, R.start, R.start); |
903 merge->ReplaceInput(i, R.dead); | 903 merge->ReplaceInput(i, R.dead); |
904 for (int j = 0; j < kPhiCount; j++) { | 904 for (int j = 0; j < kPhiCount; j++) { |
905 phis[j] = R.graph.NewNode(R.common.Phi(kMachAnyTagged, 3), R.leaf[0], | 905 phis[j] = R.graph.NewNode(R.common.Phi(kMachAnyTagged, 3), R.leaf[0], |
906 R.leaf[1], R.leaf[2], merge); | 906 R.leaf[1], R.leaf[2], merge); |
907 } | 907 } |
908 R.ReduceMerge(merge, merge); | 908 R.ReduceMerge(merge, merge); |
909 for (int j = 0; j < kPhiCount; j++) { | 909 for (int j = 0; j < kPhiCount; j++) { |
910 Node* phi = phis[j]; | 910 Node* phi = phis[j]; |
911 CHECK_EQ(IrOpcode::kPhi, phi->opcode()); | 911 CHECK_EQ(IrOpcode::kPhi, phi->opcode()); |
912 CHECK_EQ(2, phi->op()->InputCount()); | 912 CHECK_EQ(2, phi->op()->ValueInputCount()); |
913 CHECK_EQ(3, phi->InputCount()); | 913 CHECK_EQ(3, phi->InputCount()); |
914 CHECK_EQ(R.leaf[i < 1 ? 1 : 0], phi->InputAt(0)); | 914 CHECK_EQ(R.leaf[i < 1 ? 1 : 0], phi->InputAt(0)); |
915 CHECK_EQ(R.leaf[i < 2 ? 2 : 1], phi->InputAt(1)); | 915 CHECK_EQ(R.leaf[i < 2 ? 2 : 1], phi->InputAt(1)); |
916 CHECK_EQ(merge, phi->InputAt(2)); | 916 CHECK_EQ(merge, phi->InputAt(2)); |
917 } | 917 } |
918 } | 918 } |
919 } | 919 } |
920 | 920 |
921 | 921 |
922 TEST(CMergeReduce_simple_chain1) { | 922 TEST(CMergeReduce_simple_chain1) { |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 | 1672 |
1673 Node* ret = R.Return(d1.phi, R.start, d1.merge); | 1673 Node* ret = R.Return(d1.phi, R.start, d1.merge); |
1674 | 1674 |
1675 R.ReduceGraph(); // d1 gets folded true. | 1675 R.ReduceGraph(); // d1 gets folded true. |
1676 | 1676 |
1677 CheckInputs(ret, y2, R.start, R.start); | 1677 CheckInputs(ret, y2, R.start, R.start); |
1678 CheckDeadDiamond(d1); | 1678 CheckDeadDiamond(d1); |
1679 CheckDeadDiamond(d2); | 1679 CheckDeadDiamond(d2); |
1680 CheckDeadDiamond(d3); | 1680 CheckDeadDiamond(d3); |
1681 } | 1681 } |
OLD | NEW |