diff options
author | Max Graey <maxgraey@gmail.com> | 2020-10-20 22:35:36 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-20 12:35:36 -0700 |
commit | 8b31756134ba4460d1dc5320198a87f88af2443c (patch) | |
tree | 2b675ce14dc02a6801b4b6cedb2cec617d7806bc /test | |
parent | c0c3812dfde2b8086b2fdd603e0d70705ec8a1e4 (diff) | |
download | binaryen-8b31756134ba4460d1dc5320198a87f88af2443c.tar.gz binaryen-8b31756134ba4460d1dc5320198a87f88af2443c.tar.bz2 binaryen-8b31756134ba4460d1dc5320198a87f88af2443c.zip |
Optimize signed division when RHS is signed minimum (#3221)
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/optimize-instructions_all-features.txt | 24 | ||||
-rw-r--r-- | test/passes/optimize-instructions_all-features.wast | 20 |
2 files changed, 41 insertions, 3 deletions
diff --git a/test/passes/optimize-instructions_all-features.txt b/test/passes/optimize-instructions_all-features.txt index f43316f3d..6ef58233f 100644 --- a/test/passes/optimize-instructions_all-features.txt +++ b/test/passes/optimize-instructions_all-features.txt @@ -4174,7 +4174,27 @@ ) ) ) - (func $rhs-is-neg-const (param $x i32) (param $y i64) + (func $rhs-is-const (param $x i32) (param $y i64) + (drop + (i32.eq + (local.get $x) + (i32.const -2147483648) + ) + ) + (drop + (i64.extend_i32_u + (i64.eq + (local.get $y) + (i64.const -9223372036854775808) + ) + ) + ) + (drop + (i64.div_s + (local.get $y) + (i64.const -2147483648) + ) + ) (drop (i32.ge_u (local.get $x) @@ -4337,7 +4357,7 @@ ) ) (drop - (i32.div_s + (i32.eq (i32.and (local.get $x) (i32.const 2147483647) diff --git a/test/passes/optimize-instructions_all-features.wast b/test/passes/optimize-instructions_all-features.wast index 934ccc977..60ae8d3c2 100644 --- a/test/passes/optimize-instructions_all-features.wast +++ b/test/passes/optimize-instructions_all-features.wast @@ -4638,7 +4638,25 @@ (i64.const -1) )) ) - (func $rhs-is-neg-const (param $x i32) (param $y i64) + (func $rhs-is-const (param $x i32) (param $y i64) + ;; signed divs + ;; i32(x) / -2147483648 -> x == -2147483648 + (drop (i32.div_s + (local.get $x) + (i32.const -2147483648) + )) + ;; i64(x) / -9223372036854775808 -> x == -9223372036854775808 + (drop (i64.div_s + (local.get $y) + (i64.const -9223372036854775808) + )) + ;; skip + (drop (i64.div_s + (local.get $y) + (i64.const -2147483648) + )) + + ;; unsigned divs ;; u32(x) / -2 => x >= -2 (drop (i32.div_u (local.get $x) |