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

Side by Side Diff: src/compiler/simplified-operator-reducer.cc

Issue 1843533003: [turbofan] Introduce NumberFloor simplified operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 | « src/compiler/simplified-operator-reducer.h ('k') | src/compiler/typer.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/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"
11 #include "src/conversions-inl.h" 11 #include "src/conversions-inl.h"
12 #include "src/type-cache.h"
12 13
13 namespace v8 { 14 namespace v8 {
14 namespace internal { 15 namespace internal {
15 namespace compiler { 16 namespace compiler {
16 17
17 SimplifiedOperatorReducer::SimplifiedOperatorReducer(JSGraph* jsgraph) 18 SimplifiedOperatorReducer::SimplifiedOperatorReducer(JSGraph* jsgraph)
18 : jsgraph_(jsgraph) {} 19 : jsgraph_(jsgraph), type_cache_(TypeCache::Get()) {}
19
20 20
21 SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {} 21 SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {}
22 22
23 23
24 Reduction SimplifiedOperatorReducer::Reduce(Node* node) { 24 Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
25 switch (node->opcode()) { 25 switch (node->opcode()) {
26 case IrOpcode::kBooleanNot: { 26 case IrOpcode::kBooleanNot: {
27 HeapObjectMatcher m(node->InputAt(0)); 27 HeapObjectMatcher m(node->InputAt(0));
28 if (m.HasValue()) { 28 if (m.HasValue()) {
29 return Replace(jsgraph()->BooleanConstant(!m.Value()->BooleanValue())); 29 return Replace(jsgraph()->BooleanConstant(!m.Value()->BooleanValue()));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::kNumberFloor:
93 return ReduceNumberFloor(node);
92 case IrOpcode::kReferenceEqual: 94 case IrOpcode::kReferenceEqual:
93 return ReduceReferenceEqual(node); 95 return ReduceReferenceEqual(node);
94 default: 96 default:
95 break; 97 break;
96 } 98 }
97 return NoChange(); 99 return NoChange();
98 } 100 }
99 101
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 }
100 111
101 Reduction SimplifiedOperatorReducer::ReduceReferenceEqual(Node* node) { 112 Reduction SimplifiedOperatorReducer::ReduceReferenceEqual(Node* node) {
102 DCHECK_EQ(IrOpcode::kReferenceEqual, node->opcode()); 113 DCHECK_EQ(IrOpcode::kReferenceEqual, node->opcode());
103 Node* const left = NodeProperties::GetValueInput(node, 0); 114 Node* const left = NodeProperties::GetValueInput(node, 0);
104 Node* const right = NodeProperties::GetValueInput(node, 1); 115 Node* const right = NodeProperties::GetValueInput(node, 1);
105 HeapObjectMatcher match_left(left); 116 HeapObjectMatcher match_left(left);
106 HeapObjectMatcher match_right(right); 117 HeapObjectMatcher match_right(right);
107 if (match_left.HasValue() && match_right.HasValue()) { 118 if (match_left.HasValue() && match_right.HasValue()) {
108 if (match_left.Value().is_identical_to(match_right.Value())) { 119 if (match_left.Value().is_identical_to(match_right.Value())) {
109 return Replace(jsgraph()->TrueConstant()); 120 return Replace(jsgraph()->TrueConstant());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); } 159 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); }
149 160
150 161
151 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { 162 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const {
152 return jsgraph()->machine(); 163 return jsgraph()->machine();
153 } 164 }
154 165
155 } // namespace compiler 166 } // namespace compiler
156 } // namespace internal 167 } // namespace internal
157 } // namespace v8 168 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-operator-reducer.h ('k') | src/compiler/typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698