| 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/compiler/instruction-selector-impl.h" | 5 #include "src/compiler/instruction-selector-impl.h" |
| 6 #include "src/compiler/node-matchers.h" | 6 #include "src/compiler/node-matchers.h" |
| 7 #include "src/compiler/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 | 1243 |
| 1244 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, | 1244 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, |
| 1245 BasicBlock* fbranch) { | 1245 BasicBlock* fbranch) { |
| 1246 OperandGenerator g(this); | 1246 OperandGenerator g(this); |
| 1247 Node* user = branch; | 1247 Node* user = branch; |
| 1248 Node* value = branch->InputAt(0); | 1248 Node* value = branch->InputAt(0); |
| 1249 | 1249 |
| 1250 FlagsContinuation cont(kNotEqual, tbranch, fbranch); | 1250 FlagsContinuation cont(kNotEqual, tbranch, fbranch); |
| 1251 | 1251 |
| 1252 // Try to combine with comparisons against 0 by simply inverting the branch. | 1252 // Try to combine with comparisons against 0 by simply inverting the branch. |
| 1253 while (CanCover(user, value)) { | 1253 while (CanCover(user, value) && value->opcode() == IrOpcode::kWord32Equal) { |
| 1254 if (value->opcode() == IrOpcode::kWord32Equal) { | 1254 Int32BinopMatcher m(value); |
| 1255 Int32BinopMatcher m(value); | 1255 if (m.right().Is(0)) { |
| 1256 if (m.right().Is(0)) { | 1256 user = value; |
| 1257 user = value; | 1257 value = m.left().node(); |
| 1258 value = m.left().node(); | 1258 cont.Negate(); |
| 1259 cont.Negate(); | |
| 1260 } else { | |
| 1261 break; | |
| 1262 } | |
| 1263 } else if (value->opcode() == IrOpcode::kWord64Equal) { | |
| 1264 Int64BinopMatcher m(value); | |
| 1265 if (m.right().Is(0)) { | |
| 1266 user = value; | |
| 1267 value = m.left().node(); | |
| 1268 cont.Negate(); | |
| 1269 } else { | |
| 1270 break; | |
| 1271 } | |
| 1272 } else { | 1259 } else { |
| 1273 break; | 1260 break; |
| 1274 } | 1261 } |
| 1275 } | 1262 } |
| 1276 | 1263 |
| 1277 // Try to combine the branch with a comparison. | 1264 // Try to combine the branch with a comparison. |
| 1278 if (CanCover(user, value)) { | 1265 if (CanCover(user, value)) { |
| 1279 switch (value->opcode()) { | 1266 switch (value->opcode()) { |
| 1280 case IrOpcode::kWord32Equal: | 1267 case IrOpcode::kWord32Equal: |
| 1281 cont.OverwriteAndNegateIfEqual(kEqual); | 1268 cont.OverwriteAndNegateIfEqual(kEqual); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1597 MachineOperatorBuilder::kFloat64RoundTruncate | | 1584 MachineOperatorBuilder::kFloat64RoundTruncate | |
| 1598 MachineOperatorBuilder::kFloat64RoundTiesAway | | 1585 MachineOperatorBuilder::kFloat64RoundTiesAway | |
| 1599 MachineOperatorBuilder::kWord32ShiftIsSafe | | 1586 MachineOperatorBuilder::kWord32ShiftIsSafe | |
| 1600 MachineOperatorBuilder::kInt32DivIsSafe | | 1587 MachineOperatorBuilder::kInt32DivIsSafe | |
| 1601 MachineOperatorBuilder::kUint32DivIsSafe; | 1588 MachineOperatorBuilder::kUint32DivIsSafe; |
| 1602 } | 1589 } |
| 1603 | 1590 |
| 1604 } // namespace compiler | 1591 } // namespace compiler |
| 1605 } // namespace internal | 1592 } // namespace internal |
| 1606 } // namespace v8 | 1593 } // namespace v8 |
| OLD | NEW |