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/simplified-operator-reducer.h" | 5 #include "src/compiler/simplified-operator-reducer.h" |
6 | 6 |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/machine-operator.h" | 8 #include "src/compiler/machine-operator.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/operator-properties.h" | 10 #include "src/compiler/operator-properties.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 return Change(node, machine()->ChangeFloat64ToUint32(), m.InputAt(0)); | 82 return Change(node, machine()->ChangeFloat64ToUint32(), m.InputAt(0)); |
83 } | 83 } |
84 if (m.IsChangeUint32ToTagged()) return Replace(m.InputAt(0)); | 84 if (m.IsChangeUint32ToTagged()) return Replace(m.InputAt(0)); |
85 break; | 85 break; |
86 } | 86 } |
87 case IrOpcode::kChangeUint32ToTagged: { | 87 case IrOpcode::kChangeUint32ToTagged: { |
88 Uint32Matcher m(node->InputAt(0)); | 88 Uint32Matcher m(node->InputAt(0)); |
89 if (m.HasValue()) return ReplaceNumber(FastUI2D(m.Value())); | 89 if (m.HasValue()) return ReplaceNumber(FastUI2D(m.Value())); |
90 break; | 90 break; |
91 } | 91 } |
| 92 case IrOpcode::kNumberCeil: |
92 case IrOpcode::kNumberFloor: | 93 case IrOpcode::kNumberFloor: |
93 return ReduceNumberFloor(node); | 94 case IrOpcode::kNumberRound: |
| 95 case IrOpcode::kNumberTrunc: { |
| 96 Node* const input = NodeProperties::GetValueInput(node, 0); |
| 97 Type* const input_type = NodeProperties::GetType(input); |
| 98 if (input_type->Is(type_cache_.kIntegerOrMinusZeroOrNaN)) { |
| 99 return Replace(input); |
| 100 } |
| 101 break; |
| 102 } |
94 case IrOpcode::kReferenceEqual: | 103 case IrOpcode::kReferenceEqual: |
95 return ReduceReferenceEqual(node); | 104 return ReduceReferenceEqual(node); |
96 default: | 105 default: |
97 break; | 106 break; |
98 } | 107 } |
99 return NoChange(); | 108 return NoChange(); |
100 } | 109 } |
101 | 110 |
102 Reduction SimplifiedOperatorReducer::ReduceNumberFloor(Node* node) { | |
103 DCHECK_EQ(IrOpcode::kNumberFloor, node->opcode()); | |
104 Node* const input = NodeProperties::GetValueInput(node, 0); | |
105 Type* const input_type = NodeProperties::GetType(input); | |
106 if (input_type->Is(type_cache_.kIntegerOrMinusZeroOrNaN)) { | |
107 return Replace(input); | |
108 } | |
109 return NoChange(); | |
110 } | |
111 | |
112 Reduction SimplifiedOperatorReducer::ReduceReferenceEqual(Node* node) { | 111 Reduction SimplifiedOperatorReducer::ReduceReferenceEqual(Node* node) { |
113 DCHECK_EQ(IrOpcode::kReferenceEqual, node->opcode()); | 112 DCHECK_EQ(IrOpcode::kReferenceEqual, node->opcode()); |
114 Node* const left = NodeProperties::GetValueInput(node, 0); | 113 Node* const left = NodeProperties::GetValueInput(node, 0); |
115 Node* const right = NodeProperties::GetValueInput(node, 1); | 114 Node* const right = NodeProperties::GetValueInput(node, 1); |
116 HeapObjectMatcher match_left(left); | 115 HeapObjectMatcher match_left(left); |
117 HeapObjectMatcher match_right(right); | 116 HeapObjectMatcher match_right(right); |
118 if (match_left.HasValue() && match_right.HasValue()) { | 117 if (match_left.HasValue() && match_right.HasValue()) { |
119 if (match_left.Value().is_identical_to(match_right.Value())) { | 118 if (match_left.Value().is_identical_to(match_right.Value())) { |
120 return Replace(jsgraph()->TrueConstant()); | 119 return Replace(jsgraph()->TrueConstant()); |
121 } else { | 120 } else { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); } | 158 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); } |
160 | 159 |
161 | 160 |
162 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { | 161 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { |
163 return jsgraph()->machine(); | 162 return jsgraph()->machine(); |
164 } | 163 } |
165 | 164 |
166 } // namespace compiler | 165 } // namespace compiler |
167 } // namespace internal | 166 } // namespace internal |
168 } // namespace v8 | 167 } // namespace v8 |
OLD | NEW |