mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-12 22:41:27 +00:00
Transition to TypeFlags for specific type checks; Optimize logical ops a bit
This commit is contained in:
19
tests/binaryen/optimize-if-eqz.js
Normal file
19
tests/binaryen/optimize-if-eqz.js
Normal file
@ -0,0 +1,19 @@
|
||||
var binaryen = require("binaryen");
|
||||
|
||||
var mod = new binaryen.Module();
|
||||
var funcType = mod.addFunctionType("i", binaryen.i32, [ binaryen.i32 ]);
|
||||
var func = mod.addFunction("test", funcType, [],
|
||||
mod.if(
|
||||
mod.i32.eqz(mod.getLocal(0, binaryen.i32)),
|
||||
mod.i32.const(0),
|
||||
mod.getLocal(0, binaryen.i32)
|
||||
)
|
||||
);
|
||||
mod.addExport("test", "test");
|
||||
|
||||
console.log(mod.emitText());
|
||||
if (!mod.validate())
|
||||
console.log("-> does not validate");
|
||||
|
||||
mod.optimize();
|
||||
console.log(mod.emitText());
|
14
tests/binaryen/optimize-if-eqz.wast
Normal file
14
tests/binaryen/optimize-if-eqz.wast
Normal file
@ -0,0 +1,14 @@
|
||||
(module
|
||||
(type $i (func (param i32) (result i32)))
|
||||
(memory $0 0)
|
||||
(export "test" (func $test))
|
||||
(func $test (; 0 ;) (type $i) (param $0 i32) (result i32)
|
||||
(if (result i32)
|
||||
(i32.eqz
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.const 0)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
Reference in New Issue
Block a user