summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-01-08 14:51:52 -0800
committerAlon Zakai <alonzakai@gmail.com>2016-01-08 14:51:52 -0800
commita695f82586d452dfc7ba51c18a5b76aa0cd8fb22 (patch)
treec690004c6d369119641dc46462437e0d7fe00013
parentff29d891b7b58376712a48152b0a1406b08d5fd7 (diff)
downloadbinaryen-a695f82586d452dfc7ba51c18a5b76aa0cd8fb22.tar.gz
binaryen-a695f82586d452dfc7ba51c18a5b76aa0cd8fb22.tar.bz2
binaryen-a695f82586d452dfc7ba51c18a5b76aa0cd8fb22.zip
add a testcase
-rw-r--r--test/two_sides.asm.js30
-rw-r--r--test/two_sides.fromasm85
2 files changed, 115 insertions, 0 deletions
diff --git a/test/two_sides.asm.js b/test/two_sides.asm.js
new file mode 100644
index 000000000..cb45ac6fa
--- /dev/null
+++ b/test/two_sides.asm.js
@@ -0,0 +1,30 @@
+Module["asm"] = (function(global, env, buffer) {
+ "use asm";
+ var Math_imul = global.Math.imul;
+ function _test(i1, i2, i3, i4, i5) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var d6 = 0.0;
+ if (!i5) {
+ d6 = +(Math_imul(i4, i3) | 0);
+ d6 = (+(i3 | 0) + d6) * (+(i4 | 0) + d6);
+ i5 = ~~d6;
+ return i5 | 0;
+ } else {
+ d6 = +(Math_imul(i2, i1) | 0);
+ d6 = (+(i3 | 0) + d6) * (d6 + +(i4 | 0));
+ i5 = ~~d6;
+ return i5 | 0;
+ }
+ return 0;
+ }
+ return {
+ _test: _test
+ };
+});
+
+
+
diff --git a/test/two_sides.fromasm b/test/two_sides.fromasm
new file mode 100644
index 000000000..49cd25218
--- /dev/null
+++ b/test/two_sides.fromasm
@@ -0,0 +1,85 @@
+(module
+ (memory 16777216 16777216)
+ (import $f64-to-int "asm2wasm" "f64-to-int" (param f64) (result i32))
+ (export "_test" $_test)
+ (func $_test (param $i1 i32) (param $i2 i32) (param $i3 i32) (param $i4 i32) (param $i5 i32) (result i32)
+ (local $d6 f64)
+ (block $topmost
+ (if_else
+ (i32.eq
+ (get_local $i5)
+ (i32.const 0)
+ )
+ (block
+ (set_local $d6
+ (f64.convert_s/i32
+ (i32.mul
+ (get_local $i4)
+ (get_local $i3)
+ )
+ )
+ )
+ (set_local $d6
+ (f64.mul
+ (f64.add
+ (f64.convert_s/i32
+ (get_local $i3)
+ )
+ (get_local $d6)
+ )
+ (f64.add
+ (f64.convert_s/i32
+ (get_local $i4)
+ )
+ (get_local $d6)
+ )
+ )
+ )
+ (set_local $i5
+ (call_import $f64-to-int
+ (get_local $d6)
+ )
+ )
+ (br $topmost
+ (get_local $i5)
+ )
+ )
+ (block
+ (set_local $d6
+ (f64.convert_s/i32
+ (i32.mul
+ (get_local $i2)
+ (get_local $i1)
+ )
+ )
+ )
+ (set_local $d6
+ (f64.mul
+ (f64.add
+ (f64.convert_s/i32
+ (get_local $i3)
+ )
+ (get_local $d6)
+ )
+ (f64.add
+ (get_local $d6)
+ (f64.convert_s/i32
+ (get_local $i4)
+ )
+ )
+ )
+ )
+ (set_local $i5
+ (call_import $f64-to-int
+ (get_local $d6)
+ )
+ )
+ (br $topmost
+ (get_local $i5)
+ )
+ )
+ )
+ (i32.const 0)
+ )
+ )
+)