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

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

Issue 599383002: [turbofan] add some simplifications in the machine operator reducer (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review fix Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/compiler/test-machine-operator-reducer.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/machine-operator-reducer.h" 5 #include "src/compiler/machine-operator-reducer.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/compiler/generic-node-inl.h" 8 #include "src/compiler/generic-node-inl.h"
9 #include "src/compiler/graph.h" 9 #include "src/compiler/graph.h"
10 #include "src/compiler/js-graph.h" 10 #include "src/compiler/js-graph.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 if (m.left().Is(0)) return ReplaceBool(true); // 0 <= x => true 331 if (m.left().Is(0)) return ReplaceBool(true); // 0 <= x => true
332 if (m.right().Is(kMaxUInt32)) return ReplaceBool(true); // x <= M => true 332 if (m.right().Is(kMaxUInt32)) return ReplaceBool(true); // x <= M => true
333 if (m.IsFoldable()) { // K <= K => K 333 if (m.IsFoldable()) { // K <= K => K
334 return ReplaceBool(m.left().Value() <= m.right().Value()); 334 return ReplaceBool(m.left().Value() <= m.right().Value());
335 } 335 }
336 if (m.LeftEqualsRight()) return ReplaceBool(true); // x <= x => true 336 if (m.LeftEqualsRight()) return ReplaceBool(true); // x <= x => true
337 break; 337 break;
338 } 338 }
339 case IrOpcode::kFloat64Add: { 339 case IrOpcode::kFloat64Add: {
340 Float64BinopMatcher m(node); 340 Float64BinopMatcher m(node);
341 if (m.right().IsNaN()) { // x + NaN => NaN
342 return Replace(m.right().node());
343 }
341 if (m.IsFoldable()) { // K + K => K 344 if (m.IsFoldable()) { // K + K => K
342 return ReplaceFloat64(m.left().Value() + m.right().Value()); 345 return ReplaceFloat64(m.left().Value() + m.right().Value());
343 } 346 }
344 break; 347 break;
345 } 348 }
346 case IrOpcode::kFloat64Sub: { 349 case IrOpcode::kFloat64Sub: {
347 Float64BinopMatcher m(node); 350 Float64BinopMatcher m(node);
351 if (m.right().Is(0) && (Double(m.right().Value()).Sign() > 0)) {
352 return Replace(m.left().node()); // x - 0 => x
353 }
354 if (m.right().IsNaN()) { // x - NaN => NaN
355 return Replace(m.right().node());
356 }
357 if (m.left().IsNaN()) { // NaN - x => NaN
358 return Replace(m.left().node());
359 }
348 if (m.IsFoldable()) { // K - K => K 360 if (m.IsFoldable()) { // K - K => K
349 return ReplaceFloat64(m.left().Value() - m.right().Value()); 361 return ReplaceFloat64(m.left().Value() - m.right().Value());
350 } 362 }
351 break; 363 break;
352 } 364 }
353 case IrOpcode::kFloat64Mul: { 365 case IrOpcode::kFloat64Mul: {
354 Float64BinopMatcher m(node); 366 Float64BinopMatcher m(node);
355 if (m.right().Is(1)) return Replace(m.left().node()); // x * 1.0 => x 367 if (m.right().Is(1)) return Replace(m.left().node()); // x * 1.0 => x
356 if (m.right().IsNaN()) { // x * NaN => NaN 368 if (m.right().IsNaN()) { // x * NaN => NaN
357 return Replace(m.right().node()); 369 return Replace(m.right().node());
(...skipping 12 matching lines...) Expand all
370 if (m.left().IsNaN()) { // NaN / x => NaN 382 if (m.left().IsNaN()) { // NaN / x => NaN
371 return Replace(m.left().node()); 383 return Replace(m.left().node());
372 } 384 }
373 if (m.IsFoldable()) { // K / K => K 385 if (m.IsFoldable()) { // K / K => K
374 return ReplaceFloat64(m.left().Value() / m.right().Value()); 386 return ReplaceFloat64(m.left().Value() / m.right().Value());
375 } 387 }
376 break; 388 break;
377 } 389 }
378 case IrOpcode::kFloat64Mod: { 390 case IrOpcode::kFloat64Mod: {
379 Float64BinopMatcher m(node); 391 Float64BinopMatcher m(node);
392 if (m.right().Is(0)) { // x % 0 => NaN
393 return ReplaceFloat64(base::OS::nan_value());
394 }
380 if (m.right().IsNaN()) { // x % NaN => NaN 395 if (m.right().IsNaN()) { // x % NaN => NaN
381 return Replace(m.right().node()); 396 return Replace(m.right().node());
382 } 397 }
383 if (m.left().IsNaN()) { // NaN % x => NaN 398 if (m.left().IsNaN()) { // NaN % x => NaN
384 return Replace(m.left().node()); 399 return Replace(m.left().node());
385 } 400 }
386 if (m.IsFoldable()) { // K % K => K 401 if (m.IsFoldable()) { // K % K => K
387 return ReplaceFloat64(modulo(m.left().Value(), m.right().Value())); 402 return ReplaceFloat64(modulo(m.left().Value(), m.right().Value()));
388 } 403 }
389 break; 404 break;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 MachineOperatorBuilder* MachineOperatorReducer::machine() const { 510 MachineOperatorBuilder* MachineOperatorReducer::machine() const {
496 return jsgraph()->machine(); 511 return jsgraph()->machine();
497 } 512 }
498 513
499 514
500 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } 515 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
501 516
502 } // namespace compiler 517 } // namespace compiler
503 } // namespace internal 518 } // namespace internal
504 } // namespace v8 519 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/compiler/test-machine-operator-reducer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698