Utilize Binaryen's -O4

When specifying -O3 or -Oz, asc now automatically increases the optimize level to 4, then including costly non-LLVM optimizations for blocky code, in turn achieving similar results as an LLVM-based generator.
This commit is contained in:
dcodeIO
2018-06-09 14:05:33 +02:00
parent e9094bbd6f
commit c6ec5e2832
46 changed files with 14240 additions and 16223 deletions

View File

@ -9,20 +9,19 @@
(func $~lib/math/NativeMath.log (; 0 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i32)
(local $2 i32)
(local $3 i64)
(local $4 f64)
(local $5 i32)
(local $3 i32)
(local $4 i64)
(local $5 f64)
(local $6 f64)
(local $7 f64)
(local $8 f64)
(if
(if (result i32)
(tee_local $5
(i32.eqz
(tee_local $2
(i32.lt_u
(tee_local $1
(i32.wrap/i64
(i64.shr_u
(tee_local $3
(tee_local $4
(i64.reinterpret/f64
(get_local $0)
)
@ -34,17 +33,21 @@
(i32.const 1048576)
)
)
(get_local $5)
)
(set_local $2
(i32.shr_u
(get_local $1)
(i32.const 31)
)
)
)
(if
(get_local $2)
(block
(if
(i64.eq
(i64.shl
(get_local $3)
(get_local $4)
(i64.const 1)
)
(i64.const 0)
@ -74,16 +77,13 @@
)
)
)
(set_local $2
(i32.sub
(get_local $2)
(i32.const 54)
)
(set_local $3
(i32.const -54)
)
(set_local $1
(i32.wrap/i64
(i64.shr_u
(tee_local $3
(tee_local $4
(i64.reinterpret/f64
(f64.mul
(get_local $0)
@ -104,32 +104,36 @@
(return
(get_local $0)
)
(if
(if (result i32)
(tee_local $5
(block
(if
(tee_local $2
(i32.eq
(get_local $1)
(i32.const 1072693248)
)
)
(i64.eq
(i64.shl
(get_local $3)
(i64.const 32)
(set_local $2
(i64.eq
(i64.shl
(get_local $4)
(i64.const 32)
)
(i64.const 0)
)
(i64.const 0)
)
(get_local $5)
)
(return
(f64.const 0)
(if
(get_local $2)
(return
(f64.const 0)
)
)
)
)
)
(set_local $2
(set_local $3
(i32.add
(get_local $2)
(get_local $3)
(i32.sub
(i32.shr_s
(tee_local $1
@ -144,56 +148,47 @@
)
)
)
(set_local $6
(f64.mul
(f64.mul
(f64.const 0.5)
(tee_local $4
(f64.sub
(f64.reinterpret/i64
(i64.or
(i64.shl
(i64.extend_u/i32
(i32.add
(i32.and
(get_local $1)
(i32.const 1048575)
)
(i32.const 1072079006)
)
)
(i64.const 32)
)
(i64.and
(get_local $3)
(i64.const 4294967295)
)
)
)
(f64.const 1)
)
)
)
(get_local $4)
)
)
(set_local $0
(f64.mul
(tee_local $8
(tee_local $7
(f64.mul
(tee_local $7
(tee_local $6
(f64.div
(get_local $4)
(tee_local $5
(f64.sub
(f64.reinterpret/i64
(i64.or
(i64.shl
(i64.extend_u/i32
(i32.add
(i32.and
(get_local $1)
(i32.const 1048575)
)
(i32.const 1072079006)
)
)
(i64.const 32)
)
(i64.and
(get_local $4)
(i64.const 4294967295)
)
)
)
(f64.const 1)
)
)
(f64.add
(f64.const 2)
(get_local $4)
(get_local $5)
)
)
)
(get_local $7)
(get_local $6)
)
)
(get_local $8)
(get_local $7)
)
)
(f64.add
@ -201,12 +196,20 @@
(f64.sub
(f64.add
(f64.mul
(get_local $7)
(get_local $6)
(f64.add
(get_local $6)
(tee_local $6
(f64.mul
(f64.mul
(f64.const 0.5)
(get_local $5)
)
(get_local $5)
)
)
(f64.add
(f64.mul
(get_local $8)
(get_local $7)
(f64.add
(f64.const 0.6666666666666735)
(f64.mul
@ -247,20 +250,20 @@
)
)
(f64.mul
(f64.convert_s/i32
(get_local $2)
(tee_local $0
(f64.convert_s/i32
(get_local $3)
)
)
(f64.const 1.9082149292705877e-10)
)
)
(get_local $6)
)
(get_local $4)
(get_local $5)
)
(f64.mul
(f64.convert_s/i32
(get_local $2)
)
(get_local $0)
(f64.const 0.6931471803691238)
)
)
@ -286,17 +289,19 @@
(func $../../examples/mandelbrot/assembly/index/computeLine (; 3 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
(local $4 f64)
(local $5 f64)
(local $6 i32)
(local $6 f64)
(local $7 f64)
(local $8 f64)
(local $8 i32)
(local $9 f64)
(local $10 f64)
(local $11 f64)
(local $12 f64)
(set_local $11
(f64.div
(f64.convert_u/i32
(get_local $1)
(tee_local $6
(f64.convert_u/i32
(get_local $1)
)
)
(f64.const 1.6)
)
@ -307,11 +312,15 @@
(f64.convert_u/i32
(get_local $0)
)
(f64.div
(f64.convert_u/i32
(get_local $2)
(tee_local $7
(f64.div
(tee_local $4
(f64.convert_u/i32
(get_local $2)
)
)
(f64.const 2)
)
(f64.const 2)
)
)
(tee_local $12
@ -320,15 +329,11 @@
(f64.min
(f64.mul
(f64.const 3)
(f64.convert_u/i32
(get_local $1)
)
(get_local $6)
)
(f64.mul
(f64.const 4)
(f64.convert_u/i32
(get_local $2)
)
(get_local $4)
)
)
)
@ -336,13 +341,10 @@
)
)
(block $break|0
(set_local $2
(i32.const 0)
)
(loop $repeat|0
(br_if $break|0
(i32.ge_u
(get_local $2)
(get_local $8)
(get_local $1)
)
)
@ -350,7 +352,7 @@
(f64.mul
(f64.sub
(f64.convert_u/i32
(get_local $2)
(get_local $8)
)
(get_local $11)
)
@ -363,7 +365,7 @@
(set_local $5
(f64.const 0)
)
(set_local $6
(set_local $2
(i32.const 0)
)
(block $break|1
@ -371,13 +373,13 @@
(if
(f64.le
(f64.add
(tee_local $7
(tee_local $6
(f64.mul
(get_local $4)
(get_local $4)
)
)
(tee_local $8
(tee_local $7
(f64.mul
(get_local $5)
(get_local $5)
@ -402,21 +404,21 @@
(set_local $4
(f64.add
(f64.sub
(get_local $6)
(get_local $7)
(get_local $8)
)
(get_local $10)
)
)
(br_if $break|1
(i32.ge_u
(get_local $6)
(get_local $2)
(get_local $3)
)
)
(set_local $6
(set_local $2
(i32.add
(get_local $6)
(get_local $2)
(i32.const 1)
)
)
@ -426,7 +428,7 @@
)
)
(block $break|2
(set_local $7
(set_local $6
(f64.min
(f64.const 8)
(f64.convert_u/i32
@ -439,13 +441,13 @@
(i32.eqz
(f64.lt
(f64.convert_u/i32
(get_local $6)
(get_local $2)
)
(get_local $7)
(get_local $6)
)
)
)
(set_local $8
(set_local $7
(f64.add
(f64.sub
(f64.mul
@ -473,11 +475,11 @@
)
)
(set_local $4
(get_local $8)
(get_local $7)
)
(set_local $6
(set_local $2
(i32.add
(get_local $6)
(get_local $2)
(i32.const 1)
)
)
@ -491,63 +493,67 @@
(get_local $0)
(get_local $1)
)
(get_local $2)
(get_local $8)
)
(i32.const 1)
)
(if (result i32)
(call $isFinite<f64>
(tee_local $7
(f64.div
(call $~lib/math/NativeMath.log
(call $~lib/math/NativeMath.log
(f64.sqrt
(f64.add
(f64.mul
(get_local $4)
(get_local $4)
)
(f64.mul
(get_local $5)
(get_local $5)
)
)
)
)
)
(f64.const 0.6931471805599453)
)
)
)
(i32.trunc_u/f64
(f64.mul
(f64.const 2047)
(call $../../examples/mandelbrot/assembly/index/clamp<f64>
(tee_local $2
(if (result i32)
(call $isFinite<f64>
(tee_local $6
(f64.div
(f64.sub
(f64.convert_u/i32
(i32.add
(get_local $6)
(i32.const 1)
(call $~lib/math/NativeMath.log
(call $~lib/math/NativeMath.log
(tee_local $7
(f64.sqrt
(f64.add
(f64.mul
(get_local $4)
(get_local $4)
)
(f64.mul
(get_local $5)
(get_local $5)
)
)
)
)
)
(get_local $7)
)
(f64.convert_u/i32
(get_local $3)
)
(f64.const 0.6931471805599453)
)
(f64.const 0)
(f64.const 1)
)
)
(i32.trunc_u/f64
(f64.mul
(f64.const 2047)
(call $../../examples/mandelbrot/assembly/index/clamp<f64>
(f64.div
(f64.sub
(f64.convert_u/i32
(i32.add
(get_local $2)
(i32.const 1)
)
)
(get_local $6)
)
(f64.convert_u/i32
(get_local $3)
)
)
(f64.const 0)
(f64.const 1)
)
)
)
(i32.const 2047)
)
(i32.const 2047)
)
)
(set_local $2
(set_local $8
(i32.add
(get_local $2)
(get_local $8)
(i32.const 1)
)
)