Max Graey

Results 346 comments of Max Graey

Just note. Found another possible improvments like transform this: ```wat i32.const 1 i32.const 0 get_local $p0 select ``` or this: ```wat get_local $p0 if $I0 (result i32) i32.const 1 else...

More possible optimizations: 1. from: ```wat (func $t1 (export "t1") (type $t0) (param $p0 i32) (result i32) get_local $p0 i32.const 0 i32.lt_s) ``` to: ```wat (func $t1 (export "t1") (type...

one more peephole optimization: `~(1 `rotl(-2, n)` which looks like in wat as: ```wat i32.const 1 get_local $p0 i32.shl i32.const -1 i32.xor ``` to: ```wat i32.const -2 get_local $p0 i32.rotl...

`(x >> C) != 0` =========> `(unsigned)x > ((1 > C) > 0` ==> `(unsigned)x > ((1 > C) > 0` ====> `(signed)x > ((1 > C) == 0` =========>...

Such distributive optimizations for integers also missing currently: ``` x * y + x * z x * y - x * z ``` to ``` x * (y +...

~~`(signed)x % С_pot == 0` ==> `(x & (С_pot - 1)) == 0`~~ ~~`(signed)x % С_pot != 0` ==> `(x & (С_pot - 1)) != 0`~~ `x % C ==...

Pretty common patterns. But what is surprising is neither LLVM nor GCC can't optimize this: `(x > y) - (x < y) < 0` -> `x < y` `(x >...

// add-sub integer patters `(x + y) - x` -> `y` `(x - y) - x` -> `0 - y` `(x + y) - y` -> `x` `(x - y)...

~~`-(x + C)` -> `-C - x`~~ ~~`-(C - x)` -> `x - C`~~ `-1 - x` -> `x ^ -1`

`bool(x) ? -1 : 0` -> `0 - x` `bool(x) ? 0 : -1` -> `0 - (x ^ 1)` where `bool(x) ` is `getBits(x) == 1`