summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/passes/optimize-instructions_all-features.txt106
-rw-r--r--test/passes/optimize-instructions_all-features.wast146
-rw-r--r--test/wasm2js/br_table_temp.2asm.js.opt6
3 files changed, 254 insertions, 4 deletions
diff --git a/test/passes/optimize-instructions_all-features.txt b/test/passes/optimize-instructions_all-features.txt
index b5e720353..7eebb3867 100644
--- a/test/passes/optimize-instructions_all-features.txt
+++ b/test/passes/optimize-instructions_all-features.txt
@@ -6,9 +6,9 @@
(type $none_=>_none (func))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(type $i32_=>_none (func (param i32)))
+ (type $i32_i32_i64_i64_=>_none (func (param i32 i32 i64 i64)))
(type $none_=>_i64 (func (result i64)))
(type $i64_=>_i64 (func (param i64) (result i64)))
- (type $i32_i32_i64_i64_=>_none (func (param i32 i32 i64 i64)))
(type $i32_i64_f32_=>_none (func (param i32 i64 f32)))
(type $i32_i64_f32_f64_=>_none (func (param i32 i64 f32 f64)))
(type $none_=>_anyref (func (result anyref)))
@@ -4354,6 +4354,110 @@
)
)
)
+ (func $optimize-relationals (param $x i32) (param $y i32) (param $X i64) (param $Y i64)
+ (drop
+ (i32.eq
+ (local.get $x)
+ (i32.const -2147483647)
+ )
+ )
+ (drop
+ (i32.eq
+ (local.get $x)
+ (i32.const -2147483648)
+ )
+ )
+ (drop
+ (i32.eq
+ (local.get $x)
+ (i32.const 2147483647)
+ )
+ )
+ (drop
+ (i32.eq
+ (local.get $x)
+ (local.get $y)
+ )
+ )
+ (drop
+ (i64.eq
+ (local.get $X)
+ (local.get $Y)
+ )
+ )
+ (drop
+ (i32.eq
+ (local.get $x)
+ (local.get $y)
+ )
+ )
+ (drop
+ (i64.eq
+ (local.get $X)
+ (local.get $Y)
+ )
+ )
+ (drop
+ (i32.ne
+ (local.get $x)
+ (local.get $y)
+ )
+ )
+ (drop
+ (i64.ne
+ (local.get $X)
+ (local.get $Y)
+ )
+ )
+ (drop
+ (i32.gt_s
+ (local.get $x)
+ (local.get $y)
+ )
+ )
+ (drop
+ (i32.ge_s
+ (local.get $x)
+ (local.get $y)
+ )
+ )
+ (drop
+ (i32.ne
+ (local.get $x)
+ (local.get $y)
+ )
+ )
+ (drop
+ (i32.const 1)
+ )
+ (drop
+ (i32.const 1)
+ )
+ (drop
+ (i32.lt_s
+ (local.get $x)
+ (local.get $y)
+ )
+ )
+ (drop
+ (i32.le_s
+ (local.get $x)
+ (local.get $y)
+ )
+ )
+ (drop
+ (i32.const 0)
+ )
+ (drop
+ (i32.const 0)
+ )
+ (drop
+ (i32.eq
+ (local.get $x)
+ (local.get $y)
+ )
+ )
+ )
(func $unsigned-context (param $x i32) (param $y i64)
(drop
(i32.div_u
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
diff --git a/test/wasm2js/br_table_temp.2asm.js.opt b/test/wasm2js/br_table_temp.2asm.js.opt
index 4d73ee3b6..c96c0f18e 100644
--- a/test/wasm2js/br_table_temp.2asm.js.opt
+++ b/test/wasm2js/br_table_temp.2asm.js.opt
@@ -12611,10 +12611,10 @@ function asmFunc(global, env) {
function $63($0) {
$0 = $0 | 0;
- if ($0 - 1 | 0) {
- $0 = 9
- } else {
+ if (($0 | 0) == 1) {
$0 = 8
+ } else {
+ $0 = 9
}
return $0 | 0;
}