Extract portable AS to its own definition and polyfill; Try running flatten/ssa before default optimizations, see WebAssembly/binaryen#1331

This commit is contained in:
dcodeIO
2017-12-08 19:08:03 +01:00
parent d6b94d4c33
commit 0ebb99a33c
23 changed files with 1515 additions and 1231 deletions

View File

@ -5,11 +5,15 @@
(export "loopDoInDo" (func $do/loopDoInDo))
(export "memory" (memory $0))
(func $do/loopDo (; 0 ;) (type $iv) (param $0 i32)
(local $1 i32)
(set_local $1
(get_local $0)
)
(loop $continue|0
(br_if $continue|0
(tee_local $0
(tee_local $1
(i32.sub
(get_local $0)
(get_local $1)
(i32.const 1)
)
)
@ -17,8 +21,10 @@
)
)
(func $do/loopDoInDo (; 1 ;) (type $iv) (param $0 i32)
(local $1 i32)
(local $2 i32)
(loop $continue|0
(set_local $0
(set_local $1
(i32.sub
(get_local $0)
(i32.const 1)
@ -26,16 +32,20 @@
)
(loop $continue|1
(br_if $continue|1
(tee_local $0
(i32.sub
(get_local $0)
(i32.const 1)
(tee_local $2
(tee_local $1
(tee_local $0
(i32.sub
(get_local $1)
(i32.const 1)
)
)
)
)
)
)
(br_if $continue|0
(get_local $0)
(get_local $2)
)
)
)

View File

@ -100,7 +100,7 @@
(get_local $4)
(get_global $game-of-life/w)
)
(tee_local $2
(tee_local $3
(select
(i32.sub
(get_local $1)
@ -128,7 +128,7 @@
(get_local $4)
(get_global $game-of-life/w)
)
(tee_local $3
(tee_local $2
(select
(i32.const 0)
(i32.add
@ -150,7 +150,7 @@
(get_local $0)
(get_global $game-of-life/w)
)
(get_local $2)
(get_local $3)
)
)
)
@ -160,7 +160,7 @@
(get_local $0)
(get_global $game-of-life/w)
)
(get_local $3)
(get_local $2)
)
)
)
@ -170,7 +170,7 @@
(get_local $5)
(get_global $game-of-life/w)
)
(get_local $2)
(get_local $3)
)
)
)
@ -190,7 +190,7 @@
(get_local $5)
(get_global $game-of-life/w)
)
(get_local $3)
(get_local $2)
)
)
)
@ -205,32 +205,38 @@
(get_local $1)
)
)
(if
(if (result i32)
(tee_local $3
(i32.lt_s
(get_local $2)
(i32.const 2)
)
)
(get_local $3)
(i32.gt_s
(get_local $2)
(i32.const 3)
)
)
(i32.store8
(i32.add
(i32.add
(get_global $game-of-life/s)
(i32.mul
(get_local $0)
(get_global $game-of-life/w)
(block
(if
(i32.eqz
(tee_local $3
(i32.lt_s
(get_local $2)
(i32.const 2)
)
)
(get_local $1)
)
(i32.const 0)
(set_local $3
(i32.gt_s
(get_local $2)
(i32.const 3)
)
)
)
(if
(get_local $3)
(i32.store8
(i32.add
(i32.add
(get_global $game-of-life/s)
(i32.mul
(get_local $0)
(get_global $game-of-life/w)
)
)
(get_local $1)
)
(i32.const 0)
)
)
)
(if

View File

@ -44,46 +44,48 @@
)
(unreachable)
)
(if
(tee_local $0
(i32.const 1)
)
(set_local $0
(i32.const 2)
)
)
(if
(i32.eqz
(if (result i32)
(tee_local $0
(i32.const 1)
)
(tee_local $0
(i32.const 2)
)
(get_local $0)
)
(get_local $0)
)
(unreachable)
)
(if
(f64.eq
(if (result f64)
(f64.ne
(tee_local $1
(f64.const 1)
)
(f64.const 0)
)
(tee_local $1
(f64.const 2)
)
(get_local $1)
(f64.ne
(tee_local $1
(f64.const 1)
)
(f64.const 0)
)
(set_local $1
(f64.const 2)
)
)
(if
(f64.eq
(get_local $1)
(f64.const 0)
)
(unreachable)
)
(set_global $logical/i
(if (result i32)
(tee_local $0
(i32.const 1)
)
(i32.const 2)
(get_local $0)
(if
(tee_local $0
(i32.const 1)
)
(set_local $0
(i32.const 2)
)
)
(set_global $logical/i
(get_local $0)
)
(if
(i32.ne
@ -92,15 +94,19 @@
)
(unreachable)
)
(set_global $logical/i
(if (result i32)
(if
(i32.eqz
(tee_local $0
(i32.const 0)
)
(get_local $0)
)
(set_local $0
(i32.const 1)
)
)
(set_global $logical/i
(get_local $0)
)
(if
(i32.ne
(get_global $logical/i)
@ -108,17 +114,19 @@
)
(unreachable)
)
(set_global $logical/I
(if (result i64)
(i64.ne
(tee_local $2
(i64.const 1)
)
(i64.const 0)
(if
(i64.ne
(tee_local $2
(i64.const 1)
)
(i64.const 2)
(get_local $2)
(i64.const 0)
)
(set_local $2
(i64.const 2)
)
)
(set_global $logical/I
(get_local $2)
)
(if
(i64.ne
@ -127,18 +135,20 @@
)
(unreachable)
)
(set_global $logical/I
(if (result i64)
(i64.ne
(tee_local $2
(i64.const 0)
)
(if
(i64.eq
(tee_local $2
(i64.const 0)
)
(get_local $2)
(i64.const 0)
)
(set_local $2
(i64.const 1)
)
)
(set_global $logical/I
(get_local $2)
)
(if
(i64.ne
(get_global $logical/I)
@ -146,17 +156,19 @@
)
(unreachable)
)
(set_global $logical/f
(if (result f32)
(f32.ne
(tee_local $3
(f32.const 1)
)
(f32.const 0)
(if
(f32.ne
(tee_local $3
(f32.const 1)
)
(f32.const 2)
(get_local $3)
(f32.const 0)
)
(set_local $3
(f32.const 2)
)
)
(set_global $logical/f
(get_local $3)
)
(if
(f32.ne
@ -165,18 +177,20 @@
)
(unreachable)
)
(set_global $logical/f
(if (result f32)
(f32.ne
(tee_local $3
(f32.const 0)
)
(if
(f32.eq
(tee_local $3
(f32.const 0)
)
(get_local $3)
(f32.const 0)
)
(set_local $3
(f32.const 1)
)
)
(set_global $logical/f
(get_local $3)
)
(if
(f32.ne
(get_global $logical/f)
@ -184,17 +198,19 @@
)
(unreachable)
)
(if
(f64.ne
(tee_local $1
(f64.const 1)
)
(f64.const 0)
)
(set_local $1
(f64.const 2)
)
)
(set_global $logical/F
(if (result f64)
(f64.ne
(tee_local $1
(f64.const 1)
)
(f64.const 0)
)
(f64.const 2)
(get_local $1)
)
(get_local $1)
)
(if
(f64.ne
@ -203,18 +219,20 @@
)
(unreachable)
)
(set_global $logical/F
(if (result f64)
(f64.ne
(tee_local $1
(f64.const 0)
)
(if
(f64.eq
(tee_local $1
(f64.const 0)
)
(get_local $1)
(f64.const 0)
)
(set_local $1
(f64.const 1)
)
)
(set_global $logical/F
(get_local $1)
)
(if
(f64.ne
(get_global $logical/F)

File diff suppressed because it is too large Load Diff

View File

@ -6,15 +6,36 @@
(export "doSwitchDefaultOmitted" (func $switch/doSwitchDefaultOmitted))
(export "memory" (memory $0))
(func $switch/doSwitch (; 0 ;) (type $ii) (param $0 i32) (result i32)
(local $1 i32)
(block $case4|0
(block $case2|0
(block $case0|0
(block $tablify|0
(br_table $case2|0 $case0|0 $case4|0 $case4|0 $tablify|0
(if
(i32.ne
(tee_local $1
(get_local $0)
)
(i32.const 1)
)
(block
(br_if $case2|0
(i32.eqz
(get_local $1)
)
)
(br_if $case4|0
(i32.eq
(get_local $1)
(i32.const 2)
)
)
(br_if $case4|0
(i32.eq
(get_local $1)
(i32.const 3)
)
)
(br $case2|0)
)
(br $case2|0)
)
(return
(i32.const 1)
@ -27,18 +48,31 @@
(i32.const 23)
)
(func $switch/doSwitchDefaultFirst (; 1 ;) (type $ii) (param $0 i32) (result i32)
(local $1 i32)
(block $case3|0
(block $case1|0
(block $tablify|0
(br_table $case1|0 $case3|0 $case3|0 $tablify|0
(i32.sub
(get_local $0)
(i32.const 1)
(if
(i32.ne
(tee_local $1
(get_local $0)
)
(i32.const 1)
)
(block
(br_if $case3|0
(i32.eq
(get_local $1)
(i32.const 2)
)
)
)
(return
(i32.const 0)
(br_if $case3|0
(i32.eq
(get_local $1)
(i32.const 3)
)
)
(return
(i32.const 0)
)
)
)
(return
@ -48,18 +82,31 @@
(i32.const 23)
)
(func $switch/doSwitchDefaultOmitted (; 2 ;) (type $ii) (param $0 i32) (result i32)
(local $1 i32)
(block $break|0
(block $case2|0
(block $case0|0
(block $tablify|0
(br_table $case0|0 $case2|0 $case2|0 $tablify|0
(i32.sub
(get_local $0)
(i32.const 1)
(if
(i32.ne
(tee_local $1
(get_local $0)
)
(i32.const 1)
)
(block
(br_if $case2|0
(i32.eq
(get_local $1)
(i32.const 2)
)
)
(br_if $case2|0
(i32.eq
(get_local $1)
(i32.const 3)
)
)
(br $break|0)
)
(br $break|0)
)
(return
(i32.const 1)

View File

@ -5,14 +5,28 @@
(export "memory" (memory $0))
(start $start)
(func $start (; 0 ;) (type $v)
(local $0 i32)
(set_global $ternary/a
(i32.const 1)
(tee_local $0
(i32.const 1)
)
)
(set_global $ternary/a
(i32.const 1)
(tee_local $0
(i32.const 1)
)
)
(if
(tee_local $0
(i32.const 1)
)
(set_local $0
(i32.const 1)
)
(unreachable)
)
(set_global $ternary/a
(i32.const 1)
(get_local $0)
)
)
)

View File

@ -66,53 +66,39 @@
)
)
(set_global $unary/i
(block (result i32)
(set_global $unary/i
(i32.add
(get_global $unary/i)
(i32.const 1)
)
)
(i32.add
(get_global $unary/i)
(i32.const 1)
)
)
(set_global $unary/i
(block (result i32)
(set_global $unary/i
(i32.sub
(get_global $unary/i)
(i32.const 1)
)
)
(i32.sub
(get_global $unary/i)
(i32.const 1)
)
)
(set_global $unary/i
(block (result i32)
(set_global $unary/i
(i32.add
(tee_local $0
(get_global $unary/i)
)
(i32.const 1)
)
(i32.add
(tee_local $0
(get_global $unary/i)
)
(get_local $0)
(i32.const 1)
)
)
(set_global $unary/i
(block (result i32)
(set_global $unary/i
(i32.sub
(tee_local $0
(get_global $unary/i)
)
(i32.const 1)
)
(get_local $0)
)
(set_global $unary/i
(i32.sub
(tee_local $0
(get_global $unary/i)
)
(get_local $0)
(i32.const 1)
)
)
(set_global $unary/i
(get_local $0)
)
(set_global $unary/I
(i64.add
(get_global $unary/I)
@ -169,53 +155,39 @@
)
)
(set_global $unary/I
(block (result i64)
(set_global $unary/I
(i64.add
(get_global $unary/I)
(i64.const 1)
)
)
(i64.add
(get_global $unary/I)
(i64.const 1)
)
)
(set_global $unary/I
(block (result i64)
(set_global $unary/I
(i64.sub
(get_global $unary/I)
(i64.const 1)
)
)
(i64.sub
(get_global $unary/I)
(i64.const 1)
)
)
(set_global $unary/I
(block (result i64)
(set_global $unary/I
(i64.add
(tee_local $1
(get_global $unary/I)
)
(i64.const 1)
)
(i64.add
(tee_local $1
(get_global $unary/I)
)
(get_local $1)
(i64.const 1)
)
)
(set_global $unary/I
(block (result i64)
(set_global $unary/I
(i64.sub
(tee_local $1
(get_global $unary/I)
)
(i64.const 1)
)
(get_local $1)
)
(set_global $unary/I
(i64.sub
(tee_local $1
(get_global $unary/I)
)
(get_local $1)
(i64.const 1)
)
)
(set_global $unary/I
(get_local $1)
)
(set_global $unary/f
(f32.add
(get_global $unary/f)
@ -261,53 +233,39 @@
)
)
(set_global $unary/f
(block (result f32)
(set_global $unary/f
(f32.add
(get_global $unary/f)
(f32.const 1)
)
)
(f32.add
(get_global $unary/f)
(f32.const 1)
)
)
(set_global $unary/f
(block (result f32)
(set_global $unary/f
(f32.sub
(get_global $unary/f)
(f32.const 1)
)
)
(f32.sub
(get_global $unary/f)
(f32.const 1)
)
)
(set_global $unary/f
(block (result f32)
(set_global $unary/f
(f32.add
(tee_local $2
(get_global $unary/f)
)
(f32.const 1)
)
(f32.add
(tee_local $2
(get_global $unary/f)
)
(get_local $2)
(f32.const 1)
)
)
(set_global $unary/f
(block (result f32)
(set_global $unary/f
(f32.sub
(tee_local $2
(get_global $unary/f)
)
(f32.const 1)
)
(get_local $2)
)
(set_global $unary/f
(f32.sub
(tee_local $2
(get_global $unary/f)
)
(get_local $2)
(f32.const 1)
)
)
(set_global $unary/f
(get_local $2)
)
(set_global $unary/F
(f64.add
(get_global $unary/F)
@ -355,52 +313,38 @@
)
)
(set_global $unary/F
(block (result f64)
(set_global $unary/F
(f64.add
(get_global $unary/F)
(f64.const 1)
)
)
(f64.add
(get_global $unary/F)
(f64.const 1)
)
)
(set_global $unary/F
(block (result f64)
(set_global $unary/F
(f64.sub
(get_global $unary/F)
(f64.const 1)
)
)
(f64.sub
(get_global $unary/F)
(f64.const 1)
)
)
(set_global $unary/F
(block (result f64)
(set_global $unary/F
(f64.add
(tee_local $3
(get_global $unary/F)
)
(f64.const 1)
)
(f64.add
(tee_local $3
(get_global $unary/F)
)
(get_local $3)
(f64.const 1)
)
)
(set_global $unary/F
(block (result f64)
(set_global $unary/F
(f64.sub
(tee_local $3
(get_global $unary/F)
)
(f64.const 1)
)
(get_local $3)
)
(set_global $unary/F
(f64.sub
(tee_local $3
(get_global $unary/F)
)
(get_local $3)
(f64.const 1)
)
)
(set_global $unary/F
(get_local $3)
)
)
)

View File

@ -5,14 +5,20 @@
(export "loopWhileInWhile" (func $while/loopWhileInWhile))
(export "memory" (memory $0))
(func $while/loopWhile (; 0 ;) (type $iv) (param $0 i32)
(local $1 i32)
(set_local $1
(get_local $0)
)
(loop $continue|0
(if
(get_local $0)
(get_local $1)
(block
(set_local $0
(i32.sub
(get_local $0)
(i32.const 1)
(tee_local $1
(i32.sub
(get_local $0)
(i32.const 1)
)
)
)
(br $continue|0)
@ -21,24 +27,32 @@
)
)
(func $while/loopWhileInWhile (; 1 ;) (type $iv) (param $0 i32)
(local $1 i32)
(set_local $1
(get_local $0)
)
(loop $continue|0
(if
(get_local $0)
(get_local $1)
(block
(set_local $0
(i32.sub
(get_local $0)
(i32.const 1)
(tee_local $1
(i32.sub
(get_local $0)
(i32.const 1)
)
)
)
(loop $continue|1
(if
(get_local $0)
(get_local $1)
(block
(set_local $0
(i32.sub
(get_local $0)
(i32.const 1)
(tee_local $1
(i32.sub
(get_local $1)
(i32.const 1)
)
)
)
(br $continue|1)