summaryrefslogtreecommitdiff
path: root/test/passes/optimize-instructions.wast
diff options
context:
space:
mode:
authorAlon Zakai (kripken) <alonzakai@gmail.com>2017-02-13 17:47:48 -0800
committerAlon Zakai (kripken) <alonzakai@gmail.com>2017-02-16 22:45:40 -0800
commitff8705ef08502411093cef7a90c7f30833147af1 (patch)
treea87e230a8bcab95a9ff8d25b60657dc9ba8d5508 /test/passes/optimize-instructions.wast
parentced44f4fd543b50980d4bf674fa6a30f9c31790f (diff)
downloadbinaryen-ff8705ef08502411093cef7a90c7f30833147af1.tar.gz
binaryen-ff8705ef08502411093cef7a90c7f30833147af1.tar.bz2
binaryen-ff8705ef08502411093cef7a90c7f30833147af1.zip
optimize a compare of a load_s and a sign-extend into a load_u and a cheaper zero-extend
Diffstat (limited to 'test/passes/optimize-instructions.wast')
-rw-r--r--test/passes/optimize-instructions.wast86
1 files changed, 86 insertions, 0 deletions
diff --git a/test/passes/optimize-instructions.wast b/test/passes/optimize-instructions.wast
index 2f2333867..51bd076d1 100644
--- a/test/passes/optimize-instructions.wast
+++ b/test/passes/optimize-instructions.wast
@@ -2020,4 +2020,90 @@
)
)
)
+ (func $compare-load-s-sign-extend (param $0 i32) (param $1 i32)
+ (drop
+ (i32.eq
+ (i32.load8_s
+ (get_local $0)
+ )
+ (i32.shr_s
+ (i32.shl
+ (get_local $1)
+ (i32.const 24)
+ )
+ (i32.const 24)
+ )
+ )
+ )
+ (drop
+ (i32.eq
+ (i32.shr_s
+ (i32.shl
+ (get_local $1)
+ (i32.const 24)
+ )
+ (i32.const 24)
+ )
+ (i32.load8_s
+ (get_local $0) ;; flip order, we should canonicalize
+ )
+ )
+ )
+ (drop
+ (i32.eq
+ (i32.load8_u ;; unsigned, bad
+ (get_local $0)
+ )
+ (i32.shr_s
+ (i32.shl
+ (get_local $1)
+ (i32.const 24)
+ )
+ (i32.const 24)
+ )
+ )
+ )
+ (drop
+ (i32.eq
+ (i32.load8_s
+ (get_local $0)
+ )
+ (i32.shr_s
+ (i32.shl
+ (get_local $1)
+ (i32.const 16) ;; wrong size
+ )
+ (i32.const 16)
+ )
+ )
+ )
+ (drop
+ (i32.eq
+ (i32.shr_s
+ (i32.shl
+ (get_local $1)
+ (i32.const 24)
+ )
+ (i32.const 24)
+ )
+ (i32.load8_u ;; unsigned, bad
+ (get_local $0)
+ )
+ )
+ )
+ (drop
+ (i32.eq
+ (i32.shr_s
+ (i32.shl
+ (get_local $1)
+ (i32.const 16) ;; wrong size
+ )
+ (i32.const 16)
+ )
+ (i32.load8_s
+ (get_local $0)
+ )
+ )
+ )
+ )
)