summaryrefslogtreecommitdiff
path: root/src/wasm-interpreter.h
diff options
context:
space:
mode:
authorJF Bastien <jfb@chromium.org>2015-12-24 09:26:04 -0800
committerJF Bastien <jfb@chromium.org>2015-12-24 09:26:04 -0800
commitf2773d476c835fcc95e4e67d775736affa224552 (patch)
tree0e4c53f179d8ddd4e0e0c07fd168702d25c39b6e /src/wasm-interpreter.h
parenta8f29286f99b8cde3dbb4656d5ac24a0ec2bdf5c (diff)
downloadbinaryen-f2773d476c835fcc95e4e67d775736affa224552.tar.gz
binaryen-f2773d476c835fcc95e4e67d775736affa224552.tar.bz2
binaryen-f2773d476c835fcc95e4e67d775736affa224552.zip
Simplify the bit functions... a bit!
Diffstat (limited to 'src/wasm-interpreter.h')
-rw-r--r--src/wasm-interpreter.h27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 012c1c347..d231aee42 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -360,15 +360,9 @@ private:
if (value.type == i32) {
int32_t v = value.geti32();
switch (curr->op) {
- 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));
- }
- case Popcnt: return Literal((int32_t)PopCount((uint32_t)v));
+ case Clz: return Literal((int32_t)CountLeadingZeroes(v));
+ case Ctz: return Literal((int32_t)CountTrailingZeroes(v));
+ case Popcnt: return Literal((int32_t)PopCount(v));
case ReinterpretInt: {
float v = value.reinterpretf32();
if (isnan(v)) {
@@ -385,19 +379,10 @@ private:
}
if (value.type == i64) {
int64_t v = value.geti64();
- int32_t high = v >> 32, low = v;
switch (curr->op) {
- case Clz: {
- if (v == 0) return Literal((int64_t)64);
- if (high == 0) return Literal(32+(int64_t)CountLeadingZeroes((uint32_t)low));
- return Literal((int64_t)CountLeadingZeroes((uint32_t)high));
- }
- case Ctz: {
- if (v == 0) return Literal((int64_t)64);
- if (low == 0) return Literal(32+(int64_t)CountTrailingZeroes((uint32_t)high));
- return Literal((int64_t)CountTrailingZeroes((uint32_t)low));
- }
- case Popcnt: return Literal((int64_t)PopCount((uint64_t)v));
+ case Clz: return Literal((int64_t)CountLeadingZeroes(v));
+ case Ctz: return Literal((int64_t)CountTrailingZeroes(v));
+ case Popcnt: return Literal((int64_t)PopCount(v));
case WrapInt64: return Literal(int32_t(value.geti64()));
case ReinterpretInt: {
return Literal(value.reinterpretf64());