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

Side by Side Diff: src/compiler/mips/instruction-selector-mips.cc

Issue 1019463003: MIPS: Tweak constants to be in favor of table switch. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | src/compiler/mips64/instruction-selector-mips64.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/instruction-selector-impl.h" 6 #include "src/compiler/instruction-selector-impl.h"
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 #include "src/compiler/node-properties.h" 8 #include "src/compiler/node-properties.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 InstructionOperand default_operand = g.Label(default_branch); 777 InstructionOperand default_operand = g.Label(default_branch);
778 778
779 // Note that {value_range} can be 0 if {min_value} is -2^31 and {max_value} 779 // Note that {value_range} can be 0 if {min_value} is -2^31 and {max_value}
780 // is 2^31-1, so don't assume that it's non-zero below. 780 // is 2^31-1, so don't assume that it's non-zero below.
781 size_t value_range = 781 size_t value_range =
782 1u + bit_cast<uint32_t>(max_value) - bit_cast<uint32_t>(min_value); 782 1u + bit_cast<uint32_t>(max_value) - bit_cast<uint32_t>(min_value);
783 783
784 // Determine whether to issue an ArchTableSwitch or an ArchLookupSwitch 784 // Determine whether to issue an ArchTableSwitch or an ArchLookupSwitch
785 // instruction. 785 // instruction.
786 size_t table_space_cost = 9 + value_range; 786 size_t table_space_cost = 9 + value_range;
787 size_t table_time_cost = 9; 787 size_t table_time_cost = 3;
788 size_t lookup_space_cost = 2 + 2 * case_count; 788 size_t lookup_space_cost = 2 + 2 * case_count;
789 size_t lookup_time_cost = case_count; 789 size_t lookup_time_cost = case_count;
790 if (case_count > 0 && 790 if (case_count > 0 &&
791 table_space_cost + 3 * table_time_cost <= 791 table_space_cost + 3 * table_time_cost <=
792 lookup_space_cost + 3 * lookup_time_cost && 792 lookup_space_cost + 3 * lookup_time_cost &&
793 min_value > std::numeric_limits<int32_t>::min()) { 793 min_value > std::numeric_limits<int32_t>::min()) {
794 InstructionOperand index_operand = value_operand; 794 InstructionOperand index_operand = value_operand;
795 if (min_value) { 795 if (min_value) {
796 index_operand = g.TempRegister(); 796 index_operand = g.TempRegister();
797 Emit(kMipsSub, index_operand, value_operand, g.TempImmediate(min_value)); 797 Emit(kMipsSub, index_operand, value_operand, g.TempImmediate(min_value));
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) { 938 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
939 return MachineOperatorBuilder::kFloat64RoundDown | 939 return MachineOperatorBuilder::kFloat64RoundDown |
940 MachineOperatorBuilder::kFloat64RoundTruncate; 940 MachineOperatorBuilder::kFloat64RoundTruncate;
941 } 941 }
942 return MachineOperatorBuilder::kNoFlags; 942 return MachineOperatorBuilder::kNoFlags;
943 } 943 }
944 944
945 } // namespace compiler 945 } // namespace compiler
946 } // namespace internal 946 } // namespace internal
947 } // namespace v8 947 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/mips64/instruction-selector-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698