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/compiler/instruction-selector-impl.h" | 7 #include "src/compiler/instruction-selector-impl.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 | 10 |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 | 1061 |
1062 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, | 1062 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, |
1063 BasicBlock* fbranch) { | 1063 BasicBlock* fbranch) { |
1064 X64OperandGenerator g(this); | 1064 X64OperandGenerator g(this); |
1065 Node* user = branch; | 1065 Node* user = branch; |
1066 Node* value = branch->InputAt(0); | 1066 Node* value = branch->InputAt(0); |
1067 | 1067 |
1068 FlagsContinuation cont(kNotEqual, tbranch, fbranch); | 1068 FlagsContinuation cont(kNotEqual, tbranch, fbranch); |
1069 | 1069 |
1070 // Try to combine with comparisons against 0 by simply inverting the branch. | 1070 // Try to combine with comparisons against 0 by simply inverting the branch. |
1071 while (CanCover(user, value)) { | 1071 while (CanCover(user, value) && value->opcode() == IrOpcode::kWord32Equal) { |
1072 if (value->opcode() == IrOpcode::kWord32Equal) { | 1072 Int32BinopMatcher m(value); |
1073 Int32BinopMatcher m(value); | 1073 if (m.right().Is(0)) { |
1074 if (m.right().Is(0)) { | 1074 user = value; |
1075 user = value; | 1075 value = m.left().node(); |
1076 value = m.left().node(); | 1076 cont.Negate(); |
1077 cont.Negate(); | |
1078 } else { | |
1079 break; | |
1080 } | |
1081 } else if (value->opcode() == IrOpcode::kWord64Equal) { | |
1082 Int64BinopMatcher m(value); | |
1083 if (m.right().Is(0)) { | |
1084 user = value; | |
1085 value = m.left().node(); | |
1086 cont.Negate(); | |
1087 } else { | |
1088 break; | |
1089 } | |
1090 } else { | 1077 } else { |
1091 break; | 1078 break; |
1092 } | 1079 } |
1093 } | 1080 } |
1094 | 1081 |
1095 // Try to combine the branch with a comparison. | 1082 // Try to combine the branch with a comparison. |
1096 if (CanCover(user, value)) { | 1083 if (CanCover(user, value)) { |
1097 switch (value->opcode()) { | 1084 switch (value->opcode()) { |
1098 case IrOpcode::kWord32Equal: | 1085 case IrOpcode::kWord32Equal: |
1099 cont.OverwriteAndNegateIfEqual(kEqual); | 1086 cont.OverwriteAndNegateIfEqual(kEqual); |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 MachineOperatorBuilder::kFloat64Ceil | | 1385 MachineOperatorBuilder::kFloat64Ceil | |
1399 MachineOperatorBuilder::kFloat64RoundTruncate | | 1386 MachineOperatorBuilder::kFloat64RoundTruncate | |
1400 MachineOperatorBuilder::kWord32ShiftIsSafe; | 1387 MachineOperatorBuilder::kWord32ShiftIsSafe; |
1401 } | 1388 } |
1402 return MachineOperatorBuilder::kNoFlags; | 1389 return MachineOperatorBuilder::kNoFlags; |
1403 } | 1390 } |
1404 | 1391 |
1405 } // namespace compiler | 1392 } // namespace compiler |
1406 } // namespace internal | 1393 } // namespace internal |
1407 } // namespace v8 | 1394 } // namespace v8 |
OLD | NEW |