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

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

Issue 1128133003: [turbofan] Make an OptionalOperator for MachineOperatorBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | src/compiler/js-intrinsic-lowering.cc » ('j') | src/compiler/machine-operator.h » ('J')
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/common-operator-reducer.h" 5 #include "src/compiler/common-operator-reducer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/compiler/common-operator.h" 9 #include "src/compiler/common-operator.h"
10 #include "src/compiler/js-graph.h" 10 #include "src/compiler/js-graph.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 Node* vfalse = NodeProperties::GetValueInput(node, 1); 52 Node* vfalse = NodeProperties::GetValueInput(node, 1);
53 Node* merge = NodeProperties::GetControlInput(node); 53 Node* merge = NodeProperties::GetControlInput(node);
54 DiamondMatcher matcher(merge); 54 DiamondMatcher matcher(merge);
55 if (matcher.Matched()) { 55 if (matcher.Matched()) {
56 if (matcher.IfTrue() == merge->InputAt(1)) std::swap(vtrue, vfalse); 56 if (matcher.IfTrue() == merge->InputAt(1)) std::swap(vtrue, vfalse);
57 Node* cond = matcher.Branch()->InputAt(0); 57 Node* cond = matcher.Branch()->InputAt(0);
58 if (cond->opcode() == IrOpcode::kFloat32LessThan) { 58 if (cond->opcode() == IrOpcode::kFloat32LessThan) {
59 Float32BinopMatcher mcond(cond); 59 Float32BinopMatcher mcond(cond);
60 if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) && 60 if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) &&
61 vfalse->opcode() == IrOpcode::kFloat32Sub && 61 vfalse->opcode() == IrOpcode::kFloat32Sub &&
62 machine()->HasFloat32Abs()) { 62 machine()->Float32Abs().supported()) {
63 Float32BinopMatcher mvfalse(vfalse); 63 Float32BinopMatcher mvfalse(vfalse);
64 if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) { 64 if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) {
65 return Change(node, machine()->Float32Abs(), vtrue); 65 return Change(node, machine()->Float32Abs().op(), vtrue);
66 } 66 }
67 } 67 }
68 if (mcond.left().Equals(vtrue) && mcond.right().Equals(vfalse) && 68 if (mcond.left().Equals(vtrue) && mcond.right().Equals(vfalse) &&
69 machine()->HasFloat32Min()) { 69 machine()->Float32Min().supported()) {
70 return Change(node, machine()->Float32Min(), vtrue, vfalse); 70 return Change(node, machine()->Float32Min().op(), vtrue, vfalse);
71 } else if (mcond.left().Equals(vfalse) && mcond.right().Equals(vtrue) && 71 } else if (mcond.left().Equals(vfalse) && mcond.right().Equals(vtrue) &&
72 machine()->HasFloat32Max()) { 72 machine()->Float32Max().supported()) {
73 return Change(node, machine()->Float32Max(), vtrue, vfalse); 73 return Change(node, machine()->Float32Max().op(), vtrue, vfalse);
74 } 74 }
75 } else if (cond->opcode() == IrOpcode::kFloat64LessThan) { 75 } else if (cond->opcode() == IrOpcode::kFloat64LessThan) {
76 Float64BinopMatcher mcond(cond); 76 Float64BinopMatcher mcond(cond);
77 if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) && 77 if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) &&
78 vfalse->opcode() == IrOpcode::kFloat64Sub && 78 vfalse->opcode() == IrOpcode::kFloat64Sub &&
79 machine()->HasFloat64Abs()) { 79 machine()->Float64Abs().supported()) {
80 Float64BinopMatcher mvfalse(vfalse); 80 Float64BinopMatcher mvfalse(vfalse);
81 if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) { 81 if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) {
82 return Change(node, machine()->Float64Abs(), vtrue); 82 return Change(node, machine()->Float64Abs().op(), vtrue);
83 } 83 }
84 } 84 }
85 if (mcond.left().Equals(vtrue) && mcond.right().Equals(vfalse) && 85 if (mcond.left().Equals(vtrue) && mcond.right().Equals(vfalse) &&
86 machine()->HasFloat64Min()) { 86 machine()->Float64Min().supported()) {
87 return Change(node, machine()->Float64Min(), vtrue, vfalse); 87 return Change(node, machine()->Float64Min().op(), vtrue, vfalse);
88 } else if (mcond.left().Equals(vfalse) && mcond.right().Equals(vtrue) && 88 } else if (mcond.left().Equals(vfalse) && mcond.right().Equals(vtrue) &&
89 machine()->HasFloat64Max()) { 89 machine()->Float64Max().supported()) {
90 return Change(node, machine()->Float64Max(), vtrue, vfalse); 90 return Change(node, machine()->Float64Max().op(), vtrue, vfalse);
91 } 91 }
92 } 92 }
93 } 93 }
94 } 94 }
95 if (input_count > 1) { 95 if (input_count > 1) {
96 Node* const replacement = node->InputAt(0); 96 Node* const replacement = node->InputAt(0);
97 for (int i = 1; i < input_count - 1; ++i) { 97 for (int i = 1; i < input_count - 1; ++i) {
98 if (node->InputAt(i) != replacement) return NoChange(); 98 if (node->InputAt(i) != replacement) return NoChange();
99 } 99 }
100 return Replace(replacement); 100 return Replace(replacement);
(...skipping 10 matching lines...) Expand all
111 if (vtrue == vfalse) return Replace(vtrue); 111 if (vtrue == vfalse) return Replace(vtrue);
112 switch (cond->opcode()) { 112 switch (cond->opcode()) {
113 case IrOpcode::kHeapConstant: { 113 case IrOpcode::kHeapConstant: {
114 HeapObjectMatcher<HeapObject> mcond(cond); 114 HeapObjectMatcher<HeapObject> mcond(cond);
115 return Replace(mcond.Value().handle()->BooleanValue() ? vtrue : vfalse); 115 return Replace(mcond.Value().handle()->BooleanValue() ? vtrue : vfalse);
116 } 116 }
117 case IrOpcode::kFloat32LessThan: { 117 case IrOpcode::kFloat32LessThan: {
118 Float32BinopMatcher mcond(cond); 118 Float32BinopMatcher mcond(cond);
119 if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) && 119 if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) &&
120 vfalse->opcode() == IrOpcode::kFloat32Sub && 120 vfalse->opcode() == IrOpcode::kFloat32Sub &&
121 machine()->HasFloat32Abs()) { 121 machine()->Float32Abs().supported()) {
122 Float32BinopMatcher mvfalse(vfalse); 122 Float32BinopMatcher mvfalse(vfalse);
123 if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) { 123 if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) {
124 return Change(node, machine()->Float32Abs(), vtrue); 124 return Change(node, machine()->Float32Abs().op(), vtrue);
125 } 125 }
126 } 126 }
127 if (mcond.left().Equals(vtrue) && mcond.right().Equals(vfalse) && 127 if (mcond.left().Equals(vtrue) && mcond.right().Equals(vfalse) &&
128 machine()->HasFloat32Min()) { 128 machine()->Float32Min().supported()) {
129 return Change(node, machine()->Float32Min(), vtrue, vfalse); 129 return Change(node, machine()->Float32Min().op(), vtrue, vfalse);
130 } else if (mcond.left().Equals(vfalse) && mcond.right().Equals(vtrue) && 130 } else if (mcond.left().Equals(vfalse) && mcond.right().Equals(vtrue) &&
131 machine()->HasFloat32Max()) { 131 machine()->Float32Max().supported()) {
132 return Change(node, machine()->Float32Max(), vtrue, vfalse); 132 return Change(node, machine()->Float32Max().op(), vtrue, vfalse);
133 } 133 }
134 break; 134 break;
135 } 135 }
136 case IrOpcode::kFloat64LessThan: { 136 case IrOpcode::kFloat64LessThan: {
137 Float64BinopMatcher mcond(cond); 137 Float64BinopMatcher mcond(cond);
138 if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) && 138 if (mcond.left().Is(0.0) && mcond.right().Equals(vtrue) &&
139 vfalse->opcode() == IrOpcode::kFloat64Sub && 139 vfalse->opcode() == IrOpcode::kFloat64Sub &&
140 machine()->HasFloat64Abs()) { 140 machine()->Float64Abs().supported()) {
141 Float64BinopMatcher mvfalse(vfalse); 141 Float64BinopMatcher mvfalse(vfalse);
142 if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) { 142 if (mvfalse.left().IsZero() && mvfalse.right().Equals(vtrue)) {
143 return Change(node, machine()->Float64Abs(), vtrue); 143 return Change(node, machine()->Float64Abs().op(), vtrue);
144 } 144 }
145 } 145 }
146 if (mcond.left().Equals(vtrue) && mcond.right().Equals(vfalse) && 146 if (mcond.left().Equals(vtrue) && mcond.right().Equals(vfalse) &&
147 machine()->HasFloat64Min()) { 147 machine()->Float64Min().supported()) {
148 return Change(node, machine()->Float64Min(), vtrue, vfalse); 148 return Change(node, machine()->Float64Min().op(), vtrue, vfalse);
149 } else if (mcond.left().Equals(vfalse) && mcond.right().Equals(vtrue) && 149 } else if (mcond.left().Equals(vfalse) && mcond.right().Equals(vtrue) &&
150 machine()->HasFloat64Max()) { 150 machine()->Float64Max().supported()) {
151 return Change(node, machine()->Float64Max(), vtrue, vfalse); 151 return Change(node, machine()->Float64Max().op(), vtrue, vfalse);
152 } 152 }
153 break; 153 break;
154 } 154 }
155 default: 155 default:
156 break; 156 break;
157 } 157 }
158 return NoChange(); 158 return NoChange();
159 } 159 }
160 160
161 161
(...skipping 24 matching lines...) Expand all
186 Graph* CommonOperatorReducer::graph() const { return jsgraph()->graph(); } 186 Graph* CommonOperatorReducer::graph() const { return jsgraph()->graph(); }
187 187
188 188
189 MachineOperatorBuilder* CommonOperatorReducer::machine() const { 189 MachineOperatorBuilder* CommonOperatorReducer::machine() const {
190 return jsgraph()->machine(); 190 return jsgraph()->machine();
191 } 191 }
192 192
193 } // namespace compiler 193 } // namespace compiler
194 } // namespace internal 194 } // namespace internal
195 } // namespace v8 195 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/js-intrinsic-lowering.cc » ('j') | src/compiler/machine-operator.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698