Minor optimizations to array sorting

...to get a handle on the code
This commit is contained in:
dcodeIO
2018-04-08 01:53:22 +02:00
parent ac2281b14b
commit 0f49e054d2
5 changed files with 317 additions and 402 deletions

View File

@ -3893,7 +3893,14 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
(set_local $6
(local $7 i32)
(local $8 i32)
(set_local $4
(i32.load
(get_local $0)
)
)
(set_local $7
(call $~lib/array/Array<i32>#get:length
(get_local $0)
)
@ -3901,26 +3908,24 @@
(loop $continue|0
(if
(i32.lt_s
(get_local $3)
(get_local $6)
(get_local $2)
(get_local $7)
)
(block
(set_local $4
(set_local $5
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $4)
(i32.shl
(get_local $3)
(get_local $2)
(i32.const 2)
)
)
)
)
(set_local $2
(set_local $3
(i32.sub
(get_local $3)
(get_local $2)
(i32.const 1)
)
)
@ -3928,18 +3933,16 @@
(loop $continue|1
(if
(i32.ge_s
(get_local $2)
(get_local $3)
(i32.const 0)
)
(block
(set_local $5
(set_local $6
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $4)
(i32.shl
(get_local $2)
(get_local $3)
(i32.const 2)
)
)
@ -3951,33 +3954,33 @@
(br_if $break|1
(i32.ge_s
(call_indirect (type $iii)
(get_local $4)
(get_local $5)
(get_local $6)
(get_local $1)
)
(i32.const 0)
)
)
(set_local $3
(i32.sub
(tee_local $8
(get_local $3)
)
(i32.const 1)
)
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $4)
(i32.shl
(i32.add
(get_local $2)
(get_local $8)
(i32.const 1)
)
(i32.const 2)
)
)
(get_local $5)
)
(set_local $2
(i32.sub
(get_local $2)
(i32.const 1)
)
(get_local $6)
)
(br $continue|1)
)
@ -3986,22 +3989,20 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $4)
(i32.shl
(i32.add
(get_local $2)
(get_local $3)
(i32.const 1)
)
(i32.const 2)
)
)
(get_local $4)
(get_local $5)
)
(set_local $3
(set_local $2
(i32.add
(get_local $3)
(get_local $2)
(i32.const 1)
)
)
@ -4018,14 +4019,15 @@
(local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
(call $~lib/memory/set_memory
(tee_local $5
(tee_local $6
(call $~lib/allocator/arena/allocate_memory
(i32.shl
(tee_local $2
(tee_local $2
(i32.shl
(i32.shr_s
(i32.add
(tee_local $7
(tee_local $8
(call $~lib/array/Array<i32>#get:length
(get_local $0)
)
@ -4034,48 +4036,50 @@
)
(i32.const 5)
)
(i32.const 2)
)
(i32.const 2)
)
)
)
(i32.const 0)
(i32.shl
(get_local $2)
(i32.const 2)
)
(get_local $2)
)
(set_local $3
(i32.load
(get_local $0)
)
)
(set_local $4
(i32.sub
(get_local $7)
(get_local $8)
(i32.const 1)
)
)
(loop $continue|0
(if
(i32.gt_s
(get_local $3)
(get_local $4)
(i32.const 0)
)
(block
(set_local $2
(get_local $3)
(set_local $5
(get_local $4)
)
(loop $continue|1
(if
(i32.eq
(i32.and
(get_local $2)
(get_local $5)
(i32.const 1)
)
(i32.and
(i32.shr_s
(i32.load
(i32.add
(get_local $5)
(get_local $6)
(i32.shl
(i32.shr_s
(get_local $2)
(get_local $5)
(i32.const 6)
)
(i32.const 2)
@ -4084,7 +4088,7 @@
)
(i32.and
(i32.shr_s
(get_local $2)
(get_local $5)
(i32.const 1)
)
(i32.const 31)
@ -4094,9 +4098,9 @@
)
)
(block
(set_local $2
(set_local $5
(i32.shr_s
(get_local $2)
(get_local $5)
(i32.const 1)
)
)
@ -4104,16 +4108,14 @@
)
)
)
(set_local $4
(set_local $2
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(tee_local $2
(tee_local $5
(i32.shr_s
(get_local $2)
(get_local $5)
(i32.const 1)
)
)
@ -4122,14 +4124,12 @@
)
)
)
(set_local $6
(set_local $7
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(get_local $3)
(get_local $4)
(i32.const 2)
)
)
@ -4142,8 +4142,8 @@
)
(i32.lt_s
(call_indirect (type $iii)
(get_local $4)
(get_local $6)
(get_local $2)
(get_local $7)
(get_local $1)
)
(i32.const 0)
@ -4152,10 +4152,10 @@
(block
(i32.store
(i32.add
(get_local $5)
(get_local $6)
(i32.shl
(i32.shr_s
(get_local $3)
(get_local $4)
(i32.const 5)
)
(i32.const 2)
@ -4164,10 +4164,10 @@
(i32.xor
(i32.load
(i32.add
(get_local $5)
(get_local $6)
(i32.shl
(i32.shr_s
(get_local $3)
(get_local $4)
(i32.const 5)
)
(i32.const 2)
@ -4177,7 +4177,7 @@
(i32.shl
(i32.const 1)
(i32.and
(get_local $3)
(get_local $4)
(i32.const 31)
)
)
@ -4185,33 +4185,29 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(get_local $3)
(get_local $4)
(i32.const 2)
)
)
(get_local $4)
(get_local $2)
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(get_local $2)
(get_local $5)
(i32.const 2)
)
)
(get_local $6)
(get_local $7)
)
)
)
(set_local $3
(set_local $4
(i32.sub
(get_local $3)
(get_local $4)
(i32.const 1)
)
)
@ -4219,37 +4215,31 @@
)
)
)
(set_local $3
(set_local $4
(i32.sub
(get_local $7)
(get_local $8)
(i32.const 1)
)
)
(loop $continue|2
(if
(i32.ge_s
(get_local $3)
(get_local $4)
(i32.const 2)
)
(block
(set_local $4
(set_local $7
(i32.load
(i32.load
(get_local $0)
)
(get_local $3)
)
)
(i32.store
(i32.load
(get_local $0)
)
(get_local $3)
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(get_local $3)
(get_local $4)
(i32.const 2)
)
)
@ -4257,15 +4247,13 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(get_local $3)
(get_local $4)
(i32.const 2)
)
)
(get_local $4)
(get_local $7)
)
(set_local $2
(i32.const 1)
@ -4273,7 +4261,7 @@
(loop $continue|3
(if
(i32.lt_s
(tee_local $4
(tee_local $5
(i32.add
(i32.shl
(get_local $2)
@ -4283,7 +4271,7 @@
(i32.shr_s
(i32.load
(i32.add
(get_local $5)
(get_local $6)
(i32.shl
(i32.shr_s
(get_local $2)
@ -4302,11 +4290,11 @@
)
)
)
(get_local $3)
(get_local $4)
)
(block
(set_local $2
(get_local $4)
(get_local $5)
)
(br $continue|3)
)
@ -4319,19 +4307,15 @@
(i32.const 0)
)
(block
(set_local $4
(set_local $7
(i32.load
(i32.load
(get_local $0)
)
(get_local $3)
)
)
(set_local $6
(set_local $5
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(get_local $2)
(i32.const 2)
@ -4346,8 +4330,8 @@
)
(i32.lt_s
(call_indirect (type $iii)
(get_local $4)
(get_local $6)
(get_local $7)
(get_local $5)
(get_local $1)
)
(i32.const 0)
@ -4356,7 +4340,7 @@
(block
(i32.store
(i32.add
(get_local $5)
(get_local $6)
(i32.shl
(i32.shr_s
(get_local $2)
@ -4368,7 +4352,7 @@
(i32.xor
(i32.load
(i32.add
(get_local $5)
(get_local $6)
(i32.shl
(i32.shr_s
(get_local $2)
@ -4389,21 +4373,17 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $3)
(i32.shl
(get_local $2)
(i32.const 2)
)
)
(get_local $4)
(get_local $7)
)
(i32.store
(i32.load
(get_local $0)
)
(get_local $6)
(get_local $3)
(get_local $5)
)
)
)
@ -4417,9 +4397,9 @@
)
)
)
(set_local $3
(set_local $4
(i32.sub
(get_local $3)
(get_local $4)
(i32.const 1)
)
)
@ -4428,29 +4408,21 @@
)
)
(call $~lib/allocator/arena/free_memory
(get_local $5)
(get_local $6)
)
(set_local $1
(i32.load offset=4
(i32.load
(get_local $0)
)
(get_local $3)
)
)
(i32.store offset=4
(get_local $3)
(i32.load
(get_local $0)
)
(i32.load
(i32.load
(get_local $0)
)
(get_local $3)
)
)
(i32.store
(i32.load
(get_local $0)
)
(get_local $3)
(get_local $1)
)
(get_local $0)

View File

@ -4473,14 +4473,20 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
(nop)
(nop)
(set_local $2
(i32.load
(get_local $0)
)
)
(block $break|0
(block
(set_local $5
(set_local $3
(i32.const 0)
)
(set_local $6
(set_local $4
(call $~lib/array/Array<i32>#get:length
(get_local $0)
)
@ -4489,27 +4495,25 @@
(loop $continue|0
(if
(i32.lt_s
(get_local $5)
(get_local $6)
(get_local $3)
(get_local $4)
)
(block
(block
(set_local $2
(set_local $5
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $2)
(i32.shl
(get_local $5)
(get_local $3)
(i32.const 2)
)
)
)
)
(set_local $4
(set_local $6
(i32.sub
(get_local $5)
(get_local $3)
(i32.const 1)
)
)
@ -4517,19 +4521,17 @@
(loop $continue|1
(if
(i32.ge_s
(get_local $4)
(get_local $6)
(i32.const 0)
)
(block
(block
(set_local $3
(set_local $7
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $2)
(i32.shl
(get_local $4)
(get_local $6)
(i32.const 2)
)
)
@ -4542,35 +4544,36 @@
(i32.const 2)
)
(call_indirect (type $iii)
(get_local $2)
(get_local $3)
(get_local $5)
(get_local $7)
(get_local $1)
)
)
(i32.const 0)
)
(block
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(i32.shl
(i32.add
(get_local $4)
(i32.const 1)
(i32.store
(i32.add
(get_local $2)
(i32.shl
(i32.add
(block (result i32)
(set_local $8
(get_local $6)
)
(set_local $6
(i32.sub
(get_local $8)
(i32.const 1)
)
)
(get_local $8)
)
(i32.const 2)
(i32.const 1)
)
)
(get_local $3)
)
(set_local $4
(i32.sub
(get_local $4)
(i32.const 1)
(i32.const 2)
)
)
(get_local $7)
)
(br $break|1)
)
@ -4582,23 +4585,21 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $2)
(i32.shl
(i32.add
(get_local $4)
(get_local $6)
(i32.const 1)
)
(i32.const 2)
)
)
(get_local $2)
(get_local $5)
)
)
(set_local $5
(set_local $3
(i32.add
(get_local $5)
(get_local $3)
(i32.const 1)
)
)
@ -4622,42 +4623,42 @@
(local $9 i32)
(local $10 i32)
(local $11 i32)
(local $12 i32)
(nop)
(nop)
(set_local $2
(call $~lib/array/Array<i32>#get:length
(get_local $0)
)
)
(nop)
(nop)
(nop)
(set_local $9
(i32.shr_s
(i32.add
(get_local $2)
(i32.const 31)
)
(i32.const 5)
)
)
(set_local $10
(call $~lib/allocator/arena/allocate_memory
(i32.shl
(get_local $9)
(i32.const 2)
)
)
)
(call $~lib/memory/set_memory
(get_local $10)
(i32.const 0)
(set_local $3
(i32.shl
(get_local $9)
(i32.shr_s
(i32.add
(get_local $2)
(i32.const 31)
)
(i32.const 5)
)
(i32.const 2)
)
)
(set_local $4
(call $~lib/allocator/arena/allocate_memory
(get_local $3)
)
)
(call $~lib/memory/set_memory
(get_local $4)
(i32.const 0)
(get_local $3)
)
(set_local $5
(i32.load
(get_local $0)
)
)
(block $break|0
(set_local $3
(set_local $6
(i32.sub
(get_local $2)
(i32.const 1)
@ -4666,30 +4667,30 @@
(loop $continue|0
(if
(i32.gt_s
(get_local $3)
(get_local $6)
(i32.const 0)
)
(block
(block
(set_local $4
(get_local $3)
(set_local $7
(get_local $6)
)
(block $break|1
(loop $continue|1
(if
(i32.eq
(i32.and
(get_local $4)
(get_local $7)
(i32.const 1)
)
(i32.and
(i32.shr_s
(i32.load
(i32.add
(get_local $10)
(get_local $4)
(i32.shl
(i32.shr_s
(get_local $4)
(get_local $7)
(i32.const 6)
)
(i32.const 2)
@ -4698,7 +4699,7 @@
)
(i32.and
(i32.shr_s
(get_local $4)
(get_local $7)
(i32.const 1)
)
(i32.const 31)
@ -4708,12 +4709,10 @@
)
)
(block
(block
(set_local $4
(i32.shr_s
(get_local $4)
(i32.const 1)
)
(set_local $7
(i32.shr_s
(get_local $7)
(i32.const 1)
)
)
(br $continue|1)
@ -4721,33 +4720,29 @@
)
)
)
(set_local $6
(set_local $8
(i32.shr_s
(get_local $4)
(get_local $7)
(i32.const 1)
)
)
(set_local $7
(set_local $9
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $5)
(i32.shl
(get_local $6)
(get_local $8)
(i32.const 2)
)
)
)
)
(set_local $8
(set_local $10
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $5)
(i32.shl
(get_local $3)
(get_local $6)
(i32.const 2)
)
)
@ -4760,8 +4755,8 @@
(i32.const 2)
)
(call_indirect (type $iii)
(get_local $7)
(get_local $8)
(get_local $9)
(get_local $10)
(get_local $1)
)
)
@ -4770,10 +4765,10 @@
(block
(i32.store
(i32.add
(get_local $10)
(get_local $4)
(i32.shl
(i32.shr_s
(get_local $3)
(get_local $6)
(i32.const 5)
)
(i32.const 2)
@ -4782,10 +4777,10 @@
(i32.xor
(i32.load
(i32.add
(get_local $10)
(get_local $4)
(i32.shl
(i32.shr_s
(get_local $3)
(get_local $6)
(i32.const 5)
)
(i32.const 2)
@ -4795,7 +4790,7 @@
(i32.shl
(i32.const 1)
(i32.and
(get_local $3)
(get_local $6)
(i32.const 31)
)
)
@ -4803,34 +4798,30 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(i32.shl
(get_local $3)
(i32.const 2)
)
)
(get_local $7)
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $5)
(i32.shl
(get_local $6)
(i32.const 2)
)
)
(get_local $8)
(get_local $9)
)
(i32.store
(i32.add
(get_local $5)
(i32.shl
(get_local $8)
(i32.const 2)
)
)
(get_local $10)
)
)
)
)
(set_local $3
(set_local $6
(i32.sub
(get_local $3)
(get_local $6)
(i32.const 1)
)
)
@ -4840,7 +4831,7 @@
)
)
(block $break|2
(set_local $3
(set_local $6
(i32.sub
(get_local $2)
(i32.const 1)
@ -4849,29 +4840,23 @@
(loop $continue|2
(if
(i32.ge_s
(get_local $3)
(get_local $6)
(i32.const 2)
)
(block
(block
(set_local $7
(set_local $10
(i32.load
(i32.load
(get_local $0)
)
(get_local $5)
)
)
(i32.store
(i32.load
(get_local $0)
)
(get_local $5)
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $5)
(i32.shl
(get_local $3)
(get_local $6)
(i32.const 2)
)
)
@ -4879,37 +4864,35 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $5)
(i32.shl
(get_local $3)
(get_local $6)
(i32.const 2)
)
)
(get_local $7)
(get_local $10)
)
(set_local $11
(set_local $9
(i32.const 1)
)
(block $break|3
(loop $continue|3
(if
(i32.lt_s
(tee_local $5
(tee_local $8
(i32.add
(i32.shl
(get_local $11)
(get_local $9)
(i32.const 1)
)
(i32.and
(i32.shr_s
(i32.load
(i32.add
(get_local $10)
(get_local $4)
(i32.shl
(i32.shr_s
(get_local $11)
(get_local $9)
(i32.const 5)
)
(i32.const 2)
@ -4917,7 +4900,7 @@
)
)
(i32.and
(get_local $11)
(get_local $9)
(i32.const 31)
)
)
@ -4925,13 +4908,11 @@
)
)
)
(get_local $3)
(get_local $6)
)
(block
(block
(set_local $11
(get_local $5)
)
(set_local $9
(get_local $8)
)
(br $continue|3)
)
@ -4942,26 +4923,22 @@
(loop $continue|4
(if
(i32.gt_s
(get_local $11)
(get_local $9)
(i32.const 0)
)
(block
(block
(set_local $7
(set_local $10
(i32.load
(i32.load
(get_local $0)
)
(get_local $5)
)
)
(set_local $8
(set_local $7
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(get_local $5)
(i32.shl
(get_local $11)
(get_local $9)
(i32.const 2)
)
)
@ -4974,8 +4951,8 @@
(i32.const 2)
)
(call_indirect (type $iii)
(get_local $10)
(get_local $7)
(get_local $8)
(get_local $1)
)
)
@ -4984,10 +4961,10 @@
(block
(i32.store
(i32.add
(get_local $10)
(get_local $4)
(i32.shl
(i32.shr_s
(get_local $11)
(get_local $9)
(i32.const 5)
)
(i32.const 2)
@ -4996,10 +4973,10 @@
(i32.xor
(i32.load
(i32.add
(get_local $10)
(get_local $4)
(i32.shl
(i32.shr_s
(get_local $11)
(get_local $9)
(i32.const 5)
)
(i32.const 2)
@ -5009,7 +4986,7 @@
(i32.shl
(i32.const 1)
(i32.and
(get_local $11)
(get_local $9)
(i32.const 31)
)
)
@ -5017,27 +4994,23 @@
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(get_local $5)
(i32.shl
(get_local $11)
(get_local $9)
(i32.const 2)
)
)
(get_local $7)
(get_local $10)
)
(i32.store
(i32.load
(get_local $0)
)
(get_local $8)
(get_local $5)
(get_local $7)
)
)
)
(set_local $11
(set_local $9
(i32.shr_s
(get_local $11)
(get_local $9)
(i32.const 1)
)
)
@ -5048,9 +5021,9 @@
)
)
)
(set_local $3
(set_local $6
(i32.sub
(get_local $3)
(get_local $6)
(i32.const 1)
)
)
@ -5060,30 +5033,22 @@
)
)
(call $~lib/allocator/arena/free_memory
(get_local $10)
(get_local $4)
)
(set_local $12
(set_local $11
(i32.load offset=4
(i32.load
(get_local $0)
)
(get_local $5)
)
)
(i32.store offset=4
(get_local $5)
(i32.load
(get_local $0)
)
(i32.load
(i32.load
(get_local $0)
)
(get_local $5)
)
)
(i32.store
(i32.load
(get_local $0)
)
(get_local $12)
(get_local $5)
(get_local $11)
)
(return
(get_local $0)