summaryrefslogtreecommitdiff
path: root/test/passes/optimize-instructions_all-features.wast
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2020-10-26 06:53:17 +0200
committerGitHub <noreply@github.com>2020-10-25 21:53:17 -0700
commitd0032c299695c765e757de5f9482a610bf687d69 (patch)
tree737d4485a6d8652538b89a3d7ddfa9891a67278b /test/passes/optimize-instructions_all-features.wast
parentb8b457ddad939a316cb833a8beb8987ca04fa865 (diff)
downloadbinaryen-d0032c299695c765e757de5f9482a610bf687d69.tar.gz
binaryen-d0032c299695c765e757de5f9482a610bf687d69.tar.bz2
binaryen-d0032c299695c765e757de5f9482a610bf687d69.zip
Optimize relations of subtractions and zero (#3275)
Diffstat (limited to 'test/passes/optimize-instructions_all-features.wast')
-rw-r--r--test/passes/optimize-instructions_all-features.wast146
1 files changed, 146 insertions, 0 deletions
diff --git a/test/passes/optimize-instructions_all-features.wast b/test/passes/optimize-instructions_all-features.wast
index f857c1f5f..c2c1609ba 100644
--- a/test/passes/optimize-instructions_all-features.wast
+++ b/test/passes/optimize-instructions_all-features.wast
@@ -4842,6 +4842,152 @@
)
))
)
+ (func $optimize-relationals (param $x i32) (param $y i32) (param $X i64) (param $Y i64)
+ ;; eqz(x + 0x7FFFFFFF) -> x == -2147483647
+ (drop (i32.eqz
+ (i32.add
+ (local.get $x)
+ (i32.const 0x7FFFFFFF)
+ )
+ ))
+ ;; eqz(x + 0x80000000) -> x == -2147483648
+ (drop (i32.eqz
+ (i32.add
+ (local.get $x)
+ (i32.const 0x80000000)
+ )
+ ))
+ ;; eqz(x + 0x80000001) -> x == 2147483647
+ (drop (i32.eqz
+ (i32.add
+ (local.get $x)
+ (i32.const 0x80000001)
+ )
+ ))
+ ;; eqz(x - y)
+ (drop (i32.eqz
+ (i32.sub
+ (local.get $x)
+ (local.get $y)
+ )
+ ))
+ (drop (i64.eqz
+ (i64.sub
+ (local.get $X)
+ (local.get $Y)
+ )
+ ))
+ ;; x - y == 0
+ (drop (i32.eq
+ (i32.sub
+ (local.get $x)
+ (local.get $y)
+ )
+ (i32.const 0)
+ ))
+ (drop (i64.eq
+ (i64.sub
+ (local.get $X)
+ (local.get $Y)
+ )
+ (i64.const 0)
+ ))
+ ;; x - y != 0
+ (drop (i32.ne
+ (i32.sub
+ (local.get $x)
+ (local.get $y)
+ )
+ (i32.const 0)
+ ))
+ (drop (i64.ne
+ (i64.sub
+ (local.get $X)
+ (local.get $Y)
+ )
+ (i64.const 0)
+ ))
+ ;; i32(x - y) > 0 -> x > y
+ (drop (i32.gt_s
+ (i32.sub
+ (local.get $x)
+ (local.get $y)
+ )
+ (i32.const 0)
+ ))
+ ;; i32(x - y) >= 0 -> x >= y
+ (drop (i32.ge_s
+ (i32.sub
+ (local.get $x)
+ (local.get $y)
+ )
+ (i32.const 0)
+ ))
+ ;; u32(x - y) > 0 -> x != y
+ (drop (i32.gt_u
+ (i32.sub
+ (local.get $x)
+ (local.get $y)
+ )
+ (i32.const 0)
+ ))
+ ;; u32(x - y) >= 0 -> 1
+ (drop (i32.ge_u
+ (i32.sub
+ (local.get $x)
+ (local.get $y)
+ )
+ (i32.const 0)
+ ))
+ ;; u64(x - y) >= 0 -> i32(1)
+ (drop (i64.ge_u
+ (i64.sub
+ (local.get $X)
+ (local.get $Y)
+ )
+ (i64.const 0)
+ ))
+ ;; i32(x - y) < 0 -> x < y
+ (drop (i32.lt_s
+ (i32.sub
+ (local.get $x)
+ (local.get $y)
+ )
+ (i32.const 0)
+ ))
+ ;; i32(x - y) <= 0 -> x <= y
+ (drop (i32.le_s
+ (i32.sub
+ (local.get $x)
+ (local.get $y)
+ )
+ (i32.const 0)
+ ))
+ ;; u32(x - y) < 0 -> 0
+ (drop (i32.lt_u
+ (i32.sub
+ (local.get $x)
+ (local.get $y)
+ )
+ (i32.const 0)
+ ))
+ ;; u64(x - y) < 0 -> i32(0)
+ (drop (i64.lt_u
+ (i64.sub
+ (local.get $X)
+ (local.get $Y)
+ )
+ (i64.const 0)
+ ))
+ ;; u32(x - y) <= 0 -> x == y
+ (drop (i32.le_u
+ (i32.sub
+ (local.get $x)
+ (local.get $y)
+ )
+ (i32.const 0)
+ ))
+ )
(func $unsigned-context (param $x i32) (param $y i64)
(drop (i32.div_s
(i32.and