diff options
author | JF Bastien <github@jfbastien.com> | 2015-12-23 16:20:00 -0800 |
---|---|---|
committer | JF Bastien <github@jfbastien.com> | 2015-12-23 16:20:00 -0800 |
commit | 5ae3515596921ca5721a540d9aeb74fdf1af87ae (patch) | |
tree | 20b63b5fbd9e687f09dee2888ff07b3b723c3122 /src | |
parent | fa3d3bab09730f7bbce4e6d6889ebda3be3795d6 (diff) | |
parent | 6874599d894b925ee5708c30de0cd3d355fed729 (diff) | |
download | binaryen-5ae3515596921ca5721a540d9aeb74fdf1af87ae.tar.gz binaryen-5ae3515596921ca5721a540d9aeb74fdf1af87ae.tar.bz2 binaryen-5ae3515596921ca5721a540d9aeb74fdf1af87ae.zip |
Merge pull request #43 from WebAssembly/clz32-0
clz32: handle 0 as with ctz
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-interpreter.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 0d32dcf52..7752f5356 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -360,7 +360,10 @@ private: if (value.type == i32) { int32_t v = value.geti32(); switch (curr->op) { - case Clz: return Literal(CountLeadingZeroes((uint32_t)v)); + case Clz: { + if (v == 0) return Literal(32); + return Literal(CountLeadingZeroes((uint32_t)v)); + } case Ctz: { if (v == 0) return Literal(32); return Literal(CountTrailingZeroes((uint32_t)v)); |