diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-03-05 19:06:32 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-03-05 19:06:32 -0800 |
commit | c1823df9feea7ea90e3886cb18fedee56df48156 (patch) | |
tree | f1301cdab0c35aec1b8daac51b89d305366e579b /src | |
parent | 49b8031ecf4695850d060ef11926caddf4bd3352 (diff) | |
download | binaryen-c1823df9feea7ea90e3886cb18fedee56df48156.tar.gz binaryen-c1823df9feea7ea90e3886cb18fedee56df48156.tar.bz2 binaryen-c1823df9feea7ea90e3886cb18fedee56df48156.zip |
cast f32 to f64 before calling f64-to-int in asm2wasm
Diffstat (limited to 'src')
-rw-r--r-- | src/asm2wasm.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 1aca26e88..06960a114 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -1018,7 +1018,15 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { // WebAssembly traps on float-to-int overflows, but asm.js wouldn't, so we must emulate that CallImport *ret = allocator.alloc<CallImport>(); ret->target = F64_TO_INT; - ret->operands.push_back(process(ast[2][2])); + auto input = process(ast[2][2]); + if (input->type == f32) { + auto conv = allocator.alloc<Unary>(); + conv->op = PromoteFloat32; + conv->value = input; + conv->type = WasmType::f64; + input = conv; + } + ret->operands.push_back(input); ret->type = i32; static bool addedImport = false; if (!addedImport) { |