summaryrefslogtreecommitdiff
path: root/test/lit/passes
diff options
context:
space:
mode:
Diffstat (limited to 'test/lit/passes')
-rw-r--r--test/lit/passes/O4_disable-bulk-memory.wast4
-rw-r--r--test/lit/passes/inlining-optimizing_optimize-level=3.wast12
-rw-r--r--test/lit/passes/optimize-instructions.wast125
3 files changed, 125 insertions, 16 deletions
diff --git a/test/lit/passes/O4_disable-bulk-memory.wast b/test/lit/passes/O4_disable-bulk-memory.wast
index 8200df5a3..c0bcc07a9 100644
--- a/test/lit/passes/O4_disable-bulk-memory.wast
+++ b/test/lit/passes/O4_disable-bulk-memory.wast
@@ -236,9 +236,9 @@
;; CHECK-NEXT: (i32.add
;; CHECK-NEXT: (i32.add
;; CHECK-NEXT: (select
- ;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: (i32.gt_u
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: (i32.le_u
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: )
diff --git a/test/lit/passes/inlining-optimizing_optimize-level=3.wast b/test/lit/passes/inlining-optimizing_optimize-level=3.wast
index d8157d9a1..4fa8e1936 100644
--- a/test/lit/passes/inlining-optimizing_optimize-level=3.wast
+++ b/test/lit/passes/inlining-optimizing_optimize-level=3.wast
@@ -5413,9 +5413,9 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: (local.set $6
;; CHECK-NEXT: (select
- ;; CHECK-NEXT: (local.get $6)
;; CHECK-NEXT: (i32.const 8)
- ;; CHECK-NEXT: (i32.gt_u
+ ;; CHECK-NEXT: (local.get $6)
+ ;; CHECK-NEXT: (i32.le_u
;; CHECK-NEXT: (local.get $6)
;; CHECK-NEXT: (i32.const 8)
;; CHECK-NEXT: )
@@ -7473,14 +7473,14 @@
;; CHECK-NEXT: (local.get $19)
;; CHECK-NEXT: (local.tee $5
;; CHECK-NEXT: (select
- ;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (local.tee $5
;; CHECK-NEXT: (i32.sub
;; CHECK-NEXT: (local.get $6)
;; CHECK-NEXT: (local.get $5)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
- ;; CHECK-NEXT: (i32.lt_s
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: (i32.ge_s
;; CHECK-NEXT: (local.get $5)
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
@@ -7500,7 +7500,6 @@
;; CHECK-NEXT: (local.get $19)
;; CHECK-NEXT: (local.tee $5
;; CHECK-NEXT: (select
- ;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (local.tee $5
;; CHECK-NEXT: (i32.sub
;; CHECK-NEXT: (i32.add
@@ -7510,7 +7509,8 @@
;; CHECK-NEXT: (local.get $5)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
- ;; CHECK-NEXT: (i32.lt_s
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: (i32.ge_s
;; CHECK-NEXT: (local.get $5)
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
diff --git a/test/lit/passes/optimize-instructions.wast b/test/lit/passes/optimize-instructions.wast
index 3c9cfb2be..71d4e7fe3 100644
--- a/test/lit/passes/optimize-instructions.wast
+++ b/test/lit/passes/optimize-instructions.wast
@@ -893,9 +893,35 @@
)
)
)
+ ;; CHECK: (func $select-or-negation (param $x i32) (param $y i32) (result i32)
+ ;; CHECK-NEXT: (i32.and
+ ;; CHECK-NEXT: (i32.eq
+ ;; CHECK-NEXT: (local.get $y)
+ ;; CHECK-NEXT: (i32.const 1337)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.ge_u
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: (i32.const 20)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $select-or-negation (param $x i32) (param $y i32) (result i32)
+ (select
+ ;; We can turn this select into an and by negating the condition.
+ (i32.const 0)
+ (i32.eq
+ (local.get $y)
+ (i32.const 1337)
+ )
+ (i32.lt_u
+ (local.get $x)
+ (i32.const 20)
+ )
+ )
+ )
;; CHECK: (func $select-or-no-const (param $x i32) (param $y i32) (result i32)
;; CHECK-NEXT: (select
- ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: (i32.const 2)
;; CHECK-NEXT: (i32.eq
;; CHECK-NEXT: (local.get $y)
;; CHECK-NEXT: (i32.const 1337)
@@ -908,8 +934,8 @@
;; CHECK-NEXT: )
(func $select-or-no-const (param $x i32) (param $y i32) (result i32)
(select
- ;; The wrong const (should be 1).
- (i32.const 0)
+ ;; The wrong const (should be 0 or 1).
+ (i32.const 2)
(i32.eq
(local.get $y)
(i32.const 1337)
@@ -945,14 +971,97 @@
)
)
)
- ;; CHECK: (func $select-and-no-const (param $x i32) (param $y i32) (result i32)
+ ;; CHECK: (func $select-and-negation (param $x i32) (param $y i32) (result i32)
+ ;; CHECK-NEXT: (i32.or
+ ;; CHECK-NEXT: (i32.eq
+ ;; CHECK-NEXT: (local.get $y)
+ ;; CHECK-NEXT: (i32.const 1337)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.ne
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: (i32.const 42)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $select-and-negation (param $x i32) (param $y i32) (result i32)
+ (select
+ (i32.eq
+ (local.get $y)
+ (i32.const 1337)
+ )
+ ;; With a 1 here, we negate the condition.
+ (i32.const 1)
+ (i32.eq
+ (local.get $x)
+ (i32.const 42)
+ )
+ )
+ )
+ ;; CHECK: (func $select-and-negation-impossible (param $x i32) (param $y i32) (result i32)
+ ;; CHECK-NEXT: (select
+ ;; CHECK-NEXT: (i32.eq
+ ;; CHECK-NEXT: (local.get $y)
+ ;; CHECK-NEXT: (i32.const 1337)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: (i32.shr_u
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: (i32.const 31)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $select-and-negation-impossible (param $x i32) (param $y i32) (result i32)
+ (select
+ (i32.eq
+ (local.get $y)
+ (i32.const 1337)
+ )
+ ;; With a 1 here, we must negate the condition, but the condition here
+ ;; cannot be negated in a simple way, so skip.
+ (i32.const 1)
+ (i32.shr_u
+ (local.get $x)
+ (i32.const 31)
+ )
+ )
+ )
+ ;; CHECK: (func $select-and-negation-impossible-float (param $x f64) (param $y i32) (result i32)
;; CHECK-NEXT: (select
;; CHECK-NEXT: (i32.eq
;; CHECK-NEXT: (local.get $y)
;; CHECK-NEXT: (i32.const 1337)
;; CHECK-NEXT: )
;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: (f64.le
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: (f64.const 3.14159)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $select-and-negation-impossible-float (param $x f64) (param $y i32) (result i32)
+ (select
+ (i32.eq
+ (local.get $y)
+ (i32.const 1337)
+ )
+ ;; With a 1 here, we must negate the condition, but the condition here
+ ;; cannot be negated due to it operating on floats (where NaNs cause
+ ;; difficulties), so we skip.
+ (i32.const 1)
+ (f64.le
+ (local.get $x)
+ (f64.const 3.14159)
+ )
+ )
+ )
+ ;; CHECK: (func $select-and-no-const (param $x i32) (param $y i32) (result i32)
+ ;; CHECK-NEXT: (select
+ ;; CHECK-NEXT: (i32.const 2)
;; CHECK-NEXT: (i32.eq
+ ;; CHECK-NEXT: (local.get $y)
+ ;; CHECK-NEXT: (i32.const 1337)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.ne
;; CHECK-NEXT: (local.get $x)
;; CHECK-NEXT: (i32.const 42)
;; CHECK-NEXT: )
@@ -964,8 +1073,8 @@
(local.get $y)
(i32.const 1337)
)
- ;; The wrong constant (should be 0).
- (i32.const 1)
+ ;; The wrong constant (should be 0 or 1).
+ (i32.const 2)
(i32.eq
(local.get $x)
(i32.const 42)
@@ -11271,9 +11380,9 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (select
- ;; CHECK-NEXT: (i64.const 0)
;; CHECK-NEXT: (local.get $y)
- ;; CHECK-NEXT: (i64.ne
+ ;; CHECK-NEXT: (i64.const 0)
+ ;; CHECK-NEXT: (i64.eq
;; CHECK-NEXT: (local.get $y)
;; CHECK-NEXT: (i64.const 1)
;; CHECK-NEXT: )