diff options
-rw-r--r-- | src/asm2wasm.h | 4 | ||||
-rw-r--r-- | test/unit.asm.js | 2 | ||||
-rw-r--r-- | test/unit.fromasm | 6 | ||||
-rw-r--r-- | test/unit.fromasm.imprecise | 6 |
4 files changed, 18 insertions, 0 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index f905d2047..974a06bf3 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -1579,6 +1579,10 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { auto conv = allocator.alloc<Unary>(); conv->op = ReinterpretFloat; conv->value = process(writtenValue); + if (conv->value->type == f64) { + // this has an implicit f64->f32 in the write to memory + conv->value = builder.makeUnary(DemoteFloat64, conv->value, f32); + } conv->type = WasmType::i32; return conv; } diff --git a/test/unit.asm.js b/test/unit.asm.js index df731148a..da4269873 100644 --- a/test/unit.asm.js +++ b/test/unit.asm.js @@ -207,9 +207,11 @@ function asm(global, env, buffer) { function bitcasts(i, f) { i = i | 0; f = Math_fround(f); + var d = 0.0; (HEAP32[tempDoublePtr >> 2] = i, Math_fround(HEAPF32[tempDoublePtr >> 2])); // i32->f32 (HEAP32[tempDoublePtr >> 2] = i, +HEAPF32[tempDoublePtr >> 2]); // i32->f32, no fround (HEAPF32[tempDoublePtr >> 2] = f, HEAP32[tempDoublePtr >> 2] | 0); // f32->i32 + (HEAPF32[tempDoublePtr >> 2] = d, HEAP32[tempDoublePtr >> 2] | 0); // f64 with implict f32 conversion, ->i32 } function z() { diff --git a/test/unit.fromasm b/test/unit.fromasm index eda3ea485..41e1154b5 100644 --- a/test/unit.fromasm +++ b/test/unit.fromasm @@ -460,6 +460,7 @@ ) ) (func $bitcasts (param $i i32) (param $f f32) + (local $d f64) (f32.reinterpret/i32 (get_local $i) ) @@ -471,6 +472,11 @@ (i32.reinterpret/f32 (get_local $f) ) + (i32.reinterpret/f32 + (f32.demote/f64 + (get_local $d) + ) + ) ) (func $z (nop) diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise index 2d7147edb..3c8a7d917 100644 --- a/test/unit.fromasm.imprecise +++ b/test/unit.fromasm.imprecise @@ -454,6 +454,7 @@ ) ) (func $bitcasts (param $i i32) (param $f f32) + (local $d f64) (f32.reinterpret/i32 (get_local $i) ) @@ -465,6 +466,11 @@ (i32.reinterpret/f32 (get_local $f) ) + (i32.reinterpret/f32 + (f32.demote/f64 + (get_local $d) + ) + ) ) (func $z (nop) |