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

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

Issue 2662233002: [wasm] Remove x / -1 = -x constant folding for wasm (Closed)
Patch Set: Created 3 years, 10 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
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/base/division-by-constant.h" 8 #include "src/base/division-by-constant.h"
9 #include "src/base/ieee754.h" 9 #include "src/base/ieee754.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // Do some calculation to make a signalling NaN quiet. 430 // Do some calculation to make a signalling NaN quiet.
431 return ReplaceFloat64(m.right().Value() - m.right().Value()); 431 return ReplaceFloat64(m.right().Value() - m.right().Value());
432 } 432 }
433 if (m.left().IsNaN()) { // NaN / x => NaN 433 if (m.left().IsNaN()) { // NaN / x => NaN
434 // Do some calculation to make a signalling NaN quiet. 434 // Do some calculation to make a signalling NaN quiet.
435 return ReplaceFloat64(m.left().Value() - m.left().Value()); 435 return ReplaceFloat64(m.left().Value() - m.left().Value());
436 } 436 }
437 if (m.IsFoldable()) { // K / K => K 437 if (m.IsFoldable()) { // K / K => K
438 return ReplaceFloat64(m.left().Value() / m.right().Value()); 438 return ReplaceFloat64(m.left().Value() / m.right().Value());
439 } 439 }
440 if (m.right().Is(-1)) { // x / -1.0 => -x 440 if (!wasm_origin_ && m.right().Is(-1)) { // x / -1.0 => -x
titzer 2017/01/31 17:24:49 Can we rename this option to something closer to w
ahaas 2017/01/31 19:43:37 Done with the rebasing.
441 node->RemoveInput(1); 441 node->RemoveInput(1);
442 NodeProperties::ChangeOp(node, machine()->Float64Neg()); 442 NodeProperties::ChangeOp(node, machine()->Float64Neg());
443 return Changed(node); 443 return Changed(node);
444 } 444 }
445 if (m.right().IsNormal() && m.right().IsPositiveOrNegativePowerOf2()) { 445 if (m.right().IsNormal() && m.right().IsPositiveOrNegativePowerOf2()) {
446 // All reciprocals of non-denormal powers of two can be represented 446 // All reciprocals of non-denormal powers of two can be represented
447 // exactly, so division by power of two can be reduced to 447 // exactly, so division by power of two can be reduced to
448 // multiplication by reciprocal, with the same result. 448 // multiplication by reciprocal, with the same result.
449 node->ReplaceInput(1, Float64Constant(1.0 / m.right().Value())); 449 node->ReplaceInput(1, Float64Constant(1.0 / m.right().Value()));
450 NodeProperties::ChangeOp(node, machine()->Float64Mul()); 450 NodeProperties::ChangeOp(node, machine()->Float64Mul());
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 MachineOperatorBuilder* MachineOperatorReducer::machine() const { 1423 MachineOperatorBuilder* MachineOperatorReducer::machine() const {
1424 return jsgraph()->machine(); 1424 return jsgraph()->machine();
1425 } 1425 }
1426 1426
1427 1427
1428 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } 1428 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
1429 1429
1430 } // namespace compiler 1430 } // namespace compiler
1431 } // namespace internal 1431 } // namespace internal
1432 } // namespace v8 1432 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/wasm/float-constant-folding.js » ('j') | test/mjsunit/wasm/float-constant-folding.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698