summaryrefslogtreecommitdiff
path: root/test/passes
diff options
context:
space:
mode:
Diffstat (limited to 'test/passes')
-rw-r--r--test/passes/optimize-instructions.txt107
-rw-r--r--test/passes/optimize-instructions.wast96
2 files changed, 179 insertions, 24 deletions
diff --git a/test/passes/optimize-instructions.txt b/test/passes/optimize-instructions.txt
index a11bd0d66..03f0f7074 100644
--- a/test/passes/optimize-instructions.txt
+++ b/test/passes/optimize-instructions.txt
@@ -704,11 +704,8 @@
(drop
(i32.shr_s
(i32.shl
- (i32.shl
- (i32.const 32)
- (i32.const 2)
- )
- (i32.const 24)
+ (i32.const 32)
+ (i32.const 26)
)
(i32.const 24)
)
@@ -722,11 +719,8 @@
(drop
(i32.shr_s
(i32.shl
- (i32.shl
- (i32.const 32)
- (i32.const 35)
- )
- (i32.const 24)
+ (i32.const 32)
+ (i32.const 59)
)
(i32.const 24)
)
@@ -828,13 +822,10 @@
(drop
(i32.shr_s
(i32.shl
- (i32.shl
- (i32.clz
- (i32.const 0)
- )
- (i32.const 3)
+ (i32.clz
+ (i32.const 0)
)
- (i32.const 24)
+ (i32.const 27)
)
(i32.const 24)
)
@@ -859,15 +850,12 @@
(drop
(i32.shr_s
(i32.shl
- (i32.shl
- (i32.wrap/i64
- (i64.clz
- (i64.const 0)
- )
+ (i32.wrap/i64
+ (i64.clz
+ (i64.const 0)
)
- (i32.const 2)
)
- (i32.const 24)
+ (i32.const 26)
)
(i32.const 24)
)
@@ -1018,4 +1006,77 @@
(get_local $0)
)
)
+ (func $almost-sign-ext (type $4) (param $0 i32) (param $0 i32)
+ (drop
+ (i32.shr_s
+ (i32.shl
+ (i32.const 100)
+ (i32.const 25)
+ )
+ (i32.const 24)
+ )
+ )
+ (drop
+ (i32.shl
+ (i32.const 50)
+ (i32.const 1)
+ )
+ )
+ )
+ (func $squaring (type $4) (param $0 i32) (param $1 i32)
+ (drop
+ (i32.and
+ (get_local $0)
+ (i32.const 8)
+ )
+ )
+ (drop
+ (i32.and
+ (i32.and
+ (get_local $0)
+ (i32.const 11)
+ )
+ (get_local $0)
+ )
+ )
+ (drop
+ (i32.and
+ (get_local $0)
+ (i32.const 8)
+ )
+ )
+ (drop
+ (i32.or
+ (get_local $0)
+ (i32.const 203)
+ )
+ )
+ (drop
+ (i32.shl
+ (get_local $0)
+ (i32.const 211)
+ )
+ )
+ (drop
+ (i32.shr_s
+ (get_local $0)
+ (i32.const 211)
+ )
+ )
+ (drop
+ (i32.shr_u
+ (get_local $0)
+ (i32.const 211)
+ )
+ )
+ (drop
+ (i32.shr_u
+ (i32.shr_s
+ (get_local $0)
+ (i32.const 11)
+ )
+ (i32.const 200)
+ )
+ )
+ )
)
diff --git a/test/passes/optimize-instructions.wast b/test/passes/optimize-instructions.wast
index b9bd420da..c59bb3ade 100644
--- a/test/passes/optimize-instructions.wast
+++ b/test/passes/optimize-instructions.wast
@@ -539,7 +539,7 @@
(get_local $0)
(i32.const 24)
)
- (i32.const 23) ;; different shift
+ (i32.const 23) ;; different shift, smaller
)
(i32.const 0)
)
@@ -1238,4 +1238,98 @@
)
)
)
+ (func $almost-sign-ext (param $0 i32) (param $0 i32)
+ (drop
+ (i32.shr_s
+ (i32.shl
+ (i32.const 100) ;; too big, there is a sign bit, due to the extra shift
+ (i32.const 25)
+ )
+ (i32.const 24) ;; different shift, but larger, so ok to opt if we leave a shift, in theory
+ )
+ )
+ (drop
+ (i32.shr_s
+ (i32.shl
+ (i32.const 50) ;; small enough, no sign bit
+ (i32.const 25)
+ )
+ (i32.const 24) ;; different shift, but larger, so ok to opt if we leave a shift
+ )
+ )
+ )
+ (func $squaring (param $0 i32) (param $1 i32)
+ (drop
+ (i32.and
+ (i32.and
+ (get_local $0)
+ (i32.const 11)
+ )
+ (i32.const 200)
+ )
+ )
+ (drop
+ (i32.and
+ (i32.and
+ (get_local $0)
+ (i32.const 11)
+ )
+ (get_local $0) ;; non-const, cannot optimize this!
+ )
+ )
+ (drop
+ (i32.and
+ (i32.and
+ (i32.const 11) ;; flipped order
+ (get_local $0)
+ )
+ (i32.const 200)
+ )
+ )
+ (drop
+ (i32.or
+ (i32.or
+ (get_local $0)
+ (i32.const 11)
+ )
+ (i32.const 200)
+ )
+ )
+ (drop
+ (i32.shl
+ (i32.shl
+ (get_local $0)
+ (i32.const 11)
+ )
+ (i32.const 200)
+ )
+ )
+ (drop
+ (i32.shr_s
+ (i32.shr_s
+ (get_local $0)
+ (i32.const 11)
+ )
+ (i32.const 200)
+ )
+ )
+ (drop
+ (i32.shr_u
+ (i32.shr_u
+ (get_local $0)
+ (i32.const 11)
+ )
+ (i32.const 200)
+ )
+ )
+ (drop
+ (i32.shr_u
+ (i32.shr_s ;; but do not optimize a mixture or different shifts!
+ (get_local $0)
+ (i32.const 11)
+ )
+ (i32.const 200)
+ )
+ )
+ )
)