summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/emcc_hello_world.fromasm12
-rw-r--r--test/emcc_hello_world.fromasm.clamp12
-rw-r--r--test/passes/Oz.txt25
-rw-r--r--test/passes/Oz.wast9
-rw-r--r--test/passes/inlining-optimizing_optimize-level=3.txt492
-rw-r--r--test/passes/precompute-propagate.txt214
-rw-r--r--test/passes/precompute-propagate.wast113
-rw-r--r--test/unit.asm.js61
-rw-r--r--test/unit.fromasm117
-rw-r--r--test/unit.fromasm.clamp117
-rw-r--r--test/unit.fromasm.clamp.no-opts98
-rw-r--r--test/unit.fromasm.imprecise96
-rw-r--r--test/unit.fromasm.imprecise.no-opts98
-rw-r--r--test/unit.fromasm.no-opts98
-rw-r--r--test/wasm-only.fromasm70
-rw-r--r--test/wasm-only.fromasm.clamp70
16 files changed, 1064 insertions, 638 deletions
diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm
index e96288365..39e161495 100644
--- a/test/emcc_hello_world.fromasm
+++ b/test/emcc_hello_world.fromasm
@@ -5099,15 +5099,9 @@
(i32.lt_s
(tee_local $6
(i32.add
- (if (result i32)
- (tee_local $12
- (i32.const 9)
- )
- (i32.rem_s
- (get_local $6)
- (get_local $12)
- )
- (i32.const 0)
+ (i32.rem_s
+ (get_local $6)
+ (i32.const 9)
)
(i32.const 1)
)
diff --git a/test/emcc_hello_world.fromasm.clamp b/test/emcc_hello_world.fromasm.clamp
index 7ae8bb801..b074afa30 100644
--- a/test/emcc_hello_world.fromasm.clamp
+++ b/test/emcc_hello_world.fromasm.clamp
@@ -5123,15 +5123,9 @@
(i32.lt_s
(tee_local $6
(i32.add
- (if (result i32)
- (tee_local $12
- (i32.const 9)
- )
- (i32.rem_s
- (get_local $6)
- (get_local $12)
- )
- (i32.const 0)
+ (i32.rem_s
+ (get_local $6)
+ (i32.const 9)
)
(i32.const 1)
)
diff --git a/test/passes/Oz.txt b/test/passes/Oz.txt
index c67106326..c76cc0e5c 100644
--- a/test/passes/Oz.txt
+++ b/test/passes/Oz.txt
@@ -1,6 +1,6 @@
(module
(type $0 (func (param i32 i32) (result i32)))
- (type $1 (func (param i32) (result i32)))
+ (type $1 (func (param i32 i32 i32 i32) (result i32)))
(memory $0 100 100)
(export "localcse" (func $basics))
(export "localcse-2" (func $8))
@@ -16,11 +16,11 @@
(get_local $2)
)
)
- (func $8 (type $1) (param $0 i32) (result i32)
- (local $1 i32)
+ (func $8 (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (local $4 i32)
(i32.store
- (tee_local $0
- (tee_local $1
+ (tee_local $2
+ (tee_local $4
(i32.add
(get_local $1)
(i32.const 4)
@@ -29,26 +29,23 @@
)
(i32.and
(i32.load
- (get_local $0)
+ (get_local $2)
)
(i32.xor
- (tee_local $0
- (i32.const 74)
- )
+ (i32.const 74)
(i32.const -1)
)
)
)
(i32.store
- (get_local $1)
+ (tee_local $1
+ (get_local $4)
+ )
(i32.or
(i32.load
(get_local $1)
)
- (i32.and
- (get_local $0)
- (i32.const 8)
- )
+ (i32.const 8)
)
)
(i32.const 0)
diff --git a/test/passes/Oz.wast b/test/passes/Oz.wast
index 2bb8934c4..5ba6a7ea5 100644
--- a/test/passes/Oz.wast
+++ b/test/passes/Oz.wast
@@ -11,10 +11,11 @@
)
(i32.add (get_local $x2) (get_local $y2))
)
- (func $8 (export "localcse-2") (param $var$0 i32) (result i32)
- (local $var$1 i32)
- (local $var$2 i32)
- (local $var$3 i32)
+ (func $8 (export "localcse-2") (param $var$0 i32)
+ (param $var$1 i32)
+ (param $var$2 i32)
+ (param $var$3 i32)
+ (result i32)
(block $label$0 (result i32)
(i32.store
(tee_local $var$2
diff --git a/test/passes/inlining-optimizing_optimize-level=3.txt b/test/passes/inlining-optimizing_optimize-level=3.txt
index 711451bcd..d9583cbb3 100644
--- a/test/passes/inlining-optimizing_optimize-level=3.txt
+++ b/test/passes/inlining-optimizing_optimize-level=3.txt
@@ -2231,7 +2231,6 @@
(local $49 i32)
(local $50 i32)
(local $51 i32)
- (local $52 i32)
(set_local $26
(get_global $STACKTOP)
)
@@ -2263,7 +2262,7 @@
(i32.const 528)
)
)
- (set_local $31
+ (set_local $30
(i32.ne
(get_local $0)
(i32.const 0)
@@ -2288,7 +2287,7 @@
(i32.const 39)
)
)
- (set_local $47
+ (set_local $46
(i32.add
(tee_local $43
(i32.add
@@ -2316,7 +2315,7 @@
(i32.const 11)
)
)
- (set_local $48
+ (set_local $47
(i32.sub
(tee_local $29
(get_local $36)
@@ -2331,21 +2330,21 @@
)
)
)
- (set_local $49
+ (set_local $48
(i32.sub
(i32.const -2)
(get_local $39)
)
)
- (set_local $50
+ (set_local $49
(i32.add
(get_local $29)
(i32.const 2)
)
)
- (set_local $52
+ (set_local $51
(i32.add
- (tee_local $51
+ (tee_local $50
(i32.add
(get_local $26)
(i32.const 24)
@@ -2355,7 +2354,7 @@
)
)
(set_local $45
- (tee_local $32
+ (tee_local $31
(i32.add
(get_local $24)
(i32.const 9)
@@ -2374,7 +2373,7 @@
(set_local $5
(get_local $1)
)
- (set_local $11
+ (set_local $10
(i32.const 0)
)
(set_local $1
@@ -2392,7 +2391,7 @@
(set_local $16
(if (result i32)
(i32.gt_s
- (get_local $11)
+ (get_local $10)
(i32.sub
(i32.const 2147483647)
(get_local $16)
@@ -2414,7 +2413,7 @@
(i32.const -1)
)
(i32.add
- (get_local $11)
+ (get_local $10)
(get_local $16)
)
)
@@ -2429,7 +2428,7 @@
)
)
)
- (set_local $11
+ (set_local $10
(get_local $5)
)
(block $label$break$L12
@@ -2450,20 +2449,20 @@
)
)
(set_local $6
- (get_local $11)
+ (get_local $10)
)
(br $__rjti$1)
)
(set_local $6
- (get_local $11)
+ (get_local $10)
)
(br $label$break$L9)
)
(set_local $7
(i32.load8_s
- (tee_local $11
+ (tee_local $10
(i32.add
- (get_local $11)
+ (get_local $10)
(i32.const 1)
)
)
@@ -2483,9 +2482,9 @@
(i32.const 37)
)
)
- (set_local $11
+ (set_local $10
(i32.add
- (get_local $11)
+ (get_local $10)
(i32.const 1)
)
)
@@ -2506,12 +2505,12 @@
)
(set_local $7
(i32.sub
- (get_local $11)
+ (get_local $10)
(get_local $5)
)
)
(if
- (get_local $31)
+ (get_local $30)
(if
(i32.eqz
(i32.and
@@ -2532,14 +2531,14 @@
)
(if
(i32.ne
- (get_local $11)
+ (get_local $10)
(get_local $5)
)
(block
(set_local $5
(get_local $6)
)
- (set_local $11
+ (set_local $10
(get_local $7)
)
(br $label$continue$L1)
@@ -2552,7 +2551,7 @@
(i32.add
(tee_local $12
(i32.load8_s
- (tee_local $11
+ (tee_local $10
(i32.add
(get_local $6)
(i32.const 1)
@@ -2568,13 +2567,13 @@
(block (result i32)
(set_local $6
(i32.load8_s
- (tee_local $11
+ (tee_local $10
(select
(i32.add
(get_local $6)
(i32.const 3)
)
- (get_local $11)
+ (get_local $10)
(tee_local $12
(i32.eq
(i32.load8_s offset=2
@@ -2686,9 +2685,9 @@
(tee_local $6
(tee_local $1
(i32.load8_s
- (tee_local $11
+ (tee_local $10
(i32.add
- (get_local $11)
+ (get_local $10)
(i32.const 1)
)
)
@@ -2723,7 +2722,7 @@
(i32.const 42)
)
(block
- (set_local $11
+ (set_local $10
(block $__rjto$0 (result i32)
(block $__rjti$0
(br_if $__rjti$0
@@ -2733,7 +2732,7 @@
(i32.load8_s
(tee_local $6
(i32.add
- (get_local $11)
+ (get_local $10)
(i32.const 1)
)
)
@@ -2747,7 +2746,7 @@
(br_if $__rjti$0
(i32.ne
(i32.load8_s offset=2
- (get_local $11)
+ (get_local $10)
)
(i32.const 36)
)
@@ -2790,7 +2789,7 @@
)
(br $__rjto$0
(i32.add
- (get_local $11)
+ (get_local $10)
(i32.const 3)
)
)
@@ -2806,13 +2805,13 @@
)
(if
(i32.eqz
- (get_local $31)
+ (get_local $30)
)
(block
(set_local $12
(get_local $1)
)
- (set_local $11
+ (set_local $10
(get_local $6)
)
(set_local $1
@@ -2826,7 +2825,7 @@
)
(set_local $14
(i32.load
- (tee_local $11
+ (tee_local $10
(i32.and
(i32.add
(i32.load
@@ -2842,7 +2841,7 @@
(i32.store
(get_local $2)
(i32.add
- (get_local $11)
+ (get_local $10)
(i32.const 4)
)
)
@@ -2912,9 +2911,9 @@
(tee_local $9
(i32.add
(i32.load8_s
- (tee_local $11
+ (tee_local $10
(i32.add
- (get_local $11)
+ (get_local $10)
(i32.const 1)
)
)
@@ -2978,7 +2977,7 @@
(if (result i32)
(i32.eq
(i32.load8_s
- (get_local $11)
+ (get_local $10)
)
(i32.const 46)
)
@@ -2989,7 +2988,7 @@
(i32.load8_s
(tee_local $6
(i32.add
- (get_local $11)
+ (get_local $10)
(i32.const 1)
)
)
@@ -3009,7 +3008,7 @@
(i32.const 10)
)
(block
- (set_local $11
+ (set_local $10
(get_local $6)
)
(set_local $8
@@ -3020,7 +3019,7 @@
)
)
(block
- (set_local $11
+ (set_local $10
(get_local $6)
)
(br $label$break$L46
@@ -3044,9 +3043,9 @@
(tee_local $9
(i32.add
(i32.load8_s
- (tee_local $11
+ (tee_local $10
(i32.add
- (get_local $11)
+ (get_local $10)
(i32.const 1)
)
)
@@ -3075,7 +3074,7 @@
(i32.load8_s
(tee_local $6
(i32.add
- (get_local $11)
+ (get_local $10)
(i32.const 2)
)
)
@@ -3088,7 +3087,7 @@
(if
(i32.eq
(i32.load8_s offset=3
- (get_local $11)
+ (get_local $10)
)
(i32.const 36)
)
@@ -3121,9 +3120,9 @@
)
)
)
- (set_local $11
+ (set_local $10
(i32.add
- (get_local $11)
+ (get_local $10)
(i32.const 4)
)
)
@@ -3145,11 +3144,11 @@
)
)
(if (result i32)
- (get_local $31)
+ (get_local $30)
(block (result i32)
(set_local $8
(i32.load
- (tee_local $11
+ (tee_local $10
(i32.and
(i32.add
(i32.load
@@ -3165,17 +3164,17 @@
(i32.store
(get_local $2)
(i32.add
- (get_local $11)
+ (get_local $10)
(i32.const 4)
)
)
- (set_local $11
+ (set_local $10
(get_local $6)
)
(get_local $8)
)
(block (result i32)
- (set_local $11
+ (set_local $10
(get_local $6)
)
(i32.const 0)
@@ -3187,7 +3186,7 @@
)
)
(set_local $8
- (get_local $11)
+ (get_local $10)
)
(set_local $9
(i32.const 0)
@@ -3195,7 +3194,7 @@
(loop $while-in13
(if
(i32.gt_u
- (tee_local $10
+ (tee_local $11
(i32.add
(i32.load8_s
(get_local $8)
@@ -3212,7 +3211,7 @@
(br $label$break$L1)
)
)
- (set_local $11
+ (set_local $10
(i32.add
(get_local $8)
(i32.const 1)
@@ -3221,7 +3220,7 @@
(if
(i32.lt_u
(i32.add
- (tee_local $10
+ (tee_local $11
(i32.and
(tee_local $13
(i32.load8_s
@@ -3233,7 +3232,7 @@
)
(i32.const 3611)
)
- (get_local $10)
+ (get_local $11)
)
)
)
@@ -3246,10 +3245,10 @@
)
(block
(set_local $8
- (get_local $11)
+ (get_local $10)
)
(set_local $9
- (get_local $10)
+ (get_local $11)
)
(br $while-in13)
)
@@ -3310,11 +3309,11 @@
(i32.const 2)
)
)
- (get_local $10)
+ (get_local $11)
)
(set_local $13
(i32.load offset=4
- (tee_local $10
+ (tee_local $11
(i32.add
(get_local $3)
(i32.shl
@@ -3330,7 +3329,7 @@
(get_local $19)
)
(i32.load
- (get_local $10)
+ (get_local $11)
)
)
(i32.store offset=4
@@ -3342,7 +3341,7 @@
)
(if
(i32.eqz
- (get_local $31)
+ (get_local $30)
)
(block
(set_local $16
@@ -3353,7 +3352,7 @@
)
(call $_pop_arg_336
(get_local $19)
- (get_local $10)
+ (get_local $11)
(get_local $2)
)
)
@@ -3362,13 +3361,13 @@
)
(if
(i32.eqz
- (get_local $31)
+ (get_local $30)
)
(block
(set_local $5
- (get_local $11)
+ (get_local $10)
)
- (set_local $11
+ (set_local $10
(get_local $7)
)
(br $label$continue$L1)
@@ -3416,14 +3415,14 @@
(tee_local $18
(select
(i32.and
- (tee_local $10
+ (tee_local $11
(i32.load8_s
(get_local $18)
)
)
(i32.const -33)
)
- (get_local $10)
+ (get_local $11)
(i32.and
(i32.ne
(get_local $9)
@@ -3431,7 +3430,7 @@
)
(i32.eq
(i32.and
- (get_local $10)
+ (get_local $11)
(i32.const 15)
)
(i32.const 3)
@@ -3462,9 +3461,9 @@
(get_local $16)
)
(set_local $5
- (get_local $11)
+ (get_local $10)
)
- (set_local $11
+ (set_local $10
(get_local $7)
)
(br $label$continue$L1)
@@ -3476,9 +3475,9 @@
(get_local $16)
)
(set_local $5
- (get_local $11)
+ (get_local $10)
)
- (set_local $11
+ (set_local $10
(get_local $7)
)
(br $label$continue$L1)
@@ -3505,9 +3504,9 @@
)
)
(set_local $5
- (get_local $11)
+ (get_local $10)
)
- (set_local $11
+ (set_local $10
(get_local $7)
)
(br $label$continue$L1)
@@ -3519,9 +3518,9 @@
(get_local $16)
)
(set_local $5
- (get_local $11)
+ (get_local $10)
)
- (set_local $11
+ (set_local $10
(get_local $7)
)
(br $label$continue$L1)
@@ -3533,9 +3532,9 @@
(get_local $16)
)
(set_local $5
- (get_local $11)
+ (get_local $10)
)
- (set_local $11
+ (set_local $10
(get_local $7)
)
(br $label$continue$L1)
@@ -3547,9 +3546,9 @@
(get_local $16)
)
(set_local $5
- (get_local $11)
+ (get_local $10)
)
- (set_local $11
+ (set_local $10
(get_local $7)
)
(br $label$continue$L1)
@@ -3576,17 +3575,17 @@
)
)
(set_local $5
- (get_local $11)
+ (get_local $10)
)
- (set_local $11
+ (set_local $10
(get_local $7)
)
(br $label$continue$L1)
)
(set_local $5
- (get_local $11)
+ (get_local $10)
)
- (set_local $11
+ (set_local $10
(get_local $7)
)
(br $label$continue$L1)
@@ -3754,16 +3753,12 @@
(set_global $tempRet0
(i32.sub
(i32.sub
- (tee_local $9
- (i32.const 0)
- )
+ (i32.const 0)
(get_local $7)
)
(i32.gt_u
(get_local $5)
- (tee_local $10
- (i32.const 0)
- )
+ (i32.const 0)
)
)
)
@@ -3773,7 +3768,7 @@
)
(tee_local $5
(i32.sub
- (get_local $10)
+ (i32.const 0)
(get_local $5)
)
)
@@ -3863,7 +3858,7 @@
(set_local $12
(get_local $8)
)
- (set_local $10
+ (set_local $11
(i32.const 1)
)
(set_local $8
@@ -3920,7 +3915,7 @@
)
)
(i32.store
- (get_local $47)
+ (get_local $46)
(i32.const 0)
)
(i32.store
@@ -3973,7 +3968,7 @@
(get_global $tempDoublePtr)
)
)
- (set_local $33
+ (set_local $32
(if (result i32)
(i32.lt_s
(i32.load offset=4
@@ -4093,10 +4088,10 @@
(set_local $9
(select
(i32.add
- (get_local $33)
+ (get_local $32)
(i32.const 9)
)
- (get_local $33)
+ (get_local $32)
(tee_local $13
(i32.and
(get_local $18)
@@ -4217,7 +4212,7 @@
)
)
)
- (set_local $10
+ (set_local $11
(i32.or
(get_local $28)
(i32.const 2)
@@ -4380,14 +4375,14 @@
(select
(i32.sub
(i32.add
- (get_local $50)
+ (get_local $49)
(get_local $6)
)
(get_local $8)
)
(i32.add
(i32.sub
- (get_local $48)
+ (get_local $47)
(get_local $8)
)
(get_local $5)
@@ -4399,7 +4394,7 @@
)
(i32.lt_s
(i32.add
- (get_local $49)
+ (get_local $48)
(get_local $5)
)
(get_local $6)
@@ -4407,7 +4402,7 @@
)
)
)
- (get_local $10)
+ (get_local $11)
)
)
(get_local $12)
@@ -4424,7 +4419,7 @@
(drop
(call $___fwritex
(get_local $9)
- (get_local $10)
+ (get_local $11)
(get_local $0)
)
)
@@ -4552,8 +4547,8 @@
(set_local $7
(tee_local $8
(select
+ (get_local $50)
(get_local $51)
- (get_local $52)
(i32.lt_s
(get_local $5)
(i32.const 0)
@@ -4652,7 +4647,7 @@
(get_local $5)
)
(block
- (set_local $10
+ (set_local $11
(i32.const 0)
)
(loop $while-in66
@@ -4675,23 +4670,21 @@
(tee_local $23
(get_global $tempRet0)
)
- (tee_local $30
- (i32.const 0)
- )
+ (i32.const 0)
)
(i32.lt_u
- (tee_local $10
+ (tee_local $11
(i32.add
(get_local $21)
- (get_local $10)
+ (get_local $11)
)
)
(get_local $21)
)
)
)
- (tee_local $10
- (get_local $10)
+ (tee_local $11
+ (get_local $11)
)
)
(tee_local $17
@@ -4701,9 +4694,9 @@
(i32.const 0)
)
)
- (set_local $10
+ (set_local $11
(call $___udivdi3
- (get_local $10)
+ (get_local $11)
(get_local $17)
(i32.const 1000000000)
(i32.const 0)
@@ -4723,7 +4716,7 @@
)
(br_if $do-once63
(i32.eqz
- (get_local $10)
+ (get_local $11)
)
)
(i32.store
@@ -4733,7 +4726,7 @@
(i32.const -4)
)
)
- (get_local $10)
+ (get_local $11)
)
)
)
@@ -4812,32 +4805,23 @@
(set_local $21
(i32.add
(if (result i32)
- (tee_local $10
- (i32.const 9)
- )
- (if (result i32)
- (i32.and
- (i32.eq
- (get_local $6)
- (i32.const -2147483648)
- )
- (i32.eq
- (get_local $10)
- (i32.const -1)
- )
- )
- (i32.const 0)
- (i32.div_s
+ (i32.and
+ (i32.eq
(get_local $6)
- (get_local $10)
+ (i32.const -2147483648)
)
+ (i32.const 0)
)
(i32.const 0)
+ (i32.div_s
+ (get_local $6)
+ (i32.const 9)
+ )
)
(i32.const 1)
)
)
- (set_local $34
+ (set_local $33
(i32.eq
(get_local $25)
(i32.const 102)
@@ -4872,7 +4856,7 @@
(get_local $5)
)
(block
- (set_local $10
+ (set_local $11
(i32.add
(i32.shl
(i32.const 1)
@@ -4898,7 +4882,7 @@
(get_local $7)
(i32.add
(i32.shr_u
- (tee_local $35
+ (tee_local $34
(i32.load
(get_local $7)
)
@@ -4911,8 +4895,8 @@
(set_local $9
(i32.mul
(i32.and
- (get_local $35)
- (get_local $10)
+ (get_local $34)
+ (get_local $11)
)
(get_local $40)
)
@@ -4971,14 +4955,14 @@
)
)
)
- (set_local $10
+ (set_local $11
(select
(i32.add
(tee_local $6
(select
(get_local $8)
(get_local $7)
- (get_local $34)
+ (get_local $33)
)
)
(i32.shl
@@ -5020,7 +5004,7 @@
(get_local $7)
)
(set_local $5
- (get_local $10)
+ (get_local $11)
)
(br $while-in70)
)
@@ -5029,7 +5013,7 @@
(get_local $7)
)
(set_local $9
- (get_local $10)
+ (get_local $11)
)
)
)
@@ -5063,7 +5047,7 @@
)
(br_if $do-once75
(i32.lt_u
- (tee_local $10
+ (tee_local $11
(i32.load
(get_local $5)
)
@@ -5083,7 +5067,7 @@
)
(br_if $while-in78
(i32.ge_u
- (get_local $10)
+ (get_local $11)
(tee_local $6
(i32.mul
(get_local $6)
@@ -5118,7 +5102,7 @@
(i32.shr_s
(i32.shl
(i32.and
- (tee_local $34
+ (tee_local $33
(i32.ne
(get_local $17)
(i32.const 0)
@@ -5152,7 +5136,7 @@
)
)
(block (result i32)
- (set_local $10
+ (set_local $11
(tee_local $6
(i32.add
(get_local $6)
@@ -5162,42 +5146,27 @@
)
(set_local $13
(if (result i32)
- (tee_local $13
- (i32.const 9)
- )
- (if (result i32)
- (i32.and
- (i32.eq
- (get_local $10)
- (i32.const -2147483648)
- )
- (i32.eq
- (get_local $13)
- (i32.const -1)
- )
+ (i32.and
+ (i32.eq
+ (get_local $11)
+ (i32.const -2147483648)
)
(i32.const 0)
- (i32.div_s
- (get_local $10)
- (get_local $13)
- )
)
(i32.const 0)
+ (i32.div_s
+ (get_local $11)
+ (i32.const 9)
+ )
)
)
(if
(i32.lt_s
(tee_local $6
(i32.add
- (if (result i32)
- (tee_local $10
- (i32.const 9)
- )
- (i32.rem_s
- (get_local $6)
- (get_local $10)
- )
- (i32.const 0)
+ (i32.rem_s
+ (get_local $6)
+ (i32.const 9)
)
(i32.const 1)
)
@@ -5205,13 +5174,13 @@
(i32.const 9)
)
(block
- (set_local $10
+ (set_local $11
(i32.const 10)
)
(loop $while-in80
- (set_local $10
+ (set_local $11
(i32.mul
- (get_local $10)
+ (get_local $11)
(i32.const 10)
)
)
@@ -5228,7 +5197,7 @@
)
)
)
- (set_local $10
+ (set_local $11
(i32.const 10)
)
)
@@ -5253,7 +5222,7 @@
(set_local $13
(if (result i32)
(tee_local $13
- (get_local $10)
+ (get_local $11)
)
(i32.rem_u
(get_local $23)
@@ -5266,7 +5235,7 @@
(if
(i32.eqz
(i32.and
- (tee_local $35
+ (tee_local $34
(i32.eq
(i32.add
(get_local $6)
@@ -5284,14 +5253,14 @@
(set_local $23
(get_local $25)
)
- (set_local $30
+ (set_local $35
(if (result i32)
- (tee_local $30
- (get_local $10)
+ (tee_local $35
+ (get_local $11)
)
(i32.div_u
(get_local $23)
- (get_local $30)
+ (get_local $35)
)
(i32.const 0)
)
@@ -5300,33 +5269,24 @@
(if (result f64)
(block (result i32)
(set_local $23
- (get_local $10)
+ (get_local $11)
)
(i32.lt_u
(get_local $13)
(tee_local $23
(if (result i32)
- (tee_local $46
- (i32.const 2)
- )
- (if (result i32)
- (i32.and
- (i32.eq
- (get_local $23)
- (i32.const -2147483648)
- )
- (i32.eq
- (get_local $46)
- (i32.const -1)
- )
- )
- (i32.const 0)
- (i32.div_s
+ (i32.and
+ (i32.eq
(get_local $23)
- (get_local $46)
+ (i32.const -2147483648)
)
+ (i32.const 0)
)
(i32.const 0)
+ (i32.div_s
+ (get_local $23)
+ (i32.const 2)
+ )
)
)
)
@@ -5336,7 +5296,7 @@
(f64.const 1)
(f64.const 1.5)
(i32.and
- (get_local $35)
+ (get_local $34)
(i32.eq
(get_local $13)
(get_local $23)
@@ -5350,7 +5310,7 @@
(f64.const 9007199254740994)
(f64.const 9007199254740992)
(i32.and
- (get_local $30)
+ (get_local $35)
(i32.const 1)
)
)
@@ -5362,7 +5322,7 @@
(br_if $do-once83
(i32.ne
(i32.load8_s
- (get_local $33)
+ (get_local $32)
)
(i32.const 45)
)
@@ -5403,7 +5363,7 @@
(tee_local $7
(i32.add
(get_local $13)
- (get_local $10)
+ (get_local $11)
)
)
)
@@ -5478,7 +5438,7 @@
(i32.const 10)
)
)
- (set_local $10
+ (set_local $11
(i32.const 10)
)
(loop $while-in88
@@ -5491,9 +5451,9 @@
(br_if $while-in88
(i32.ge_u
(get_local $13)
- (tee_local $10
+ (tee_local $11
(i32.mul
- (get_local $10)
+ (get_local $11)
(i32.const 10)
)
)
@@ -5503,7 +5463,7 @@
)
)
)
- (set_local $10
+ (set_local $11
(get_local $5)
)
(set_local $13
@@ -5524,7 +5484,7 @@
)
)
(block (result i32)
- (set_local $10
+ (set_local $11
(get_local $5)
)
(set_local $13
@@ -5534,7 +5494,7 @@
)
)
)
- (set_local $35
+ (set_local $34
(i32.sub
(i32.const 0)
(get_local $13)
@@ -5545,7 +5505,7 @@
(if
(i32.le_u
(get_local $5)
- (get_local $10)
+ (get_local $11)
)
(block
(set_local $25
@@ -5607,7 +5567,7 @@
(tee_local $5
(i32.add
(i32.xor
- (get_local $34)
+ (get_local $33)
(i32.const 1)
)
(get_local $17)
@@ -5692,15 +5652,9 @@
(set_local $5
(get_local $18)
)
- (if (result i32)
- (tee_local $6
- (i32.const 10)
- )
- (i32.rem_u
- (get_local $5)
- (get_local $6)
- )
- (i32.const 0)
+ (i32.rem_u
+ (get_local $5)
+ (i32.const 10)
)
)
(block
@@ -5731,7 +5685,7 @@
(br_if $while-in96
(i32.eqz
(if (result i32)
- (tee_local $30
+ (tee_local $35
(tee_local $6
(i32.mul
(get_local $6)
@@ -5741,7 +5695,7 @@
)
(i32.rem_u
(get_local $23)
- (get_local $30)
+ (get_local $35)
)
(i32.const 0)
)
@@ -5853,7 +5807,7 @@
)
)
(i32.ne
- (tee_local $34
+ (tee_local $33
(i32.or
(get_local $5)
(get_local $21)
@@ -5894,7 +5848,7 @@
(call $_fmt_u
(tee_local $6
(select
- (get_local $35)
+ (get_local $34)
(get_local $13)
(i32.lt_s
(get_local $13)
@@ -5988,7 +5942,7 @@
)
(drop
(call $___fwritex
- (get_local $33)
+ (get_local $32)
(get_local $28)
(get_local $0)
)
@@ -6009,12 +5963,12 @@
(get_local $17)
(block
(set_local $6
- (tee_local $10
+ (tee_local $11
(select
(get_local $8)
- (get_local $10)
+ (get_local $11)
(i32.gt_u
- (get_local $10)
+ (get_local $11)
(get_local $8)
)
)
@@ -6027,20 +5981,20 @@
(get_local $6)
)
(i32.const 0)
- (get_local $32)
+ (get_local $31)
)
)
(block $do-once103
(if
(i32.eq
(get_local $6)
- (get_local $10)
+ (get_local $11)
)
(block
(br_if $do-once103
(i32.ne
(get_local $7)
- (get_local $32)
+ (get_local $31)
)
)
(i32.store8
@@ -6118,7 +6072,7 @@
)
(block $do-once107
(if
- (get_local $34)
+ (get_local $33)
(block
(br_if $do-once107
(i32.and
@@ -6158,7 +6112,7 @@
(get_local $7)
)
(i32.const 0)
- (get_local $32)
+ (get_local $31)
)
)
(get_local $24)
@@ -6255,7 +6209,7 @@
(select
(get_local $9)
(i32.add
- (get_local $10)
+ (get_local $11)
(i32.const 4)
)
(get_local $25)
@@ -6273,7 +6227,7 @@
)
)
(set_local $6
- (get_local $10)
+ (get_local $11)
)
(set_local $7
(get_local $5)
@@ -6287,10 +6241,10 @@
(get_local $6)
)
(i32.const 0)
- (get_local $32)
+ (get_local $31)
)
)
- (get_local $32)
+ (get_local $31)
)
(block
(i32.store8
@@ -6306,7 +6260,7 @@
(if
(i32.eq
(get_local $6)
- (get_local $10)
+ (get_local $11)
)
(block
(if
@@ -6533,7 +6487,7 @@
(block
(drop
(call $___fwritex
- (get_local $33)
+ (get_local $32)
(get_local $9)
(get_local $0)
)
@@ -6606,9 +6560,9 @@
)
)
(set_local $5
- (get_local $11)
+ (get_local $10)
)
- (set_local $11
+ (set_local $10
(get_local $7)
)
(br $label$continue$L1)
@@ -6616,7 +6570,7 @@
(set_local $7
(get_local $5)
)
- (set_local $10
+ (set_local $11
(get_local $6)
)
(set_local $8
@@ -6795,7 +6749,7 @@
(set_local $12
(get_local $8)
)
- (set_local $10
+ (set_local $11
(select
(get_local $6)
(i32.sub
@@ -7001,9 +6955,9 @@
)
)
(set_local $5
- (get_local $11)
+ (get_local $10)
)
- (set_local $11
+ (set_local $10
(select
(get_local $14)
(get_local $7)
@@ -7028,11 +6982,11 @@
)
)
)
- (set_local $10
+ (set_local $11
(if (result i32)
(i32.or
(get_local $6)
- (tee_local $10
+ (tee_local $11
(i32.or
(i32.ne
(i32.load
@@ -7061,7 +7015,7 @@
(i32.add
(i32.xor
(i32.and
- (get_local $10)
+ (get_local $11)
(i32.const 1)
)
(i32.const 1)
@@ -7097,7 +7051,7 @@
(tee_local $5
(i32.add
(get_local $8)
- (tee_local $10
+ (tee_local $11
(select
(tee_local $13
(i32.sub
@@ -7105,9 +7059,9 @@
(get_local $7)
)
)
- (get_local $10)
+ (get_local $11)
(i32.lt_s
- (get_local $10)
+ (get_local $11)
(get_local $13)
)
)
@@ -7154,7 +7108,7 @@
(call $_pad
(get_local $0)
(i32.const 48)
- (get_local $10)
+ (get_local $11)
(get_local $13)
(i32.const 0)
)
@@ -7186,9 +7140,9 @@
)
)
(set_local $5
- (get_local $11)
+ (get_local $10)
)
- (set_local $11
+ (set_local $10
(get_local $6)
)
(br $label$continue$L1)
@@ -7797,15 +7751,9 @@
)
)
(i32.or
- (if (result i32)
- (tee_local $3
- (i32.const 10)
- )
- (i32.rem_u
- (get_local $1)
- (get_local $3)
- )
- (i32.const 0)
+ (i32.rem_u
+ (get_local $1)
+ (i32.const 10)
)
(i32.const 48)
)
@@ -7814,15 +7762,9 @@
(get_local $0)
)
(set_local $1
- (if (result i32)
- (tee_local $3
- (i32.const 10)
- )
- (i32.div_u
- (get_local $1)
- (get_local $3)
- )
- (i32.const 0)
+ (i32.div_u
+ (get_local $1)
+ (i32.const 10)
)
)
(if
diff --git a/test/passes/precompute-propagate.txt b/test/passes/precompute-propagate.txt
new file mode 100644
index 000000000..90b01be14
--- /dev/null
+++ b/test/passes/precompute-propagate.txt
@@ -0,0 +1,214 @@
+(module
+ (type $0 (func (param i32)))
+ (type $1 (func (param i32) (result i32)))
+ (memory $0 0)
+ (func $basic (type $0) (param $p i32)
+ (local $x i32)
+ (set_local $x
+ (i32.const 10)
+ )
+ (call $basic
+ (i32.const 20)
+ )
+ )
+ (func $split (type $0) (param $p i32)
+ (local $x i32)
+ (if
+ (i32.const 1)
+ (set_local $x
+ (i32.const 10)
+ )
+ )
+ (call $basic
+ (i32.add
+ (get_local $x)
+ (get_local $x)
+ )
+ )
+ )
+ (func $split-but-join (type $0) (param $p i32)
+ (local $x i32)
+ (if
+ (i32.const 1)
+ (set_local $x
+ (i32.const 10)
+ )
+ (set_local $x
+ (i32.const 10)
+ )
+ )
+ (call $basic
+ (i32.const 20)
+ )
+ )
+ (func $split-but-join-different (type $0) (param $p i32)
+ (local $x i32)
+ (if
+ (i32.const 1)
+ (set_local $x
+ (i32.const 10)
+ )
+ (set_local $x
+ (i32.const 20)
+ )
+ )
+ (call $basic
+ (i32.add
+ (get_local $x)
+ (get_local $x)
+ )
+ )
+ )
+ (func $split-but-join-different-b (type $0) (param $p i32)
+ (local $x i32)
+ (if
+ (i32.const 1)
+ (set_local $x
+ (i32.const 10)
+ )
+ (set_local $x
+ (get_local $p)
+ )
+ )
+ (call $basic
+ (i32.add
+ (get_local $x)
+ (get_local $x)
+ )
+ )
+ )
+ (func $split-but-join-init0 (type $0) (param $p i32)
+ (local $x i32)
+ (if
+ (i32.const 1)
+ (set_local $x
+ (i32.const 0)
+ )
+ )
+ (call $basic
+ (i32.const 0)
+ )
+ )
+ (func $later (type $0) (param $p i32)
+ (local $x i32)
+ (set_local $x
+ (i32.const 10)
+ )
+ (call $basic
+ (i32.const 20)
+ )
+ (set_local $x
+ (i32.const 22)
+ )
+ (call $basic
+ (i32.const 44)
+ )
+ (set_local $x
+ (i32.const 39)
+ )
+ )
+ (func $later2 (type $1) (param $p i32) (result i32)
+ (local $x i32)
+ (set_local $x
+ (i32.const 10)
+ )
+ (set_local $x
+ (i32.const 20)
+ )
+ (i32.const 20)
+ )
+ (func $two-ways-but-identical (type $1) (param $p i32) (result i32)
+ (local $x i32)
+ (local $y i32)
+ (set_local $x
+ (i32.const 10)
+ )
+ (if
+ (i32.const 1)
+ (set_local $y
+ (i32.const 11)
+ )
+ (set_local $y
+ (i32.const 11)
+ )
+ )
+ (set_local $y
+ (i32.const 21)
+ )
+ (i32.const 21)
+ )
+ (func $two-ways-but-almost-identical (type $1) (param $p i32) (result i32)
+ (local $x i32)
+ (local $y i32)
+ (set_local $x
+ (i32.const 10)
+ )
+ (if
+ (i32.const 1)
+ (set_local $y
+ (i32.const 12)
+ )
+ (set_local $y
+ (i32.const 11)
+ )
+ )
+ (set_local $y
+ (i32.add
+ (i32.const 10)
+ (get_local $y)
+ )
+ )
+ (get_local $y)
+ )
+ (func $deadloop (type $1) (param $p i32) (result i32)
+ (local $x i32)
+ (local $y i32)
+ (loop $loop
+ (set_local $x
+ (i32.const 0)
+ )
+ (set_local $y
+ (i32.const 0)
+ )
+ (br $loop)
+ )
+ )
+ (func $deadloop2 (type $0) (param $p i32)
+ (local $x i32)
+ (local $y i32)
+ (loop $loop
+ (set_local $x
+ (i32.const 0)
+ )
+ (set_local $y
+ (i32.const 0)
+ )
+ (call $deadloop2
+ (i32.const 0)
+ )
+ (call $deadloop2
+ (i32.const 0)
+ )
+ (br $loop)
+ )
+ )
+ (func $deadloop3 (type $0) (param $p i32)
+ (local $x i32)
+ (local $y i32)
+ (loop $loop
+ (set_local $x
+ (i32.const 0)
+ )
+ (set_local $y
+ (i32.const 0)
+ )
+ (call $deadloop2
+ (i32.const 0)
+ )
+ (call $deadloop2
+ (i32.const 0)
+ )
+ (br $loop)
+ )
+ )
+)
diff --git a/test/passes/precompute-propagate.wast b/test/passes/precompute-propagate.wast
new file mode 100644
index 000000000..af1a21ba2
--- /dev/null
+++ b/test/passes/precompute-propagate.wast
@@ -0,0 +1,113 @@
+(module
+ (func $basic (param $p i32)
+ (local $x i32)
+ (set_local $x (i32.const 10))
+ (call $basic (i32.add (get_local $x) (get_local $x)))
+ )
+ (func $split (param $p i32)
+ (local $x i32)
+ (if (i32.const 1)
+ (set_local $x (i32.const 10))
+ )
+ (call $basic (i32.add (get_local $x) (get_local $x)))
+ )
+ (func $split-but-join (param $p i32)
+ (local $x i32)
+ (if (i32.const 1)
+ (set_local $x (i32.const 10))
+ (set_local $x (i32.const 10))
+ )
+ (call $basic (i32.add (get_local $x) (get_local $x)))
+ )
+ (func $split-but-join-different (param $p i32)
+ (local $x i32)
+ (if (i32.const 1)
+ (set_local $x (i32.const 10))
+ (set_local $x (i32.const 20))
+ )
+ (call $basic (i32.add (get_local $x) (get_local $x)))
+ )
+ (func $split-but-join-different-b (param $p i32)
+ (local $x i32)
+ (if (i32.const 1)
+ (set_local $x (i32.const 10))
+ (set_local $x (get_local $p))
+ )
+ (call $basic (i32.add (get_local $x) (get_local $x)))
+ )
+ (func $split-but-join-init0 (param $p i32)
+ (local $x i32)
+ (if (i32.const 1)
+ (set_local $x (i32.const 0))
+ )
+ (call $basic (i32.add (get_local $x) (get_local $x)))
+ )
+ (func $later (param $p i32)
+ (local $x i32)
+ (set_local $x (i32.const 10))
+ (call $basic (i32.add (get_local $x) (get_local $x)))
+ (set_local $x (i32.const 22))
+ (call $basic (i32.add (get_local $x) (get_local $x)))
+ (set_local $x (i32.const 39))
+ )
+ (func $later2 (param $p i32) (result i32)
+ (local $x i32)
+ (set_local $x (i32.const 10))
+ (set_local $x (i32.add (get_local $x) (get_local $x)))
+ (get_local $x)
+ )
+ (func $two-ways-but-identical (param $p i32) (result i32)
+ (local $x i32)
+ (local $y i32)
+ (set_local $x (i32.const 10))
+ (if (i32.const 1)
+ (set_local $y (i32.const 11))
+ (set_local $y (i32.add (get_local $x) (i32.const 1)))
+ )
+ (set_local $y (i32.add (get_local $x) (get_local $y)))
+ (get_local $y)
+ )
+ (func $two-ways-but-almost-identical (param $p i32) (result i32)
+ (local $x i32)
+ (local $y i32)
+ (set_local $x (i32.const 10))
+ (if (i32.const 1)
+ (set_local $y (i32.const 12)) ;; 12, not 11...
+ (set_local $y (i32.add (get_local $x) (i32.const 1)))
+ )
+ (set_local $y (i32.add (get_local $x) (get_local $y)))
+ (get_local $y)
+ )
+ (func $deadloop (param $p i32) (result i32)
+ (local $x i32)
+ (local $y i32)
+ (loop $loop ;; we look like we depend on the other, but we don't actually
+ (set_local $x (if (result i32) (i32.const 1) (i32.const 0) (get_local $y)))
+ (set_local $y (if (result i32) (i32.const 1) (i32.const 0) (get_local $x)))
+ (br $loop)
+ )
+ )
+ (func $deadloop2 (param $p i32)
+ (local $x i32)
+ (local $y i32)
+ (loop $loop ;; we look like we depend on the other, but we don't actually
+ (set_local $x (if (result i32) (i32.const 1) (i32.const 0) (get_local $y)))
+ (set_local $y (if (result i32) (i32.const 1) (i32.const 0) (get_local $x)))
+ (call $deadloop2 (get_local $x))
+ (call $deadloop2 (get_local $y))
+ (br $loop)
+ )
+ )
+ (func $deadloop3 (param $p i32)
+ (local $x i32)
+ (local $y i32)
+ (loop $loop ;; we look like we depend on the other, but we don't actually
+ (set_local $x (if (result i32) (i32.const 1) (i32.const 0) (get_local $x)))
+ (set_local $y (if (result i32) (i32.const 1) (i32.const 0) (get_local $y)))
+ (call $deadloop2 (get_local $x))
+ (call $deadloop2 (get_local $y))
+ (br $loop)
+ )
+ )
+)
+
diff --git a/test/unit.asm.js b/test/unit.asm.js
index a1accabf5..ca7ac90e9 100644
--- a/test/unit.asm.js
+++ b/test/unit.asm.js
@@ -51,21 +51,25 @@ function asm(global, env, buffer) {
var t = 0.0;
var Int = 0.0, Double = 0; // confusing with globals
if (x > 0.0) return 1.2;
+ Int = x;
+ Double = n;
if (Int > 0.0) return -3.4;
if ((Double|0) > 0) return 5.6;
if (x < y) return +x;
return +y;
}
- function intOps() {
- var x = 0;
+ function intOps(x) {
+ x = x | 0;
return (!x) | 0;
}
function hexLiterals() {
var i = 0;
i = 0x0 + 0x12ABCdef + 0xFEDcba90 | 0;
}
- function conversions() {
- var i = 0, d = 0.0, f = Math_fround(0);
+ function conversions(i, d, f) {
+ i = i | 0;
+ d = +d;
+ f = Math_fround(f);
i = ~~d;
i = ~~f;
d = +(i | 0);
@@ -185,8 +189,9 @@ function asm(global, env, buffer) {
var $0 = 0;
($0>>>0) > 4294963200; // -4096
}
- function smallCompare() {
- var i = 0, j = 0;
+ function smallCompare(i, j) {
+ i = i | 0;
+ j = j | 0;
if ((i | 0) < (j | 0)) i = i + 1 | 0;
if ((i >>> 0) < (j >>> 0)) i = i + 1 | 0;
return i | 0;
@@ -432,6 +437,30 @@ function asm(global, env, buffer) {
return i$lcssa | 0
}
+ function loophi2b() {
+ var jnc = 0, i = 0, i$lcssa = 0, temp = 0, j = 0;
+ i = 0;
+ L7: while(1) {
+ j = 0;
+ while(1) {
+ temp = j;
+ if (return_int() | 0) {
+ if (temp) {
+ i$lcssa = j;
+ break L7;
+ }
+ }
+ jnc = j + 1 | 0;
+ if (jnc) {
+ j = jnc;
+ } else {
+ break;
+ }
+ }
+ }
+ return i$lcssa | 0
+ }
+
function relooperJumpThreading(x) {
x = x | 0;
var label = 0;
@@ -530,8 +559,15 @@ function asm(global, env, buffer) {
return x | 0;
}
- function relooperJumpThreading__ZN4game14preloadweaponsEv() {
- var $12 = 0, $14 = 0, $or$cond8 = 0, $or$cond6 = 0, $vararg_ptr5 = 0, $11 = 0, $exitcond = 0, label = 0;
+ function relooperJumpThreading__ZN4game14preloadweaponsEv($12, $14, $or$cond8, $or$cond6, $vararg_ptr5, $11, $exitcond) {
+ $12 = $12 | 0;
+ $14 = $14 | 0;
+ $or$cond8 = $or$cond8 | 0;
+ $or$cond6 = $or$cond6 | 0;
+ $vararg_ptr5 = $vararg_ptr5 | 0;
+ $11 = $11 | 0;
+ $exitcond = $exitcond | 0;
+ var label = 0;
while(1) {
if ($14) {
if ($or$cond8) {
@@ -587,9 +623,12 @@ function asm(global, env, buffer) {
}
}
- function __Z12multi_varargiz($0) {
+ function __Z12multi_varargiz($0, $$06$i4, $exitcond$i6, $2) {
$0 = $0|0;
- var $2 = 0, $$06$i4 = 0, $exitcond$i6 = 0, $12 = 0, $20 = 0;
+ $$06$i4 = $$06$i4 | 0;
+ $exitcond$i6 = $exitcond$i6 | 0;
+ $2 = $2 | 0;
+ var $12 = 0, $20 = 0;
if ($2) {
while(1) {
$12 = $$06$i4;
@@ -751,6 +790,6 @@ function asm(global, env, buffer) {
var FUNCTION_TABLE_vi = [ vi, vi, vi, vi, vi, vi, vi, vi ];
var FUNCTION_TABLE_ii = [ ii ];
- return { big_negative: big_negative, pick: forgetMe, pick: exportMe, doubleCompares: doubleCompares, intOps: intOps, conversions: conversions, switcher: switcher, frem: frem, frem_float: frem_float, big_uint_div_u: big_uint_div_u, fr: fr, negZero: negZero, neg: neg, smallCompare: smallCompare, cneg_nosemicolon: cneg_nosemicolon, forLoop: forLoop, ceiling_32_64: ceiling_32_64, aborts: aborts, continues: continues, bitcasts: bitcasts, recursiveBlockMerging: recursiveBlockMerging, lb: lb, zeroInit: zeroInit, phi: phi, smallIf: smallIf, dropCall: dropCall, useSetGlobal: useSetGlobal, usesSetGlobal2: usesSetGlobal2, breakThroughMany: breakThroughMany, ifChainEmpty: ifChainEmpty, heap8NoShift: heap8NoShift, conditionalTypeFun: conditionalTypeFun, loadSigned: loadSigned, globalOpts: globalOpts, dropCallImport: dropCallImport, loophi: loophi, loophi2: loophi2, relooperJumpThreading: relooperJumpThreading, relooperJumpThreading__ZN4game14preloadweaponsEv: relooperJumpThreading__ZN4game14preloadweaponsEv, __Z12multi_varargiz: __Z12multi_varargiz, jumpThreadDrop: jumpThreadDrop, dropIgnoredImportInIf: dropIgnoredImportInIf, dropIgnoredImportsInIf: dropIgnoredImportsInIf, relooperJumpThreading_irreducible: relooperJumpThreading_irreducible, store_fround: store_fround, exportedNumber: 42, relocatableAndModules: relocatableAndModules, exported_f32_user: exported_f32_user, keepAlive: keepAlive };
+ return { big_negative: big_negative, pick: forgetMe, pick: exportMe, doubleCompares: doubleCompares, intOps: intOps, conversions: conversions, switcher: switcher, frem: frem, frem_float: frem_float, big_uint_div_u: big_uint_div_u, fr: fr, negZero: negZero, neg: neg, smallCompare: smallCompare, cneg_nosemicolon: cneg_nosemicolon, forLoop: forLoop, ceiling_32_64: ceiling_32_64, aborts: aborts, continues: continues, bitcasts: bitcasts, recursiveBlockMerging: recursiveBlockMerging, lb: lb, zeroInit: zeroInit, phi: phi, smallIf: smallIf, dropCall: dropCall, useSetGlobal: useSetGlobal, usesSetGlobal2: usesSetGlobal2, breakThroughMany: breakThroughMany, ifChainEmpty: ifChainEmpty, heap8NoShift: heap8NoShift, conditionalTypeFun: conditionalTypeFun, loadSigned: loadSigned, globalOpts: globalOpts, dropCallImport: dropCallImport, loophi: loophi, loophi2: loophi2, loophi2b: loophi2b, relooperJumpThreading: relooperJumpThreading, relooperJumpThreading__ZN4game14preloadweaponsEv: relooperJumpThreading__ZN4game14preloadweaponsEv, __Z12multi_varargiz: __Z12multi_varargiz, jumpThreadDrop: jumpThreadDrop, dropIgnoredImportInIf: dropIgnoredImportInIf, dropIgnoredImportsInIf: dropIgnoredImportsInIf, relooperJumpThreading_irreducible: relooperJumpThreading_irreducible, store_fround: store_fround, exportedNumber: 42, relocatableAndModules: relocatableAndModules, exported_f32_user: exported_f32_user, keepAlive: keepAlive };
}
diff --git a/test/unit.fromasm b/test/unit.fromasm
index ec97a3320..1588f651b 100644
--- a/test/unit.fromasm
+++ b/test/unit.fromasm
@@ -31,7 +31,7 @@
(export "pick" (func $big_negative))
(export "doubleCompares" (func $doubleCompares))
(export "intOps" (func $intOps))
- (export "conversions" (func $conversions))
+ (export "conversions" (func $legalstub$conversions))
(export "switcher" (func $switcher))
(export "frem" (func $frem))
(export "frem_float" (func $legalstub$frem_float))
@@ -63,6 +63,7 @@
(export "dropCallImport" (func $dropCallImport))
(export "loophi" (func $loophi))
(export "loophi2" (func $loophi2))
+ (export "loophi2b" (func $loophi2b))
(export "relooperJumpThreading" (func $relooperJumpThreading))
(export "relooperJumpThreading__ZN4game14preloadweaponsEv" (func $relooperJumpThreading__ZN4game14preloadweaponsEv))
(export "__Z12multi_varargiz" (func $__Z12multi_varargiz))
@@ -100,8 +101,6 @@
(f64.const 1.2)
)
(func $doubleCompares (param $0 f64) (param $1 f64) (result f64)
- (local $2 f64)
- (local $3 i32)
(if
(f64.gt
(get_local $0)
@@ -113,7 +112,7 @@
)
(if
(f64.gt
- (get_local $2)
+ (get_local $0)
(f64.const 0)
)
(return
@@ -122,7 +121,7 @@
)
(if
(i32.gt_s
- (get_local $3)
+ (get_global $n)
(i32.const 0)
)
(return
@@ -140,24 +139,21 @@
)
(get_local $1)
)
- (func $intOps (result i32)
- (local $0 i32)
+ (func $intOps (param $0 i32) (result i32)
(i32.eqz
(get_local $0)
)
)
- (func $conversions
- (local $0 f64)
- (local $1 f32)
+ (func $conversions (param $0 i32) (param $1 f64) (param $2 f32)
(drop
(call $f64-to-int
- (get_local $0)
+ (get_local $1)
)
)
(drop
(call $f64-to-int
(f64.promote/f32
- (get_local $1)
+ (get_local $2)
)
)
)
@@ -256,21 +252,7 @@
)
)
(func $big_uint_div_u (result i32)
- (local $0 i32)
- (local $1 i32)
- (set_local $0
- (i32.const -1)
- )
- (if (result i32)
- (tee_local $1
- (i32.const 2)
- )
- (i32.div_u
- (get_local $0)
- (get_local $1)
- )
- (i32.const 0)
- )
+ (i32.const 2147483647)
)
(func $fr (param $0 f32)
(nop)
@@ -293,9 +275,7 @@
(i32.const 9)
)
)
- (func $smallCompare (result i32)
- (local $0 i32)
- (local $1 i32)
+ (func $smallCompare (param $0 i32) (param $1 i32) (result i32)
(if
(i32.lt_s
(get_local $0)
@@ -819,6 +799,38 @@
)
(get_local $1)
)
+ (func $loophi2b (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (loop $label$continue$L7
+ (block $label$break$L7
+ (set_local $0
+ (i32.const 0)
+ )
+ (loop $while-in
+ (set_local $1
+ (get_local $0)
+ )
+ (if
+ (call $return_int)
+ (br_if $label$break$L7
+ (get_local $1)
+ )
+ )
+ (br_if $while-in
+ (tee_local $0
+ (i32.add
+ (get_local $0)
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (br $label$continue$L7)
+ )
+ )
+ (get_local $0)
+ )
(func $relooperJumpThreading (param $0 i32) (result i32)
(block $__rjto$0
(block $__rjti$0
@@ -988,33 +1000,28 @@
)
(get_local $0)
)
- (func $relooperJumpThreading__ZN4game14preloadweaponsEv
- (local $0 i32)
- (local $1 i32)
- (local $2 i32)
- (local $3 i32)
- (local $4 i32)
+ (func $relooperJumpThreading__ZN4game14preloadweaponsEv (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (param $5 i32) (param $6 i32)
(loop $while-in
(block $__rjto$1
(block $__rjti$1
(if
- (get_local $0)
+ (get_local $1)
(br_if $__rjti$1
(i32.eqz
- (get_local $1)
+ (get_local $2)
)
)
(br_if $__rjti$1
(i32.eqz
- (get_local $2)
+ (get_local $3)
)
)
)
(br $while-in)
)
(i32.store
- (get_local $3)
(get_local $4)
+ (get_local $5)
)
)
(br $while-in)
@@ -1072,11 +1079,9 @@
)
)
)
- (func $__Z12multi_varargiz (param $0 i32)
- (local $1 i32)
- (local $2 i32)
+ (func $__Z12multi_varargiz (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
(if
- (get_local $1)
+ (get_local $3)
(loop $while-in
(br_if $while-in
(i32.eqz
@@ -1163,7 +1168,6 @@
)
)
(func $keepAlive
- (local $0 i32)
(drop
(call $sqrts
(f64.const 3.14159)
@@ -1184,24 +1188,12 @@
(f64.const 100)
)
)
- (block $__inlined_func$autoDrop
- (br_if $__inlined_func$autoDrop
- (i32.eq
- (tee_local $0
- (i32.const 52)
- )
- (i32.const 17)
- )
- )
- )
(call_indirect $FUNCSIG$vi
(i32.const 0)
(i32.const 17)
)
(call_indirect $FUNCSIG$vi
- (tee_local $0
- (i32.const 0)
- )
+ (i32.const 0)
(block (result i32)
(set_global $Int
(i32.const 1)
@@ -1230,6 +1222,15 @@
(func $ii (param $0 i32) (result i32)
(get_local $0)
)
+ (func $legalstub$conversions (param $0 i32) (param $1 f64) (param $2 f64)
+ (call $conversions
+ (get_local $0)
+ (get_local $1)
+ (f32.demote/f64
+ (get_local $2)
+ )
+ )
+ )
(func $legalstub$frem_float (result f64)
(f64.promote/f32
(call $frem_float)
diff --git a/test/unit.fromasm.clamp b/test/unit.fromasm.clamp
index b110204f9..4393c362c 100644
--- a/test/unit.fromasm.clamp
+++ b/test/unit.fromasm.clamp
@@ -29,7 +29,7 @@
(export "pick" (func $big_negative))
(export "doubleCompares" (func $doubleCompares))
(export "intOps" (func $intOps))
- (export "conversions" (func $conversions))
+ (export "conversions" (func $legalstub$conversions))
(export "switcher" (func $switcher))
(export "frem" (func $frem))
(export "frem_float" (func $legalstub$frem_float))
@@ -61,6 +61,7 @@
(export "dropCallImport" (func $dropCallImport))
(export "loophi" (func $loophi))
(export "loophi2" (func $loophi2))
+ (export "loophi2b" (func $loophi2b))
(export "relooperJumpThreading" (func $relooperJumpThreading))
(export "relooperJumpThreading__ZN4game14preloadweaponsEv" (func $relooperJumpThreading__ZN4game14preloadweaponsEv))
(export "__Z12multi_varargiz" (func $__Z12multi_varargiz))
@@ -98,8 +99,6 @@
(f64.const 1.2)
)
(func $doubleCompares (param $0 f64) (param $1 f64) (result f64)
- (local $2 f64)
- (local $3 i32)
(if
(f64.gt
(get_local $0)
@@ -111,7 +110,7 @@
)
(if
(f64.gt
- (get_local $2)
+ (get_local $0)
(f64.const 0)
)
(return
@@ -120,7 +119,7 @@
)
(if
(i32.gt_s
- (get_local $3)
+ (get_global $n)
(i32.const 0)
)
(return
@@ -138,8 +137,7 @@
)
(get_local $1)
)
- (func $intOps (result i32)
- (local $0 i32)
+ (func $intOps (param $0 i32) (result i32)
(i32.eqz
(get_local $0)
)
@@ -170,18 +168,16 @@
)
)
)
- (func $conversions
- (local $0 f64)
- (local $1 f32)
+ (func $conversions (param $0 i32) (param $1 f64) (param $2 f32)
(drop
(call $f64-to-int
- (get_local $0)
+ (get_local $1)
)
)
(drop
(call $f64-to-int
(f64.promote/f32
- (get_local $1)
+ (get_local $2)
)
)
)
@@ -280,21 +276,7 @@
)
)
(func $big_uint_div_u (result i32)
- (local $0 i32)
- (local $1 i32)
- (set_local $0
- (i32.const -1)
- )
- (if (result i32)
- (tee_local $1
- (i32.const 2)
- )
- (i32.div_u
- (get_local $0)
- (get_local $1)
- )
- (i32.const 0)
- )
+ (i32.const 2147483647)
)
(func $fr (param $0 f32)
(nop)
@@ -317,9 +299,7 @@
(i32.const 9)
)
)
- (func $smallCompare (result i32)
- (local $0 i32)
- (local $1 i32)
+ (func $smallCompare (param $0 i32) (param $1 i32) (result i32)
(if
(i32.lt_s
(get_local $0)
@@ -843,6 +823,38 @@
)
(get_local $1)
)
+ (func $loophi2b (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (loop $label$continue$L7
+ (block $label$break$L7
+ (set_local $0
+ (i32.const 0)
+ )
+ (loop $while-in
+ (set_local $1
+ (get_local $0)
+ )
+ (if
+ (call $return_int)
+ (br_if $label$break$L7
+ (get_local $1)
+ )
+ )
+ (br_if $while-in
+ (tee_local $0
+ (i32.add
+ (get_local $0)
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (br $label$continue$L7)
+ )
+ )
+ (get_local $0)
+ )
(func $relooperJumpThreading (param $0 i32) (result i32)
(block $__rjto$0
(block $__rjti$0
@@ -1012,33 +1024,28 @@
)
(get_local $0)
)
- (func $relooperJumpThreading__ZN4game14preloadweaponsEv
- (local $0 i32)
- (local $1 i32)
- (local $2 i32)
- (local $3 i32)
- (local $4 i32)
+ (func $relooperJumpThreading__ZN4game14preloadweaponsEv (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (param $5 i32) (param $6 i32)
(loop $while-in
(block $__rjto$1
(block $__rjti$1
(if
- (get_local $0)
+ (get_local $1)
(br_if $__rjti$1
(i32.eqz
- (get_local $1)
+ (get_local $2)
)
)
(br_if $__rjti$1
(i32.eqz
- (get_local $2)
+ (get_local $3)
)
)
)
(br $while-in)
)
(i32.store
- (get_local $3)
(get_local $4)
+ (get_local $5)
)
)
(br $while-in)
@@ -1096,11 +1103,9 @@
)
)
)
- (func $__Z12multi_varargiz (param $0 i32)
- (local $1 i32)
- (local $2 i32)
+ (func $__Z12multi_varargiz (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
(if
- (get_local $1)
+ (get_local $3)
(loop $while-in
(br_if $while-in
(i32.eqz
@@ -1187,7 +1192,6 @@
)
)
(func $keepAlive
- (local $0 i32)
(drop
(call $sqrts
(f64.const 3.14159)
@@ -1208,24 +1212,12 @@
(f64.const 100)
)
)
- (block $__inlined_func$autoDrop
- (br_if $__inlined_func$autoDrop
- (i32.eq
- (tee_local $0
- (i32.const 52)
- )
- (i32.const 17)
- )
- )
- )
(call_indirect $FUNCSIG$vi
(i32.const 0)
(i32.const 17)
)
(call_indirect $FUNCSIG$vi
- (tee_local $0
- (i32.const 0)
- )
+ (i32.const 0)
(block (result i32)
(set_global $Int
(i32.const 1)
@@ -1254,6 +1246,15 @@
(func $ii (param $0 i32) (result i32)
(get_local $0)
)
+ (func $legalstub$conversions (param $0 i32) (param $1 f64) (param $2 f64)
+ (call $conversions
+ (get_local $0)
+ (get_local $1)
+ (f32.demote/f64
+ (get_local $2)
+ )
+ )
+ )
(func $legalstub$frem_float (result f64)
(f64.promote/f32
(call $frem_float)
diff --git a/test/unit.fromasm.clamp.no-opts b/test/unit.fromasm.clamp.no-opts
index f4fe4bf83..00b1814c4 100644
--- a/test/unit.fromasm.clamp.no-opts
+++ b/test/unit.fromasm.clamp.no-opts
@@ -36,7 +36,7 @@
(export "pick" (func $exportMe))
(export "doubleCompares" (func $doubleCompares))
(export "intOps" (func $intOps))
- (export "conversions" (func $conversions))
+ (export "conversions" (func $legalstub$conversions))
(export "switcher" (func $switcher))
(export "frem" (func $frem))
(export "frem_float" (func $legalstub$frem_float))
@@ -68,6 +68,7 @@
(export "dropCallImport" (func $dropCallImport))
(export "loophi" (func $loophi))
(export "loophi2" (func $loophi2))
+ (export "loophi2b" (func $loophi2b))
(export "relooperJumpThreading" (func $relooperJumpThreading))
(export "relooperJumpThreading__ZN4game14preloadweaponsEv" (func $relooperJumpThreading__ZN4game14preloadweaponsEv))
(export "__Z12multi_varargiz" (func $__Z12multi_varargiz))
@@ -151,6 +152,12 @@
(f64.const 1.2)
)
)
+ (set_local $Int
+ (get_local $x)
+ )
+ (set_local $Double
+ (get_global $n)
+ )
(if
(f64.gt
(get_local $Int)
@@ -182,8 +189,7 @@
(get_local $y)
)
)
- (func $intOps (result i32)
- (local $x i32)
+ (func $intOps (param $x i32) (result i32)
(return
(i32.eqz
(get_local $x)
@@ -228,10 +234,7 @@
)
)
)
- (func $conversions
- (local $i i32)
- (local $d f64)
- (local $f f32)
+ (func $conversions (param $i i32) (param $d f64) (param $f f32)
(set_local $i
(call $f64-to-int
(get_local $d)
@@ -582,9 +585,7 @@
)
)
)
- (func $smallCompare (result i32)
- (local $i i32)
- (local $j i32)
+ (func $smallCompare (param $i i32) (param $j i32) (result i32)
(if
(i32.lt_s
(get_local $i)
@@ -1381,6 +1382,60 @@
(get_local $i$lcssa)
)
)
+ (func $loophi2b (result i32)
+ (local $jnc i32)
+ (local $i i32)
+ (local $i$lcssa i32)
+ (local $temp i32)
+ (local $j i32)
+ (set_local $i
+ (i32.const 0)
+ )
+ (loop $label$continue$L7
+ (block $label$break$L7
+ (set_local $j
+ (i32.const 0)
+ )
+ (loop $while-in
+ (block $while-out
+ (set_local $temp
+ (get_local $j)
+ )
+ (if
+ (call $return_int)
+ (if
+ (get_local $temp)
+ (block
+ (set_local $i$lcssa
+ (get_local $j)
+ )
+ (br $label$break$L7)
+ )
+ )
+ )
+ (set_local $jnc
+ (i32.add
+ (get_local $j)
+ (i32.const 1)
+ )
+ )
+ (if
+ (get_local $jnc)
+ (set_local $j
+ (get_local $jnc)
+ )
+ (br $while-out)
+ )
+ (br $while-in)
+ )
+ )
+ (br $label$continue$L7)
+ )
+ )
+ (return
+ (get_local $i$lcssa)
+ )
+ )
(func $relooperJumpThreading (param $x i32) (result i32)
(local $label i32)
(if
@@ -1620,14 +1675,7 @@
(get_local $x)
)
)
- (func $relooperJumpThreading__ZN4game14preloadweaponsEv
- (local $$12 i32)
- (local $$14 i32)
- (local $$or$cond8 i32)
- (local $$or$cond6 i32)
- (local $$vararg_ptr5 i32)
- (local $$11 i32)
- (local $$exitcond i32)
+ (func $relooperJumpThreading__ZN4game14preloadweaponsEv (param $$12 i32) (param $$14 i32) (param $$or$cond8 i32) (param $$or$cond6 i32) (param $$vararg_ptr5 i32) (param $$11 i32) (param $$exitcond i32)
(local $label i32)
(loop $while-in
(block $while-out
@@ -1751,10 +1799,7 @@
)
)
)
- (func $__Z12multi_varargiz (param $$0 i32)
- (local $$2 i32)
- (local $$$06$i4 i32)
- (local $$exitcond$i6 i32)
+ (func $__Z12multi_varargiz (param $$0 i32) (param $$$06$i4 i32) (param $$exitcond$i6 i32) (param $$2 i32)
(local $$12 i32)
(local $$20 i32)
(if
@@ -2068,6 +2113,15 @@
(get_local $x)
)
)
+ (func $legalstub$conversions (param $0 i32) (param $1 f64) (param $2 f64)
+ (call $conversions
+ (get_local $0)
+ (get_local $1)
+ (f32.demote/f64
+ (get_local $2)
+ )
+ )
+ )
(func $legalstub$frem_float (result f64)
(f64.promote/f32
(call $frem_float)
diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise
index 13c29f151..fec7e2038 100644
--- a/test/unit.fromasm.imprecise
+++ b/test/unit.fromasm.imprecise
@@ -28,7 +28,7 @@
(export "pick" (func $big_negative))
(export "doubleCompares" (func $doubleCompares))
(export "intOps" (func $intOps))
- (export "conversions" (func $big_negative))
+ (export "conversions" (func $legalstub$conversions))
(export "switcher" (func $switcher))
(export "frem" (func $frem))
(export "frem_float" (func $legalstub$frem_float))
@@ -60,6 +60,7 @@
(export "dropCallImport" (func $dropCallImport))
(export "loophi" (func $loophi))
(export "loophi2" (func $loophi2))
+ (export "loophi2b" (func $loophi2b))
(export "relooperJumpThreading" (func $relooperJumpThreading))
(export "relooperJumpThreading__ZN4game14preloadweaponsEv" (func $relooperJumpThreading__ZN4game14preloadweaponsEv))
(export "__Z12multi_varargiz" (func $__Z12multi_varargiz))
@@ -97,8 +98,6 @@
(f64.const 1.2)
)
(func $doubleCompares (param $0 f64) (param $1 f64) (result f64)
- (local $2 f64)
- (local $3 i32)
(if
(f64.gt
(get_local $0)
@@ -110,7 +109,7 @@
)
(if
(f64.gt
- (get_local $2)
+ (get_local $0)
(f64.const 0)
)
(return
@@ -119,7 +118,7 @@
)
(if
(i32.gt_s
- (get_local $3)
+ (get_global $n)
(i32.const 0)
)
(return
@@ -137,12 +136,14 @@
)
(get_local $1)
)
- (func $intOps (result i32)
- (local $0 i32)
+ (func $intOps (param $0 i32) (result i32)
(i32.eqz
(get_local $0)
)
)
+ (func $conversions (param $0 i32) (param $1 f64) (param $2 f32)
+ (nop)
+ )
(func $switcher (param $0 i32) (result i32)
(block $switch
(block $switch-case0
@@ -260,9 +261,7 @@
(i32.const 9)
)
)
- (func $smallCompare (result i32)
- (local $0 i32)
- (local $1 i32)
+ (func $smallCompare (param $0 i32) (param $1 i32) (result i32)
(if
(i32.lt_s
(get_local $0)
@@ -786,6 +785,38 @@
)
(get_local $1)
)
+ (func $loophi2b (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (loop $label$continue$L7
+ (block $label$break$L7
+ (set_local $0
+ (i32.const 0)
+ )
+ (loop $while-in
+ (set_local $1
+ (get_local $0)
+ )
+ (if
+ (call $return_int)
+ (br_if $label$break$L7
+ (get_local $1)
+ )
+ )
+ (br_if $while-in
+ (tee_local $0
+ (i32.add
+ (get_local $0)
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (br $label$continue$L7)
+ )
+ )
+ (get_local $0)
+ )
(func $relooperJumpThreading (param $0 i32) (result i32)
(block $__rjto$0
(block $__rjti$0
@@ -955,33 +986,28 @@
)
(get_local $0)
)
- (func $relooperJumpThreading__ZN4game14preloadweaponsEv
- (local $0 i32)
- (local $1 i32)
- (local $2 i32)
- (local $3 i32)
- (local $4 i32)
+ (func $relooperJumpThreading__ZN4game14preloadweaponsEv (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (param $5 i32) (param $6 i32)
(loop $while-in
(block $__rjto$1
(block $__rjti$1
(if
- (get_local $0)
+ (get_local $1)
(br_if $__rjti$1
(i32.eqz
- (get_local $1)
+ (get_local $2)
)
)
(br_if $__rjti$1
(i32.eqz
- (get_local $2)
+ (get_local $3)
)
)
)
(br $while-in)
)
(i32.store
- (get_local $3)
(get_local $4)
+ (get_local $5)
)
)
(br $while-in)
@@ -1039,11 +1065,9 @@
)
)
)
- (func $__Z12multi_varargiz (param $0 i32)
- (local $1 i32)
- (local $2 i32)
+ (func $__Z12multi_varargiz (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
(if
- (get_local $1)
+ (get_local $3)
(loop $while-in
(br_if $while-in
(i32.eqz
@@ -1125,7 +1149,6 @@
)
)
(func $keepAlive
- (local $0 i32)
(drop
(call $sqrts
(f64.const 3.14159)
@@ -1136,24 +1159,12 @@
(f64.const 2.18281)
)
)
- (block $__inlined_func$autoDrop
- (br_if $__inlined_func$autoDrop
- (i32.eq
- (tee_local $0
- (i32.const 52)
- )
- (i32.const 17)
- )
- )
- )
(call_indirect $FUNCSIG$vi
(i32.const 0)
(i32.const 17)
)
(call_indirect $FUNCSIG$vi
- (tee_local $0
- (i32.const 0)
- )
+ (i32.const 0)
(block (result i32)
(set_global $Int
(i32.const 1)
@@ -1182,6 +1193,15 @@
(func $ii (param $0 i32) (result i32)
(get_local $0)
)
+ (func $legalstub$conversions (param $0 i32) (param $1 f64) (param $2 f64)
+ (call $conversions
+ (get_local $0)
+ (get_local $1)
+ (f32.demote/f64
+ (get_local $2)
+ )
+ )
+ )
(func $legalstub$frem_float (result f64)
(f64.promote/f32
(call $frem_float)
diff --git a/test/unit.fromasm.imprecise.no-opts b/test/unit.fromasm.imprecise.no-opts
index 243b8b8fe..76934df4b 100644
--- a/test/unit.fromasm.imprecise.no-opts
+++ b/test/unit.fromasm.imprecise.no-opts
@@ -36,7 +36,7 @@
(export "pick" (func $exportMe))
(export "doubleCompares" (func $doubleCompares))
(export "intOps" (func $intOps))
- (export "conversions" (func $conversions))
+ (export "conversions" (func $legalstub$conversions))
(export "switcher" (func $switcher))
(export "frem" (func $frem))
(export "frem_float" (func $legalstub$frem_float))
@@ -68,6 +68,7 @@
(export "dropCallImport" (func $dropCallImport))
(export "loophi" (func $loophi))
(export "loophi2" (func $loophi2))
+ (export "loophi2b" (func $loophi2b))
(export "relooperJumpThreading" (func $relooperJumpThreading))
(export "relooperJumpThreading__ZN4game14preloadweaponsEv" (func $relooperJumpThreading__ZN4game14preloadweaponsEv))
(export "__Z12multi_varargiz" (func $__Z12multi_varargiz))
@@ -151,6 +152,12 @@
(f64.const 1.2)
)
)
+ (set_local $Int
+ (get_local $x)
+ )
+ (set_local $Double
+ (get_global $n)
+ )
(if
(f64.gt
(get_local $Int)
@@ -182,8 +189,7 @@
(get_local $y)
)
)
- (func $intOps (result i32)
- (local $x i32)
+ (func $intOps (param $x i32) (result i32)
(return
(i32.eqz
(get_local $x)
@@ -202,10 +208,7 @@
)
)
)
- (func $conversions
- (local $i i32)
- (local $d f64)
- (local $f f32)
+ (func $conversions (param $i i32) (param $d f64) (param $f f32)
(set_local $i
(i32.trunc_s/f64
(get_local $d)
@@ -542,9 +545,7 @@
)
)
)
- (func $smallCompare (result i32)
- (local $i i32)
- (local $j i32)
+ (func $smallCompare (param $i i32) (param $j i32) (result i32)
(if
(i32.lt_s
(get_local $i)
@@ -1341,6 +1342,60 @@
(get_local $i$lcssa)
)
)
+ (func $loophi2b (result i32)
+ (local $jnc i32)
+ (local $i i32)
+ (local $i$lcssa i32)
+ (local $temp i32)
+ (local $j i32)
+ (set_local $i
+ (i32.const 0)
+ )
+ (loop $label$continue$L7
+ (block $label$break$L7
+ (set_local $j
+ (i32.const 0)
+ )
+ (loop $while-in
+ (block $while-out
+ (set_local $temp
+ (get_local $j)
+ )
+ (if
+ (call $return_int)
+ (if
+ (get_local $temp)
+ (block
+ (set_local $i$lcssa
+ (get_local $j)
+ )
+ (br $label$break$L7)
+ )
+ )
+ )
+ (set_local $jnc
+ (i32.add
+ (get_local $j)
+ (i32.const 1)
+ )
+ )
+ (if
+ (get_local $jnc)
+ (set_local $j
+ (get_local $jnc)
+ )
+ (br $while-out)
+ )
+ (br $while-in)
+ )
+ )
+ (br $label$continue$L7)
+ )
+ )
+ (return
+ (get_local $i$lcssa)
+ )
+ )
(func $relooperJumpThreading (param $x i32) (result i32)
(local $label i32)
(if
@@ -1580,14 +1635,7 @@
(get_local $x)
)
)
- (func $relooperJumpThreading__ZN4game14preloadweaponsEv
- (local $$12 i32)
- (local $$14 i32)
- (local $$or$cond8 i32)
- (local $$or$cond6 i32)
- (local $$vararg_ptr5 i32)
- (local $$11 i32)
- (local $$exitcond i32)
+ (func $relooperJumpThreading__ZN4game14preloadweaponsEv (param $$12 i32) (param $$14 i32) (param $$or$cond8 i32) (param $$or$cond6 i32) (param $$vararg_ptr5 i32) (param $$11 i32) (param $$exitcond i32)
(local $label i32)
(loop $while-in
(block $while-out
@@ -1711,10 +1759,7 @@
)
)
)
- (func $__Z12multi_varargiz (param $$0 i32)
- (local $$2 i32)
- (local $$$06$i4 i32)
- (local $$exitcond$i6 i32)
+ (func $__Z12multi_varargiz (param $$0 i32) (param $$$06$i4 i32) (param $$exitcond$i6 i32) (param $$2 i32)
(local $$12 i32)
(local $$20 i32)
(if
@@ -2028,6 +2073,15 @@
(get_local $x)
)
)
+ (func $legalstub$conversions (param $0 i32) (param $1 f64) (param $2 f64)
+ (call $conversions
+ (get_local $0)
+ (get_local $1)
+ (f32.demote/f64
+ (get_local $2)
+ )
+ )
+ )
(func $legalstub$frem_float (result f64)
(f64.promote/f32
(call $frem_float)
diff --git a/test/unit.fromasm.no-opts b/test/unit.fromasm.no-opts
index 09d8361bd..021ce41f9 100644
--- a/test/unit.fromasm.no-opts
+++ b/test/unit.fromasm.no-opts
@@ -38,7 +38,7 @@
(export "pick" (func $exportMe))
(export "doubleCompares" (func $doubleCompares))
(export "intOps" (func $intOps))
- (export "conversions" (func $conversions))
+ (export "conversions" (func $legalstub$conversions))
(export "switcher" (func $switcher))
(export "frem" (func $frem))
(export "frem_float" (func $legalstub$frem_float))
@@ -70,6 +70,7 @@
(export "dropCallImport" (func $dropCallImport))
(export "loophi" (func $loophi))
(export "loophi2" (func $loophi2))
+ (export "loophi2b" (func $loophi2b))
(export "relooperJumpThreading" (func $relooperJumpThreading))
(export "relooperJumpThreading__ZN4game14preloadweaponsEv" (func $relooperJumpThreading__ZN4game14preloadweaponsEv))
(export "__Z12multi_varargiz" (func $__Z12multi_varargiz))
@@ -153,6 +154,12 @@
(f64.const 1.2)
)
)
+ (set_local $Int
+ (get_local $x)
+ )
+ (set_local $Double
+ (get_global $n)
+ )
(if
(f64.gt
(get_local $Int)
@@ -184,8 +191,7 @@
(get_local $y)
)
)
- (func $intOps (result i32)
- (local $x i32)
+ (func $intOps (param $x i32) (result i32)
(return
(i32.eqz
(get_local $x)
@@ -204,10 +210,7 @@
)
)
)
- (func $conversions
- (local $i i32)
- (local $d f64)
- (local $f f32)
+ (func $conversions (param $i i32) (param $d f64) (param $f f32)
(set_local $i
(call $f64-to-int
(get_local $d)
@@ -558,9 +561,7 @@
)
)
)
- (func $smallCompare (result i32)
- (local $i i32)
- (local $j i32)
+ (func $smallCompare (param $i i32) (param $j i32) (result i32)
(if
(i32.lt_s
(get_local $i)
@@ -1357,6 +1358,60 @@
(get_local $i$lcssa)
)
)
+ (func $loophi2b (result i32)
+ (local $jnc i32)
+ (local $i i32)
+ (local $i$lcssa i32)
+ (local $temp i32)
+ (local $j i32)
+ (set_local $i
+ (i32.const 0)
+ )
+ (loop $label$continue$L7
+ (block $label$break$L7
+ (set_local $j
+ (i32.const 0)
+ )
+ (loop $while-in
+ (block $while-out
+ (set_local $temp
+ (get_local $j)
+ )
+ (if
+ (call $return_int)
+ (if
+ (get_local $temp)
+ (block
+ (set_local $i$lcssa
+ (get_local $j)
+ )
+ (br $label$break$L7)
+ )
+ )
+ )
+ (set_local $jnc
+ (i32.add
+ (get_local $j)
+ (i32.const 1)
+ )
+ )
+ (if
+ (get_local $jnc)
+ (set_local $j
+ (get_local $jnc)
+ )
+ (br $while-out)
+ )
+ (br $while-in)
+ )
+ )
+ (br $label$continue$L7)
+ )
+ )
+ (return
+ (get_local $i$lcssa)
+ )
+ )
(func $relooperJumpThreading (param $x i32) (result i32)
(local $label i32)
(if
@@ -1596,14 +1651,7 @@
(get_local $x)
)
)
- (func $relooperJumpThreading__ZN4game14preloadweaponsEv
- (local $$12 i32)
- (local $$14 i32)
- (local $$or$cond8 i32)
- (local $$or$cond6 i32)
- (local $$vararg_ptr5 i32)
- (local $$11 i32)
- (local $$exitcond i32)
+ (func $relooperJumpThreading__ZN4game14preloadweaponsEv (param $$12 i32) (param $$14 i32) (param $$or$cond8 i32) (param $$or$cond6 i32) (param $$vararg_ptr5 i32) (param $$11 i32) (param $$exitcond i32)
(local $label i32)
(loop $while-in
(block $while-out
@@ -1727,10 +1775,7 @@
)
)
)
- (func $__Z12multi_varargiz (param $$0 i32)
- (local $$2 i32)
- (local $$$06$i4 i32)
- (local $$exitcond$i6 i32)
+ (func $__Z12multi_varargiz (param $$0 i32) (param $$$06$i4 i32) (param $$exitcond$i6 i32) (param $$2 i32)
(local $$12 i32)
(local $$20 i32)
(if
@@ -2044,6 +2089,15 @@
(get_local $x)
)
)
+ (func $legalstub$conversions (param $0 i32) (param $1 f64) (param $2 f64)
+ (call $conversions
+ (get_local $0)
+ (get_local $1)
+ (f32.demote/f64
+ (get_local $2)
+ )
+ )
+ )
(func $legalstub$frem_float (result f64)
(f64.promote/f32
(call $frem_float)
diff --git a/test/wasm-only.fromasm b/test/wasm-only.fromasm
index 8f9825dda..2ac96b8ae 100644
--- a/test/wasm-only.fromasm
+++ b/test/wasm-only.fromasm
@@ -294,67 +294,41 @@
)
(func $test64
(local $0 i64)
- (local $1 i64)
- (local $2 i64)
- (local $3 f32)
- (local $4 f64)
- (set_local $2
+ (local $1 f32)
+ (local $2 f64)
+ (set_local $0
(call $i64s-div
(block (result i64)
- (set_local $2
+ (set_local $0
(i64.mul
(i64.sub
(i64.add
- (tee_local $0
- (i64.const 128849018897)
- )
+ (i64.const 128849018897)
(i64.const 100)
)
- (get_local $0)
+ (i64.const 128849018897)
)
- (get_local $0)
+ (i64.const 128849018897)
)
)
- (if (result i64)
- (i64.eqz
- (tee_local $1
- (get_local $0)
- )
- )
- (i64.const 0)
- (i64.div_u
- (get_local $2)
- (get_local $1)
- )
+ (i64.div_u
+ (get_local $0)
+ (i64.const 128849018897)
)
)
- (get_local $0)
+ (i64.const 128849018897)
)
)
- (set_local $1
- (if (result i64)
- (i64.eqz
- (tee_local $1
- (get_local $0)
- )
- )
- (i64.const 0)
- (i64.rem_u
- (get_local $2)
- (get_local $1)
- )
+ (set_local $0
+ (i64.rem_u
+ (get_local $0)
+ (i64.const 128849018897)
)
)
(drop
- (if (result i64)
- (i64.eqz
- (get_local $0)
- )
- (i64.const 0)
- (i64.rem_s
- (get_local $1)
- (get_local $0)
- )
+ (i64.rem_s
+ (get_local $0)
+ (i64.const 128849018897)
)
)
(drop
@@ -404,7 +378,7 @@
(drop
(call $f64-to-int64
(f64.promote/f32
- (tee_local $3
+ (tee_local $1
(f32.convert_u/i64
(tee_local $0
(i64.extend_u/i32
@@ -420,7 +394,7 @@
)
(drop
(call $f64-to-int64
- (tee_local $4
+ (tee_local $2
(f64.convert_u/i64
(get_local $0)
)
@@ -430,13 +404,13 @@
(drop
(call $f64-to-int64
(f64.promote/f32
- (get_local $3)
+ (get_local $1)
)
)
)
(drop
(call $f64-to-int64
- (get_local $4)
+ (get_local $2)
)
)
)
diff --git a/test/wasm-only.fromasm.clamp b/test/wasm-only.fromasm.clamp
index 8f9825dda..2ac96b8ae 100644
--- a/test/wasm-only.fromasm.clamp
+++ b/test/wasm-only.fromasm.clamp
@@ -294,67 +294,41 @@
)
(func $test64
(local $0 i64)
- (local $1 i64)
- (local $2 i64)
- (local $3 f32)
- (local $4 f64)
- (set_local $2
+ (local $1 f32)
+ (local $2 f64)
+ (set_local $0
(call $i64s-div
(block (result i64)
- (set_local $2
+ (set_local $0
(i64.mul
(i64.sub
(i64.add
- (tee_local $0
- (i64.const 128849018897)
- )
+ (i64.const 128849018897)
(i64.const 100)
)
- (get_local $0)
+ (i64.const 128849018897)
)
- (get_local $0)
+ (i64.const 128849018897)
)
)
- (if (result i64)
- (i64.eqz
- (tee_local $1
- (get_local $0)
- )
- )
- (i64.const 0)
- (i64.div_u
- (get_local $2)
- (get_local $1)
- )
+ (i64.div_u
+ (get_local $0)
+ (i64.const 128849018897)
)
)
- (get_local $0)
+ (i64.const 128849018897)
)
)
- (set_local $1
- (if (result i64)
- (i64.eqz
- (tee_local $1
- (get_local $0)
- )
- )
- (i64.const 0)
- (i64.rem_u
- (get_local $2)
- (get_local $1)
- )
+ (set_local $0
+ (i64.rem_u
+ (get_local $0)
+ (i64.const 128849018897)
)
)
(drop
- (if (result i64)
- (i64.eqz
- (get_local $0)
- )
- (i64.const 0)
- (i64.rem_s
- (get_local $1)
- (get_local $0)
- )
+ (i64.rem_s
+ (get_local $0)
+ (i64.const 128849018897)
)
)
(drop
@@ -404,7 +378,7 @@
(drop
(call $f64-to-int64
(f64.promote/f32
- (tee_local $3
+ (tee_local $1
(f32.convert_u/i64
(tee_local $0
(i64.extend_u/i32
@@ -420,7 +394,7 @@
)
(drop
(call $f64-to-int64
- (tee_local $4
+ (tee_local $2
(f64.convert_u/i64
(get_local $0)
)
@@ -430,13 +404,13 @@
(drop
(call $f64-to-int64
(f64.promote/f32
- (get_local $3)
+ (get_local $1)
)
)
)
(drop
(call $f64-to-int64
- (get_local $4)
+ (get_local $2)
)
)
)