summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/asm2wasm.h13
-rw-r--r--src/emscripten-optimizer/parser.cpp1
-rw-r--r--src/emscripten-optimizer/parser.h1
3 files changed, 12 insertions, 3 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index 910134024..1aca67eff 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -202,6 +202,8 @@ private:
IString Math_ceil;
IString Math_sqrt;
+ IString llvm_cttz_i32;
+
IString tempDoublePtr; // imported name of tempDoublePtr
// function types. we fill in this information as we see
@@ -486,10 +488,15 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
assert(module[0] == NAME);
moduleName = module[1]->getIString();
if (moduleName == ENV) {
- if (imported[2] == TEMP_DOUBLE_PTR) {
+ auto base = imported[2]->getIString();
+ if (base == TEMP_DOUBLE_PTR) {
assert(tempDoublePtr.isNull());
tempDoublePtr = name;
// we don't return here, as we can only optimize out some uses of tDP. So it remains imported
+ } else if (base == LLVM_CTTZ_I32) {
+ assert(llvm_cttz_i32.isNull());
+ llvm_cttz_i32 = name;
+ return;
}
}
}
@@ -1092,10 +1099,10 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
ret->type = WasmType::i32;
return ret;
}
- if (name == Math_clz32) {
+ if (name == Math_clz32 || name == llvm_cttz_i32) {
assert(ast[2]->size() == 1);
auto ret = allocator.alloc<Unary>();
- ret->op = Clz;
+ ret->op = name == Math_clz32 ? Clz : Ctz;
ret->value = process(ast[2][0]);
ret->type = WasmType::i32;
return ret;
diff --git a/src/emscripten-optimizer/parser.cpp b/src/emscripten-optimizer/parser.cpp
index 7005dc4b4..ce4737476 100644
--- a/src/emscripten-optimizer/parser.cpp
+++ b/src/emscripten-optimizer/parser.cpp
@@ -48,6 +48,7 @@ IString TOPLEVEL("toplevel"),
INF("inf"),
NaN("nan"),
TEMP_RET0("tempRet0"),
+ LLVM_CTTZ_I32("_llvm_cttz_i32"),
UNARY_PREFIX("unary-prefix"),
UNARY_POSTFIX("unary-postfix"),
MATH_FROUND("Math_fround"),
diff --git a/src/emscripten-optimizer/parser.h b/src/emscripten-optimizer/parser.h
index da3e6f5c7..e10044fbc 100644
--- a/src/emscripten-optimizer/parser.h
+++ b/src/emscripten-optimizer/parser.h
@@ -63,6 +63,7 @@ extern IString TOPLEVEL,
INF,
NaN,
TEMP_RET0,
+ LLVM_CTTZ_I32,
UNARY_PREFIX,
UNARY_POSTFIX,
MATH_FROUND,