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

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

Issue 1532063002: [turbofan ] Simplify reference equal if both inputs are constants (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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') | no next file » | 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"
(...skipping 71 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::kReferenceEqual:
93 return ReduceReferenceEqual(node);
92 default: 94 default:
93 break; 95 break;
94 } 96 }
95 return NoChange(); 97 return NoChange();
96 } 98 }
97 99
98 100
101 Reduction SimplifiedOperatorReducer::ReduceReferenceEqual(Node* node) {
102 DCHECK_EQ(IrOpcode::kReferenceEqual, node->opcode());
103 Node* const left = NodeProperties::GetValueInput(node, 0);
104 Node* const right = NodeProperties::GetValueInput(node, 1);
105 HeapObjectMatcher match_left(left);
106 HeapObjectMatcher match_right(right);
107 if (match_left.HasValue() && match_right.HasValue()) {
108 if (match_left.Value().is_identical_to(match_right.Value())) {
109 return Replace(jsgraph()->TrueConstant());
110 } else {
111 return Replace(jsgraph()->FalseConstant());
112 }
113 }
114 return NoChange();
115 }
116
117
99 Reduction SimplifiedOperatorReducer::Change(Node* node, const Operator* op, 118 Reduction SimplifiedOperatorReducer::Change(Node* node, const Operator* op,
100 Node* a) { 119 Node* a) {
101 DCHECK_EQ(node->InputCount(), OperatorProperties::GetTotalInputCount(op)); 120 DCHECK_EQ(node->InputCount(), OperatorProperties::GetTotalInputCount(op));
102 DCHECK_LE(1, node->InputCount()); 121 DCHECK_LE(1, node->InputCount());
103 node->ReplaceInput(0, a); 122 node->ReplaceInput(0, a);
104 NodeProperties::ChangeOp(node, op); 123 NodeProperties::ChangeOp(node, op);
105 return Changed(node); 124 return Changed(node);
106 } 125 }
107 126
108 127
(...skipping 20 matching lines...) Expand all
129 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); } 148 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); }
130 149
131 150
132 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { 151 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const {
133 return jsgraph()->machine(); 152 return jsgraph()->machine();
134 } 153 }
135 154
136 } // namespace compiler 155 } // namespace compiler
137 } // namespace internal 156 } // namespace internal
138 } // namespace v8 157 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-operator-reducer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698