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

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

Issue 2669753002: [wasm] Do not fold f32-to-f64 and f64-to-f32 conversions. (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
« no previous file with comments | « no previous file | test/mjsunit/wasm/float-constant-folding.js » ('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/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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 if (m.HasValue()) return ReplaceFloat64(base::ieee754::tan(m.Value())); 599 if (m.HasValue()) return ReplaceFloat64(base::ieee754::tan(m.Value()));
600 break; 600 break;
601 } 601 }
602 case IrOpcode::kFloat64Tanh: { 602 case IrOpcode::kFloat64Tanh: {
603 Float64Matcher m(node->InputAt(0)); 603 Float64Matcher m(node->InputAt(0));
604 if (m.HasValue()) return ReplaceFloat64(base::ieee754::tanh(m.Value())); 604 if (m.HasValue()) return ReplaceFloat64(base::ieee754::tanh(m.Value()));
605 break; 605 break;
606 } 606 }
607 case IrOpcode::kChangeFloat32ToFloat64: { 607 case IrOpcode::kChangeFloat32ToFloat64: {
608 Float32Matcher m(node->InputAt(0)); 608 Float32Matcher m(node->InputAt(0));
609 if (m.HasValue()) return ReplaceFloat64(m.Value()); 609 if (m.HasValue()) {
610 if (!allow_signalling_nan_ && std::isnan(m.Value())) {
611 // Do some calculation to make guarantee the value is a quiet NaN.
612 return ReplaceFloat64(m.Value() + m.Value());
titzer 2017/02/01 15:36:44 That doesn't seem right. It would return 2x the in
ahaas 2017/02/01 16:23:56 It is correct because m.Value() is a NaN, and ther
titzer 2017/02/01 18:00:33 Ok, make sense.
613 }
614 return ReplaceFloat64(m.Value());
615 }
610 break; 616 break;
611 } 617 }
612 case IrOpcode::kChangeFloat64ToInt32: { 618 case IrOpcode::kChangeFloat64ToInt32: {
613 Float64Matcher m(node->InputAt(0)); 619 Float64Matcher m(node->InputAt(0));
614 if (m.HasValue()) return ReplaceInt32(FastD2I(m.Value())); 620 if (m.HasValue()) return ReplaceInt32(FastD2I(m.Value()));
615 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0)); 621 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0));
616 break; 622 break;
617 } 623 }
618 case IrOpcode::kChangeFloat64ToUint32: { 624 case IrOpcode::kChangeFloat64ToUint32: {
619 Float64Matcher m(node->InputAt(0)); 625 Float64Matcher m(node->InputAt(0));
(...skipping 28 matching lines...) Expand all
648 return NoChange(); 654 return NoChange();
649 } 655 }
650 case IrOpcode::kTruncateInt64ToInt32: { 656 case IrOpcode::kTruncateInt64ToInt32: {
651 Int64Matcher m(node->InputAt(0)); 657 Int64Matcher m(node->InputAt(0));
652 if (m.HasValue()) return ReplaceInt32(static_cast<int32_t>(m.Value())); 658 if (m.HasValue()) return ReplaceInt32(static_cast<int32_t>(m.Value()));
653 if (m.IsChangeInt32ToInt64()) return Replace(m.node()->InputAt(0)); 659 if (m.IsChangeInt32ToInt64()) return Replace(m.node()->InputAt(0));
654 break; 660 break;
655 } 661 }
656 case IrOpcode::kTruncateFloat64ToFloat32: { 662 case IrOpcode::kTruncateFloat64ToFloat32: {
657 Float64Matcher m(node->InputAt(0)); 663 Float64Matcher m(node->InputAt(0));
658 if (m.HasValue()) return ReplaceFloat32(DoubleToFloat32(m.Value())); 664 if (m.HasValue()) {
659 if (m.IsChangeFloat32ToFloat64()) return Replace(m.node()->InputAt(0)); 665 if (!allow_signalling_nan_ && std::isnan(m.Value())) {
666 // Do some calculation to make guarantee the value is a quiet NaN.
667 return ReplaceFloat32(DoubleToFloat32(m.Value() + m.Value()));
668 }
669 return ReplaceFloat32(DoubleToFloat32(m.Value()));
670 }
671 if (allow_signalling_nan_ && m.IsChangeFloat32ToFloat64())
672 return Replace(m.node()->InputAt(0));
660 break; 673 break;
661 } 674 }
662 case IrOpcode::kRoundFloat64ToInt32: { 675 case IrOpcode::kRoundFloat64ToInt32: {
663 Float64Matcher m(node->InputAt(0)); 676 Float64Matcher m(node->InputAt(0));
664 if (m.HasValue()) return ReplaceInt32(static_cast<int32_t>(m.Value())); 677 if (m.HasValue()) return ReplaceInt32(static_cast<int32_t>(m.Value()));
665 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0)); 678 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0));
666 break; 679 break;
667 } 680 }
668 case IrOpcode::kFloat64InsertLowWord32: 681 case IrOpcode::kFloat64InsertLowWord32:
669 return ReduceFloat64InsertLowWord32(node); 682 return ReduceFloat64InsertLowWord32(node);
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 MachineOperatorBuilder* MachineOperatorReducer::machine() const { 1436 MachineOperatorBuilder* MachineOperatorReducer::machine() const {
1424 return jsgraph()->machine(); 1437 return jsgraph()->machine();
1425 } 1438 }
1426 1439
1427 1440
1428 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } 1441 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
1429 1442
1430 } // namespace compiler 1443 } // namespace compiler
1431 } // namespace internal 1444 } // namespace internal
1432 } // namespace v8 1445 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/wasm/float-constant-folding.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698