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

Side by Side Diff: src/compiler/js-builtin-reducer.cc

Issue 1971163002: [turbofan] Fix optimized lowering of Math.imul. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix unittests. Reorder as pointed out by Michi. Created 4 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/opcodes.h » ('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/js-builtin-reducer.h" 5 #include "src/compiler/js-builtin-reducer.h"
6 #include "src/compiler/js-graph.h" 6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 #include "src/compiler/node-properties.h" 8 #include "src/compiler/node-properties.h"
9 #include "src/compiler/simplified-operator.h" 9 #include "src/compiler/simplified-operator.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 value = graph()->NewNode( 110 value = graph()->NewNode(
111 common()->Select(MachineRepresentation::kNone), 111 common()->Select(MachineRepresentation::kNone),
112 graph()->NewNode(simplified()->NumberLessThan(), input, value), value, 112 graph()->NewNode(simplified()->NumberLessThan(), input, value), value,
113 input); 113 input);
114 } 114 }
115 return Replace(value); 115 return Replace(value);
116 } 116 }
117 return NoChange(); 117 return NoChange();
118 } 118 }
119 119
120 120 // ES6 section 20.2.2.19 Math.imul ( x, y )
121 // ES6 draft 08-24-14, section 20.2.2.19.
122 Reduction JSBuiltinReducer::ReduceMathImul(Node* node) { 121 Reduction JSBuiltinReducer::ReduceMathImul(Node* node) {
123 JSCallReduction r(node); 122 JSCallReduction r(node);
124 if (r.InputsMatchTwo(Type::Integral32(), Type::Integral32())) { 123 if (r.InputsMatchTwo(Type::Number(), Type::Number())) {
125 // Math.imul(a:int32, b:int32) -> Int32Mul(a, b) 124 // Math.imul(a:number, b:number) -> NumberImul(NumberToUint32(a),
126 Node* value = graph()->NewNode(machine()->Int32Mul(), r.left(), r.right()); 125 // NumberToUint32(b))
126 Node* a = graph()->NewNode(simplified()->NumberToUint32(), r.left());
127 Node* b = graph()->NewNode(simplified()->NumberToUint32(), r.right());
128 Node* value = graph()->NewNode(simplified()->NumberImul(), a, b);
127 return Replace(value); 129 return Replace(value);
128 } 130 }
129 return NoChange(); 131 return NoChange();
130 } 132 }
131 133
132 // ES6 section 20.2.2.10 Math.ceil ( x ) 134 // ES6 section 20.2.2.10 Math.ceil ( x )
133 Reduction JSBuiltinReducer::ReduceMathCeil(Node* node) { 135 Reduction JSBuiltinReducer::ReduceMathCeil(Node* node) {
134 JSCallReduction r(node); 136 JSCallReduction r(node);
135 if (r.InputsMatchOne(Type::Number())) { 137 if (r.InputsMatchOne(Type::Number())) {
136 // Math.ceil(a:number) -> NumberCeil(a) 138 // Math.ceil(a:number) -> NumberCeil(a)
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 278 }
277 279
278 280
279 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { 281 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const {
280 return jsgraph()->simplified(); 282 return jsgraph()->simplified();
281 } 283 }
282 284
283 } // namespace compiler 285 } // namespace compiler
284 } // namespace internal 286 } // namespace internal
285 } // namespace v8 287 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698