mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-12 06:21:29 +00:00
Statically eliminate unnecessary branches in generic contexts
In order to use the new compile time type checks in generics, untaken branches must be skipped because these might be invalid.
This commit is contained in:
@ -640,6 +640,12 @@
|
||||
(set_global $builtins/F
|
||||
(f64.const 25)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_global $builtins/i)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f32.eq
|
||||
(tee_local $0
|
||||
|
@ -213,7 +213,7 @@ I = select<i64>(100, 200, false);
|
||||
f = select<f32>(1.25, 2.5, true);
|
||||
F = select<f64>(12.5, 25.0, false);
|
||||
|
||||
if (0) unreachable();
|
||||
if (!i) unreachable();
|
||||
|
||||
// AS specific
|
||||
|
||||
|
@ -1221,7 +1221,9 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.const 0)
|
||||
(i32.eqz
|
||||
(get_global $builtins/i)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(drop
|
||||
|
@ -4066,6 +4066,12 @@
|
||||
(set_global $builtins/F
|
||||
(f64.const 25)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_global $builtins/i)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f32.eq
|
||||
(tee_local $1
|
||||
|
@ -5614,7 +5614,9 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.const 0)
|
||||
(i32.eqz
|
||||
(get_global $builtins/i)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(drop
|
||||
|
@ -1,6 +1,7 @@
|
||||
(module
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $i (func (result i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
|
@ -217,73 +217,7 @@
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func "$(lib)/polyfills/bswap16<u32>" (; 5 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.and
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 25)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.const 0)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
(i32.or
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(i32.const 65280)
|
||||
)
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(i32.const -65536)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func "$(lib)/polyfills/bswap<u32>" (; 6 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func "$(lib)/polyfills/bswap<u32>" (; 5 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
@ -337,73 +271,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func "$(lib)/polyfills/bswap16<i32>" (; 7 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.and
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 25)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.const 0)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
(i32.or
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(i32.const 65280)
|
||||
)
|
||||
(i32.and
|
||||
(i32.shr_s
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(i32.const -65536)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func "$(lib)/polyfills/bswap<u64>" (; 8 ;) (type $II) (param $0 i64) (result i64)
|
||||
(func "$(lib)/polyfills/bswap<u64>" (; 6 ;) (type $II) (param $0 i64) (result i64)
|
||||
(local $1 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
@ -477,6 +345,138 @@
|
||||
(i64.const 32)
|
||||
)
|
||||
)
|
||||
(func "$(lib)/polyfills/bswap16<u32>" (; 7 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.and
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 25)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.const 0)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
(i32.or
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(i32.const 65280)
|
||||
)
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(i32.const -65536)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func "$(lib)/polyfills/bswap16<i32>" (; 8 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.and
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 25)
|
||||
(i32.const 2)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $1
|
||||
(i32.const 0)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(return
|
||||
(i32.or
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shl
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(i32.const 65280)
|
||||
)
|
||||
(i32.and
|
||||
(i32.shr_s
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
(i32.const 255)
|
||||
)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $0)
|
||||
(i32.const -65536)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(func $start (; 9 ;) (type $v)
|
||||
(if
|
||||
(i32.ne
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user