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

Unified Diff: src/compiler/wasm-compiler.cc

Issue 1627263002: [turbofan] Add TruncateFloat32ToUint32 operator to Turbofan. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Andreas' comment Created 4 years, 11 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 | « src/compiler/verifier.cc ('k') | src/compiler/x64/code-generator-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index d838e019581e85400700a8329cad5e7e41274ccf..31b455ac26b8a03b374cc741f71a6b07a172a215 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -1154,14 +1154,12 @@ Node* WasmGraphBuilder::BuildI32UConvertF32(Node* input) {
MachineOperatorBuilder* m = jsgraph()->machine();
// Truncation of the input value is needed for the overflow check later.
Node* trunc = Unop(wasm::kExprF32Trunc, input);
- // TODO(titzer): two conversions
- Node* f64_trunc = graph()->NewNode(m->ChangeFloat32ToFloat64(), trunc);
- Node* result = graph()->NewNode(m->ChangeFloat64ToUint32(), f64_trunc);
+ Node* result = graph()->NewNode(m->TruncateFloat32ToUint32(), trunc);
- // Convert the result back to f64. If we end up at a different value than the
+ // Convert the result back to f32. If we end up at a different value than the
// truncated input value, then there has been an overflow and we trap.
- Node* check = Unop(wasm::kExprF64UConvertI32, result);
- Node* overflow = Binop(wasm::kExprF64Ne, f64_trunc, check);
+ Node* check = Unop(wasm::kExprF32UConvertI32, result);
+ Node* overflow = Binop(wasm::kExprF32Ne, trunc, check);
trap_->AddTrapIfTrue(kTrapFloatUnrepresentable, overflow);
return result;
« no previous file with comments | « src/compiler/verifier.cc ('k') | src/compiler/x64/code-generator-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698