summaryrefslogtreecommitdiff
path: root/test/lit/passes/Oz.wast
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2021-10-05 19:06:15 +0300
committerGitHub <noreply@github.com>2021-10-05 16:06:15 +0000
commit653b9d028c12361d3e9e0c4008f8018990b765cb (patch)
tree04fd27a6cfffdbc702a77f62af9c9eef6c3e311f /test/lit/passes/Oz.wast
parent6feb8838887d21f2412176f7fdc1ab68b0e5c23d (diff)
downloadbinaryen-653b9d028c12361d3e9e0c4008f8018990b765cb.tar.gz
binaryen-653b9d028c12361d3e9e0c4008f8018990b765cb.tar.bz2
binaryen-653b9d028c12361d3e9e0c4008f8018990b765cb.zip
[OptimizeInstructions] Fold select into zero or single expression for some patterns (#4181)
i32(x) ? i32(x) : 0 ==> x i32(x) ? 0 : i32(x) ==> {x, 0} i64(x) == 0 ? 0 : i64(x) ==> x i64(x) != 0 ? i64(x) : 0 ==> x i64(x) == 0 ? i64(x) : 0 ==> {x, 0} i64(x) != 0 ? 0 : i64(x) ==> {x, 0}
Diffstat (limited to 'test/lit/passes/Oz.wast')
-rw-r--r--test/lit/passes/Oz.wast128
1 files changed, 126 insertions, 2 deletions
diff --git a/test/lit/passes/Oz.wast b/test/lit/passes/Oz.wast
index 82c441213..eabcf9aff 100644
--- a/test/lit/passes/Oz.wast
+++ b/test/lit/passes/Oz.wast
@@ -5,10 +5,10 @@
(module
(memory 100 100)
- ;; CHECK: (type $i32_=>_i32 (func (param i32) (result i32)))
-
;; CHECK: (type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
+ ;; CHECK: (type $i32_=>_i32 (func (param i32) (result i32)))
+
;; CHECK: (type $i32_i32_i32_i32_=>_i32 (func (param i32 i32 i32 i32) (result i32)))
;; CHECK: (memory $0 100 100)
@@ -21,6 +21,18 @@
;; CHECK: (export "propagate-sign-for-mul-i32-smin" (func $10))
+ ;; CHECK: (export "eliminate-redundant-checks-1" (func $11))
+
+ ;; CHECK: (export "eliminate-redundant-checks-1a" (func $11))
+
+ ;; CHECK: (export "eliminate-redundant-checks-2" (func $12))
+
+ ;; CHECK: (export "eliminate-redundant-checks-2a" (func $12))
+
+ ;; CHECK: (export "eliminate-redundant-checks-skip-1" (func $13))
+
+ ;; CHECK: (export "eliminate-redundant-checks-skip-2" (func $14))
+
;; CHECK: (func $basics (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
;; CHECK-NEXT: (i32.add
;; CHECK-NEXT: (local.tee $0
@@ -150,4 +162,116 @@
(i32.const 0x80000000)
)
)
+
+ ;; CHECK: (func $11 (; has Stack IR ;) (param $0 i32) (result i32)
+ ;; CHECK-NEXT: (if
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: (return
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ (func $11 (export "eliminate-redundant-checks-1") (param $0 i32) (result i32)
+ (if
+ (local.get $0)
+ (if
+ (local.get $0)
+ (return (local.get $0))
+ )
+ )
+ (i32.const 0)
+ )
+ (func $11a (export "eliminate-redundant-checks-1a") (param $0 i32) (result i32)
+ (if
+ (select
+ (local.get $0)
+ (i32.const 0)
+ (local.get $0)
+ )
+ (return (local.get $0))
+ )
+ (i32.const 0)
+ )
+ ;; CHECK: (func $12 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
+ ;; CHECK-NEXT: (if
+ ;; CHECK-NEXT: (local.tee $1
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (return
+ ;; CHECK-NEXT: (local.get $1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ (func $12 (export "eliminate-redundant-checks-2") (param $0 i32) (param $1 i32) (result i32)
+ (if
+ (local.tee $1 (local.get $0))
+ (if
+ (local.get $1)
+ (return (local.get $1))
+ )
+ )
+ (i32.const 0)
+ )
+ (func $12a (export "eliminate-redundant-checks-2a") (param $0 i32) (param $1 i32) (result i32)
+ (if
+ (select
+ (local.tee $1 (local.get $0))
+ (i32.const 0)
+ (local.get $1)
+ )
+ (return (local.get $1))
+ )
+ (i32.const 0)
+ )
+ ;; CHECK: (func $13 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
+ ;; CHECK-NEXT: (if
+ ;; CHECK-NEXT: (select
+ ;; CHECK-NEXT: (local.get $1)
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (return
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ (func $13 (export "eliminate-redundant-checks-skip-1") (param $0 i32) (param $1 i32) (result i32)
+ (if
+ (select
+ (local.get $1)
+ (i32.const 0)
+ (local.tee $1 (local.get $0))
+ )
+ (return (local.get $1))
+ )
+ (i32.const 0)
+ )
+
+ ;; CHECK: (func $14 (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
+ ;; CHECK-NEXT: (if
+ ;; CHECK-NEXT: (select
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: (local.get $1)
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (return
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ (func $14 (export "eliminate-redundant-checks-skip-2") (param $0 i32) (param $1 i32) (result i32)
+ (if
+ (select
+ (i32.const 0)
+ (local.get $1)
+ (local.tee $1 (local.get $0))
+ )
+ (return (local.get $1))
+ )
+ (i32.const 0)
+ )
)