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

Unified Diff: src/compiler/machine-operator-reducer.cc

Issue 2669753002: [wasm] Do not fold f32-to-f64 and f64-to-f32 conversions. (Closed)
Patch Set: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/wasm/float-constant-folding.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/machine-operator-reducer.cc
diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc
index 127c6c5870b3f1568d58094fe0c3d49de7c04b6a..69175d87028f20b6e7eb334dd1de11f1498ff5ec 100644
--- a/src/compiler/machine-operator-reducer.cc
+++ b/src/compiler/machine-operator-reducer.cc
@@ -606,7 +606,13 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
}
case IrOpcode::kChangeFloat32ToFloat64: {
Float32Matcher m(node->InputAt(0));
- if (m.HasValue()) return ReplaceFloat64(m.Value());
+ if (m.HasValue()) {
+ if (!allow_signalling_nan_ && std::isnan(m.Value())) {
+ // Do some calculation to make guarantee the value is a quiet NaN.
+ return ReplaceFloat64(m.Value() + m.Value());
+ }
+ return ReplaceFloat64(m.Value());
+ }
break;
}
case IrOpcode::kChangeFloat64ToInt32: {
@@ -655,8 +661,15 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
}
case IrOpcode::kTruncateFloat64ToFloat32: {
Float64Matcher m(node->InputAt(0));
- if (m.HasValue()) return ReplaceFloat32(DoubleToFloat32(m.Value()));
- if (m.IsChangeFloat32ToFloat64()) return Replace(m.node()->InputAt(0));
+ if (m.HasValue()) {
+ if (!allow_signalling_nan_ && std::isnan(m.Value())) {
+ // Do some calculation to make guarantee the value is a quiet NaN.
+ return ReplaceFloat32(DoubleToFloat32(m.Value() + m.Value()));
+ }
+ return ReplaceFloat32(DoubleToFloat32(m.Value()));
+ }
+ if (allow_signalling_nan_ && m.IsChangeFloat32ToFloat64())
+ return Replace(m.node()->InputAt(0));
break;
}
case IrOpcode::kRoundFloat64ToInt32: {
« 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