summaryrefslogtreecommitdiff
path: root/test/lit/passes/optimize-instructions.wast
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2021-07-20 22:28:07 +0300
committerGitHub <noreply@github.com>2021-07-20 12:28:07 -0700
commite67d50d5a6290ec9968344ee5712ebf62847fea8 (patch)
treef906ec3b52daa307b6b810c4a8548999ca727c11 /test/lit/passes/optimize-instructions.wast
parentfb9de9d391a7272548dcc41cd8229076189d7398 (diff)
downloadbinaryen-e67d50d5a6290ec9968344ee5712ebf62847fea8.tar.gz
binaryen-e67d50d5a6290ec9968344ee5712ebf62847fea8.tar.bz2
binaryen-e67d50d5a6290ec9968344ee5712ebf62847fea8.zip
[Optimize Instructions] Simplify sign extentions (#4004)
requiring sign-extension: ``` i64(x) << 56 >> 56 ==> i64.extend8_s(x) i64(x) << 48 >> 48 ==> i64.extend16_s(x) i64(x) << 32 >> 32 ==> i64.extend32_s(x) i64.extend_i32_s(i32.wrap_i64(x)) ==> i64.extend32_s(x) ``` general: ``` i32.wrap_i64(i64.extend_i32_s(x)) ==> x i32.wrap_i64(i64.extend_i32_u(x)) ==> x ```
Diffstat (limited to 'test/lit/passes/optimize-instructions.wast')
-rw-r--r--test/lit/passes/optimize-instructions.wast28
1 files changed, 18 insertions, 10 deletions
diff --git a/test/lit/passes/optimize-instructions.wast b/test/lit/passes/optimize-instructions.wast
index e8296e8cc..5fa703bd2 100644
--- a/test/lit/passes/optimize-instructions.wast
+++ b/test/lit/passes/optimize-instructions.wast
@@ -2707,11 +2707,7 @@
;; CHECK-NEXT: (i32.shr_s
;; CHECK-NEXT: (i32.shl
;; CHECK-NEXT: (i32.shr_u
- ;; CHECK-NEXT: (i32.wrap_i64
- ;; CHECK-NEXT: (i64.extend_i32_s
- ;; CHECK-NEXT: (i32.const -1)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const -1)
;; CHECK-NEXT: (i32.const 24)
;; CHECK-NEXT: )
;; CHECK-NEXT: (i32.const 24)
@@ -2737,11 +2733,7 @@
)
;; CHECK: (func $sext-24-shr_u-wrap-extend (result i32)
;; CHECK-NEXT: (i32.shr_u
- ;; CHECK-NEXT: (i32.wrap_i64
- ;; CHECK-NEXT: (i64.extend_i32_s
- ;; CHECK-NEXT: (i32.const -1)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const -1)
;; CHECK-NEXT: (i32.const 25)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
@@ -11256,6 +11248,22 @@
)
)
)
+
+ ;; i32.wrap_i64(i64.extend_i32_s(x)) ==> x
+ ;; i32.wrap_i64(i64.extend_i32_u(x)) ==> x
+
+ ;; CHECK: (func $sign-and-zero-extention-elimination (param $x i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $sign-and-zero-extention-elimination (param $x i32)
+ (drop (i32.wrap_i64 (i64.extend_i32_s (local.get $x))))
+ (drop (i32.wrap_i64 (i64.extend_i32_u (local.get $x))))
+ )
;; CHECK: (func $optimize-shifts (param $x i32) (param $y i32) (param $z i64) (param $w i64)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (local.get $x)