summaryrefslogtreecommitdiff
path: root/test/passes/optimize-instructions_all-features.wast
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2020-10-07 21:13:06 +0300
committerGitHub <noreply@github.com>2020-10-07 11:13:06 -0700
commit6fbf158b04f6ba2771f4856e41d070086b5b0d96 (patch)
tree9243b8092d102b692d4e424545026e32c238592a /test/passes/optimize-instructions_all-features.wast
parentfe56186c48350e7b4b4a2243022da65703a8f1b7 (diff)
downloadbinaryen-6fbf158b04f6ba2771f4856e41d070086b5b0d96.tar.gz
binaryen-6fbf158b04f6ba2771f4856e41d070086b5b0d96.tar.bz2
binaryen-6fbf158b04f6ba2771f4856e41d070086b5b0d96.zip
Add optimization rules for some shift operations (#3099)
Specifically, truncates constant shift values that are greater than the number of bits available and optimizes out explicit masking of the shift value that is redundant with the implicit masking performed by shift operations.
Diffstat (limited to 'test/passes/optimize-instructions_all-features.wast')
-rw-r--r--test/passes/optimize-instructions_all-features.wast120
1 files changed, 120 insertions, 0 deletions
diff --git a/test/passes/optimize-instructions_all-features.wast b/test/passes/optimize-instructions_all-features.wast
index 05e0e37c3..505f89ea2 100644
--- a/test/passes/optimize-instructions_all-features.wast
+++ b/test/passes/optimize-instructions_all-features.wast
@@ -4924,6 +4924,126 @@
)
)
)
+ (func $optimize-shifts (param $x i32) (param $y i32) (param $z i64) (param $w i64)
+ ;; i32
+ (drop (i32.shl
+ (local.get $x)
+ (i32.const 32)
+ ))
+ (drop (i32.shr_s
+ (local.get $x)
+ (i32.const 32)
+ ))
+ (drop (i32.shr_u
+ (local.get $x)
+ (i32.const 64)
+ ))
+ (drop (i32.rotl
+ (local.get $x)
+ (i32.const 64)
+ ))
+ (drop (i32.rotr
+ (local.get $x)
+ (i32.const 64)
+ ))
+ ;; i64
+ (drop (i64.shl
+ (local.get $z)
+ (i64.const 64)
+ ))
+ (drop (i64.shr_s
+ (local.get $z)
+ (i64.const 64)
+ ))
+ (drop (i64.shr_u
+ (local.get $z)
+ (i64.const 128)
+ ))
+ (drop (i64.rotl
+ (local.get $z)
+ (i64.const 128)
+ ))
+ (drop (i64.rotr
+ (local.get $z)
+ (i64.const 128)
+ ))
+
+ ;; i32
+ (drop (i32.shl
+ (local.get $x)
+ (i32.and
+ (local.get $y)
+ (i32.const 31)
+ )
+ ))
+ (drop (i32.shl
+ (local.get $x)
+ (i32.and
+ (local.get $y)
+ (i32.const 63)
+ )
+ ))
+ (drop (i32.shr_s
+ (local.get $x)
+ (i32.and
+ (local.get $y)
+ (i32.const 31)
+ )
+ ))
+ (drop (i32.shr_u
+ (local.get $x)
+ (i32.and
+ (local.get $y)
+ (i32.const 31)
+ )
+ ))
+ ;; i64
+ (drop (i64.shl
+ (local.get $z)
+ (i64.and
+ (local.get $w)
+ (i64.const 63)
+ )
+ ))
+ (drop (i64.shl
+ (local.get $z)
+ (i64.and
+ (local.get $w)
+ (i64.const 127)
+ )
+ ))
+ (drop (i64.shr_s
+ (local.get $z)
+ (i64.and
+ (local.get $w)
+ (i64.const 63)
+ )
+ ))
+ (drop (i64.shr_u
+ (local.get $z)
+ (i64.and
+ (local.get $w)
+ (i64.const 63)
+ )
+ ))
+
+ ;; skip
+ (drop (i32.shl
+ (local.get $x)
+ (i32.and
+ (local.get $y)
+ (i32.const 32)
+ )
+ ))
+ ;; skip
+ (drop (i64.shr_u
+ (local.get $z)
+ (i64.and
+ (local.get $w)
+ (i64.const 31)
+ )
+ ))
+ )
(func $optimize-bulk-memory-copy (param $dst i32) (param $src i32) (param $sz i32)
(memory.copy ;; skip
(local.get $dst)