Improve inlining where locals can be aliased; Add a crude mechanism for explicit unchecked array accesses

The `unchecked` builtin should be handled with ultimate care and it would be a lot better if there'd be a mechanism doing this automatically.
This commit is contained in:
dcodeIO
2018-04-25 05:04:35 +02:00
parent 391db28fe2
commit 6d6d1dddcf
47 changed files with 5374 additions and 15672 deletions

View File

@ -407,19 +407,19 @@
(local $10 i32)
(local $11 i32)
(local $12 f64)
(local $13 i32)
(local $14 f64)
(local $15 i32)
(local $13 f64)
(local $14 i32)
(local $15 f64)
(local $16 f64)
(local $17 f64)
(local $18 f64)
(local $19 i64)
(local $18 i64)
(local $19 i32)
(block $folding-inner1
(block $folding-inner0
(set_local $4
(set_local $19
(i32.wrap/i64
(i64.shr_u
(tee_local $19
(tee_local $18
(i64.reinterpret/f64
(get_local $0)
)
@ -428,14 +428,14 @@
)
)
)
(set_local $13
(set_local $7
(i32.wrap/i64
(get_local $19)
(get_local $18)
)
)
(set_local $5
(set_local $6
(i32.and
(get_local $4)
(get_local $19)
(i32.const 2147483647)
)
)
@ -447,7 +447,7 @@
(tee_local $11
(i32.wrap/i64
(i64.shr_u
(tee_local $19
(tee_local $18
(i64.reinterpret/f64
(get_local $1)
)
@ -459,9 +459,9 @@
(i32.const 2147483647)
)
)
(tee_local $6
(tee_local $4
(i32.wrap/i64
(get_local $19)
(get_local $18)
)
)
)
@ -473,37 +473,37 @@
(if
(i32.and
(if (result i32)
(tee_local $7
(tee_local $5
(i32.and
(if (result i32)
(tee_local $7
(tee_local $5
(i32.and
(if (result i32)
(tee_local $7
(tee_local $5
(i32.gt_s
(get_local $5)
(get_local $6)
(i32.const 2146435072)
)
)
(get_local $7)
(get_local $5)
(if (result i32)
(tee_local $7
(tee_local $5
(i32.eq
(get_local $5)
(get_local $6)
(i32.const 2146435072)
)
)
(i32.ne
(get_local $13)
(get_local $7)
(i32.const 0)
)
(get_local $7)
(get_local $5)
)
)
(i32.const 1)
)
)
(get_local $7)
(get_local $5)
(i32.gt_s
(get_local $10)
(i32.const 2146435072)
@ -512,19 +512,19 @@
(i32.const 1)
)
)
(get_local $7)
(get_local $5)
(if (result i32)
(tee_local $7
(tee_local $5
(i32.eq
(get_local $10)
(i32.const 2146435072)
)
)
(i32.ne
(get_local $6)
(get_local $4)
(i32.const 0)
)
(get_local $7)
(get_local $5)
)
)
(i32.const 1)
@ -538,7 +538,7 @@
)
(if
(i32.lt_s
(get_local $4)
(get_local $19)
(i32.const 0)
)
(if
@ -546,7 +546,7 @@
(get_local $10)
(i32.const 1128267776)
)
(set_local $15
(set_local $14
(i32.const 2)
)
(if
@ -570,9 +570,9 @@
(if
(i32.eq
(i32.shl
(tee_local $7
(tee_local $5
(i32.shr_u
(get_local $6)
(get_local $4)
(i32.sub
(i32.const 52)
(get_local $8)
@ -584,13 +584,13 @@
(get_local $8)
)
)
(get_local $6)
(get_local $4)
)
(set_local $15
(set_local $14
(i32.sub
(i32.const 2)
(i32.and
(get_local $7)
(get_local $5)
(i32.const 1)
)
)
@ -598,12 +598,12 @@
)
(if
(i32.eqz
(get_local $6)
(get_local $4)
)
(if
(i32.eq
(i32.shl
(tee_local $7
(tee_local $5
(i32.shr_s
(get_local $10)
(i32.sub
@ -619,11 +619,11 @@
)
(get_local $10)
)
(set_local $15
(set_local $14
(i32.sub
(i32.const 2)
(i32.and
(get_local $7)
(get_local $5)
(i32.const 1)
)
)
@ -636,7 +636,7 @@
)
(if
(i32.eqz
(get_local $6)
(get_local $4)
)
(block
(if
@ -647,14 +647,14 @@
(if
(i32.or
(i32.sub
(get_local $5)
(get_local $6)
(i32.const 1072693248)
)
(get_local $13)
(get_local $7)
)
(if
(i32.ge_s
(get_local $5)
(get_local $6)
(i32.const 1072693248)
)
(return
@ -727,7 +727,7 @@
)
(if
(i32.ge_s
(get_local $4)
(get_local $19)
(i32.const 0)
)
(return
@ -746,31 +746,31 @@
)
(if
(i32.eqz
(get_local $13)
(get_local $7)
)
(if
(i32.and
(if (result i32)
(tee_local $7
(tee_local $5
(i32.and
(if (result i32)
(tee_local $7
(tee_local $5
(i32.eq
(get_local $5)
(get_local $6)
(i32.const 2146435072)
)
)
(get_local $7)
(get_local $5)
(i32.eqz
(get_local $5)
(get_local $6)
)
)
(i32.const 1)
)
)
(get_local $7)
(get_local $5)
(i32.eq
(get_local $5)
(get_local $6)
(i32.const 1072693248)
)
)
@ -791,20 +791,20 @@
)
(if
(i32.lt_s
(get_local $4)
(get_local $19)
(i32.const 0)
)
(if
(i32.or
(i32.sub
(get_local $5)
(get_local $6)
(i32.const 1072693248)
)
(get_local $15)
(get_local $14)
)
(if
(i32.eq
(get_local $15)
(get_local $14)
(i32.const 1)
)
(set_local $2
@ -838,13 +838,13 @@
)
(if
(i32.lt_s
(get_local $4)
(get_local $19)
(i32.const 0)
)
(block
(if
(i32.eqz
(get_local $15)
(get_local $14)
)
(return
(f64.div
@ -861,7 +861,7 @@
)
(if
(i32.eq
(get_local $15)
(get_local $14)
(i32.const 1)
)
(set_local $12
@ -885,7 +885,7 @@
(block
(if
(i32.le_s
(get_local $5)
(get_local $6)
(i32.const 1072693247)
)
(return
@ -901,7 +901,7 @@
)
(if
(i32.ge_s
(get_local $5)
(get_local $6)
(i32.const 1072693248)
)
(return
@ -919,7 +919,7 @@
)
(if
(i32.lt_s
(get_local $5)
(get_local $6)
(i32.const 1072693247)
)
(return
@ -947,7 +947,7 @@
)
(if
(i32.gt_s
(get_local $5)
(get_local $6)
(i32.const 1072693248)
)
(return
@ -1004,13 +1004,13 @@
(i64.and
(i64.reinterpret/f64
(f64.add
(tee_local $16
(tee_local $15
(f64.mul
(f64.const 1.4426950216293335)
(get_local $3)
)
)
(tee_local $17
(tee_local $16
(f64.sub
(f64.mul
(get_local $3)
@ -1029,10 +1029,10 @@
)
)
(f64.sub
(get_local $17)
(get_local $16)
(f64.sub
(get_local $9)
(get_local $16)
(get_local $15)
)
)
)
@ -1042,7 +1042,7 @@
)
(if
(i32.lt_s
(get_local $5)
(get_local $6)
(i32.const 1048576)
)
(block
@ -1052,7 +1052,7 @@
(i32.const 53)
)
)
(set_local $5
(set_local $6
(i32.wrap/i64
(i64.shr_u
(i64.reinterpret/f64
@ -1074,18 +1074,18 @@
(get_local $4)
(i32.sub
(i32.shr_s
(get_local $5)
(get_local $6)
(i32.const 20)
)
(i32.const 1023)
)
)
)
(set_local $5
(set_local $6
(i32.or
(tee_local $6
(tee_local $7
(i32.and
(get_local $5)
(get_local $6)
(i32.const 1048575)
)
)
@ -1095,13 +1095,13 @@
(set_local $8
(if (result i32)
(i32.le_s
(get_local $6)
(get_local $7)
(i32.const 235662)
)
(i32.const 0)
(if (result i32)
(i32.lt_s
(get_local $6)
(get_local $7)
(i32.const 767610)
)
(i32.const 1)
@ -1112,9 +1112,9 @@
(i32.const 1)
)
)
(set_local $5
(set_local $6
(i32.add
(get_local $5)
(get_local $6)
(i32.const -1048576)
)
)
@ -1127,9 +1127,9 @@
(f64.reinterpret/i64
(i64.and
(i64.reinterpret/f64
(tee_local $18
(tee_local $17
(f64.mul
(tee_local $16
(tee_local $15
(f64.sub
(tee_local $2
(f64.reinterpret/i64
@ -1142,7 +1142,7 @@
)
(i64.shl
(i64.extend_u/i32
(get_local $5)
(get_local $6)
)
(i64.const 32)
)
@ -1158,7 +1158,7 @@
)
)
)
(tee_local $17
(tee_local $16
(f64.div
(f64.const 1)
(f64.add
@ -1186,7 +1186,7 @@
(i32.add
(i32.or
(i32.shr_s
(get_local $5)
(get_local $6)
(i32.const 1)
)
(i32.const 536870912)
@ -1213,34 +1213,34 @@
(f64.add
(f64.mul
(f64.mul
(tee_local $14
(tee_local $13
(f64.mul
(get_local $18)
(get_local $18)
(get_local $17)
(get_local $17)
)
)
(get_local $14)
(get_local $13)
)
(f64.add
(f64.const 0.5999999999999946)
(f64.mul
(get_local $14)
(get_local $13)
(f64.add
(f64.const 0.4285714285785502)
(f64.mul
(get_local $14)
(get_local $13)
(f64.add
(f64.const 0.33333332981837743)
(f64.mul
(get_local $14)
(get_local $13)
(f64.add
(f64.const 0.272728123808534)
(f64.mul
(get_local $14)
(get_local $13)
(f64.add
(f64.const 0.23066074577556175)
(f64.mul
(get_local $14)
(get_local $13)
(f64.const 0.20697501780033842)
)
)
@ -1256,10 +1256,10 @@
(f64.mul
(tee_local $0
(f64.mul
(get_local $17)
(get_local $16)
(f64.sub
(f64.sub
(get_local $16)
(get_local $15)
(f64.mul
(get_local $3)
(get_local $9)
@ -1274,7 +1274,7 @@
)
(f64.add
(get_local $3)
(get_local $18)
(get_local $17)
)
)
)
@ -1288,7 +1288,7 @@
(f64.add
(f64.add
(f64.const 3)
(tee_local $14
(tee_local $13
(f64.mul
(get_local $3)
(get_local $3)
@ -1304,7 +1304,7 @@
)
(f64.const 3)
)
(get_local $14)
(get_local $13)
)
)
)
@ -1315,7 +1315,7 @@
(f64.add
(f64.add
(f64.add
(tee_local $18
(tee_local $17
(f64.mul
(f64.const 0.9617967009544373)
(tee_local $0
@ -1323,13 +1323,13 @@
(i64.and
(i64.reinterpret/f64
(f64.add
(tee_local $16
(tee_local $15
(f64.mul
(get_local $3)
(get_local $9)
)
)
(tee_local $17
(tee_local $16
(f64.add
(f64.mul
(get_local $0)
@ -1337,7 +1337,7 @@
)
(f64.mul
(get_local $2)
(get_local $18)
(get_local $17)
)
)
)
@ -1358,10 +1358,10 @@
)
(f64.mul
(f64.sub
(get_local $17)
(get_local $16)
(f64.sub
(get_local $0)
(get_local $16)
(get_local $15)
)
)
(f64.const 0.9617966939259756)
@ -1404,16 +1404,16 @@
)
(get_local $0)
)
(get_local $18)
(get_local $17)
)
)
)
)
)
(set_local $6
(set_local $7
(i32.wrap/i64
(i64.shr_u
(tee_local $19
(tee_local $18
(i64.reinterpret/f64
(tee_local $2
(f64.add
@ -1455,24 +1455,24 @@
)
)
)
(set_local $13
(set_local $5
(i32.wrap/i64
(get_local $19)
(get_local $18)
)
)
(if
(i32.ge_s
(get_local $6)
(get_local $7)
(i32.const 1083179008)
)
(br_if $folding-inner1
(i32.or
(i32.or
(i32.sub
(get_local $6)
(get_local $7)
(i32.const 1083179008)
)
(get_local $13)
(get_local $5)
)
(f64.gt
(f64.add
@ -1489,7 +1489,7 @@
(if
(i32.ge_s
(i32.and
(get_local $6)
(get_local $7)
(i32.const 2147483647)
)
(i32.const 1083231232)
@ -1498,10 +1498,10 @@
(i32.or
(i32.or
(i32.sub
(get_local $6)
(get_local $7)
(i32.const -1064252416)
)
(get_local $13)
(get_local $5)
)
(f64.le
(get_local $1)
@ -1517,9 +1517,9 @@
(set_local $8
(i32.sub
(i32.shr_s
(tee_local $13
(tee_local $5
(i32.and
(get_local $6)
(get_local $7)
(i32.const 2147483647)
)
)
@ -1533,7 +1533,7 @@
)
(if
(i32.gt_s
(get_local $13)
(get_local $5)
(i32.const 1071644672)
)
(block
@ -1543,7 +1543,7 @@
(i32.and
(tee_local $4
(i32.add
(get_local $6)
(get_local $7)
(i32.shr_s
(i32.const 1048576)
(i32.add
@ -1596,7 +1596,7 @@
)
(if
(i32.lt_s
(get_local $6)
(get_local $7)
(i32.const 0)
)
(set_local $4
@ -1621,7 +1621,7 @@
(if (result f64)
(i32.le_s
(i32.shr_s
(tee_local $6
(tee_local $7
(i32.add
(i32.wrap/i64
(i64.shr_u
@ -1635,7 +1635,7 @@
(f64.mul
(tee_local $2
(f64.add
(tee_local $16
(tee_local $15
(f64.mul
(tee_local $3
(f64.reinterpret/i64
@ -1653,7 +1653,7 @@
(f64.const 0.6931471824645996)
)
)
(tee_local $17
(tee_local $16
(f64.add
(f64.mul
(f64.sub
@ -1720,10 +1720,10 @@
(f64.add
(tee_local $0
(f64.sub
(get_local $17)
(get_local $16)
(f64.sub
(get_local $2)
(get_local $16)
(get_local $15)
)
)
)
@ -1765,7 +1765,7 @@
)
(i64.shl
(i64.extend_u/i32
(get_local $6)
(get_local $7)
)
(i64.const 32)
)
@ -2831,7 +2831,7 @@
(i32.eqz
(i32.and
(if (result i32)
(tee_local $1
(tee_local $0
(i32.eq
(i32.load
(get_global $std/operator-overloading/ais)
@ -2845,7 +2845,7 @@
)
(i32.const 5)
)
(get_local $1)
(get_local $0)
)
(i32.const 1)
)
@ -2879,22 +2879,22 @@
(i32.const 0)
(i32.add
(i32.load
(tee_local $1
(tee_local $0
(get_global $std/operator-overloading/aii1)
)
)
(i32.load
(tee_local $0
(tee_local $1
(get_global $std/operator-overloading/aii2)
)
)
)
(i32.add
(i32.load offset=4
(get_local $1)
(get_local $0)
)
(i32.load offset=4
(get_local $0)
(get_local $1)
)
)
)