Chromium Code Reviews| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "src/base/adapters.h" | 7 #include "src/base/adapters.h" |
| 8 #include "src/compiler/instruction-selector-impl.h" | 8 #include "src/compiler/instruction-selector-impl.h" |
| 9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| (...skipping 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2065 return VisitBinop(selector, node, kX64Sub, cont); | 2065 return VisitBinop(selector, node, kX64Sub, cont); |
| 2066 default: | 2066 default: |
| 2067 break; | 2067 break; |
| 2068 } | 2068 } |
| 2069 } | 2069 } |
| 2070 } | 2070 } |
| 2071 break; | 2071 break; |
| 2072 case IrOpcode::kInt32Sub: | 2072 case IrOpcode::kInt32Sub: |
| 2073 return VisitWordCompare(selector, value, kX64Cmp32, cont); | 2073 return VisitWordCompare(selector, value, kX64Cmp32, cont); |
| 2074 case IrOpcode::kInt64Sub: | 2074 case IrOpcode::kInt64Sub: |
| 2075 return VisitWord64Compare(selector, value, cont); | 2075 return VisitWord64Compare(selector, value, cont); |
|
Jarin
2017/02/01 08:39:56
UNREACHABLE() ?
| |
| 2076 case IrOpcode::kWord32And: | 2076 case IrOpcode::kWord32And: |
| 2077 return VisitWordCompare(selector, value, kX64Test32, cont); | 2077 return VisitWordCompare(selector, value, kX64Test32, cont); |
| 2078 case IrOpcode::kWord64And: | 2078 case IrOpcode::kWord64And: |
| 2079 return VisitWordCompare(selector, value, kX64Test, cont); | 2079 return VisitWordCompare(selector, value, kX64Test, cont); |
|
Jarin
2017/02/01 08:39:56
UNREACHABLE() ?
| |
| 2080 default: | 2080 default: |
| 2081 break; | 2081 break; |
| 2082 } | 2082 } |
| 2083 } | 2083 } |
| 2084 | 2084 |
| 2085 // Branch could not be combined with a compare, emit compare against 0. | 2085 // Branch could not be combined with a compare, emit compare against 0. |
| 2086 VisitCompareZero(selector, value, kX64Cmp32, cont); | 2086 VisitCompareZero(selector, value, kX64Cmp32, cont); |
| 2087 } | 2087 } |
| 2088 | 2088 |
| 2089 } // namespace | 2089 } // namespace |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2148 // Generate a sequence of conditional jumps. | 2148 // Generate a sequence of conditional jumps. |
| 2149 return EmitLookupSwitch(sw, value_operand); | 2149 return EmitLookupSwitch(sw, value_operand); |
| 2150 } | 2150 } |
| 2151 | 2151 |
| 2152 | 2152 |
| 2153 void InstructionSelector::VisitWord32Equal(Node* const node) { | 2153 void InstructionSelector::VisitWord32Equal(Node* const node) { |
| 2154 Node* user = node; | 2154 Node* user = node; |
| 2155 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); | 2155 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); |
| 2156 Int32BinopMatcher m(user); | 2156 Int32BinopMatcher m(user); |
| 2157 if (m.right().Is(0)) { | 2157 if (m.right().Is(0)) { |
| 2158 Node* value = m.left().node(); | 2158 return VisitWordCompareZero(this, m.node(), m.left().node(), &cont); |
| 2159 | |
| 2160 // Try to combine with comparisons against 0 by simply inverting the branch. | |
| 2161 while (CanCover(user, value) && value->opcode() == IrOpcode::kWord32Equal) { | |
| 2162 Int32BinopMatcher m(value); | |
| 2163 if (m.right().Is(0)) { | |
| 2164 user = value; | |
| 2165 value = m.left().node(); | |
| 2166 cont.Negate(); | |
| 2167 } else { | |
| 2168 break; | |
| 2169 } | |
| 2170 } | |
| 2171 | |
| 2172 // Try to combine the branch with a comparison. | |
| 2173 if (CanCover(user, value)) { | |
| 2174 switch (value->opcode()) { | |
| 2175 case IrOpcode::kInt32Sub: | |
| 2176 return VisitWordCompare(this, value, kX64Cmp32, &cont); | |
| 2177 case IrOpcode::kWord32And: | |
| 2178 return VisitWordCompare(this, value, kX64Test32, &cont); | |
| 2179 default: | |
| 2180 break; | |
| 2181 } | |
| 2182 } | |
| 2183 return VisitCompareZero(this, value, kX64Cmp32, &cont); | |
| 2184 } | 2159 } |
| 2185 VisitWordCompare(this, node, kX64Cmp32, &cont); | 2160 VisitWordCompare(this, node, kX64Cmp32, &cont); |
| 2186 } | 2161 } |
| 2187 | 2162 |
| 2188 | 2163 |
| 2189 void InstructionSelector::VisitInt32LessThan(Node* node) { | 2164 void InstructionSelector::VisitInt32LessThan(Node* node) { |
| 2190 FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node); | 2165 FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node); |
| 2191 VisitWordCompare(this, node, kX64Cmp32, &cont); | 2166 VisitWordCompare(this, node, kX64Cmp32, &cont); |
| 2192 } | 2167 } |
| 2193 | 2168 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2481 // static | 2456 // static |
| 2482 MachineOperatorBuilder::AlignmentRequirements | 2457 MachineOperatorBuilder::AlignmentRequirements |
| 2483 InstructionSelector::AlignmentRequirements() { | 2458 InstructionSelector::AlignmentRequirements() { |
| 2484 return MachineOperatorBuilder::AlignmentRequirements:: | 2459 return MachineOperatorBuilder::AlignmentRequirements:: |
| 2485 FullUnalignedAccessSupport(); | 2460 FullUnalignedAccessSupport(); |
| 2486 } | 2461 } |
| 2487 | 2462 |
| 2488 } // namespace compiler | 2463 } // namespace compiler |
| 2489 } // namespace internal | 2464 } // namespace internal |
| 2490 } // namespace v8 | 2465 } // namespace v8 |
| OLD | NEW |