diff options
author | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-02-11 21:55:14 -0800 |
---|---|---|
committer | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-02-16 22:45:37 -0800 |
commit | c06b3762a09e95443fd0f159b2675209db1dbb29 (patch) | |
tree | fcdeda6f567e35a11582e5879746c20910499388 /test | |
parent | 2553266cf716df3f03d5d057887ed660c12f4fb6 (diff) | |
download | binaryen-c06b3762a09e95443fd0f159b2675209db1dbb29.tar.gz binaryen-c06b3762a09e95443fd0f159b2675209db1dbb29.tar.bz2 binaryen-c06b3762a09e95443fd0f159b2675209db1dbb29.zip |
optimize out a sign-ext into a store of the same size
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/optimize-instructions.txt | 59 | ||||
-rw-r--r-- | test/passes/optimize-instructions.wast | 82 |
2 files changed, 141 insertions, 0 deletions
diff --git a/test/passes/optimize-instructions.txt b/test/passes/optimize-instructions.txt index 7daf6815c..d36f1ffad 100644 --- a/test/passes/optimize-instructions.txt +++ b/test/passes/optimize-instructions.txt @@ -4,6 +4,7 @@ (type $2 (func (result i32))) (type $3 (func (param i32) (result i32))) (type $4 (func (param i32 i32))) + (type $5 (func (param i32))) (memory $0 0) (export "load-off-2" (func $load-off-2)) (func $f (type $0) (param $i1 i32) (param $i2 i64) @@ -1141,4 +1142,62 @@ (get_local $0) ) ) + (func $store-signext (type $5) (param $0 i32) + (i32.store8 + (i32.const 8) + (get_local $0) + ) + (i32.store8 + (i32.const 8) + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 25) + ) + (i32.const 25) + ) + ) + (i32.store8 + (i32.const 8) + (get_local $0) + ) + (i32.store16 + (i32.const 8) + (get_local $0) + ) + (i32.store16 + (i32.const 8) + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 17) + ) + (i32.const 17) + ) + ) + (i32.store16 + (i32.const 8) + (get_local $0) + ) + (i32.store + (i32.const 8) + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 16) + ) + (i32.const 16) + ) + ) + (i32.store + (i32.const 8) + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 8) + ) + (i32.const 8) + ) + ) + ) ) diff --git a/test/passes/optimize-instructions.wast b/test/passes/optimize-instructions.wast index 9bd5d975a..6cba3d51f 100644 --- a/test/passes/optimize-instructions.wast +++ b/test/passes/optimize-instructions.wast @@ -1419,4 +1419,86 @@ ) ) ) + (func $store-signext (param $0 i32) + (i32.store8 + (i32.const 8) + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 24) ;; exact size we store, sign-ext of 8 bits + ) + (i32.const 24) + ) + ) + (i32.store8 + (i32.const 8) + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 25) ;; 7 bits. so the ext can alter a bit we store, do not optimize + ) + (i32.const 25) + ) + ) + (i32.store8 + (i32.const 8) + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 23) ;; 9 bits, this is good to optimize + ) + (i32.const 23) + ) + ) + (i32.store16 + (i32.const 8) + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 16) ;; exact size we store, sign-ext of 16 bits + ) + (i32.const 16) + ) + ) + (i32.store16 + (i32.const 8) + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 17) ;; 15 bits. so the ext can alter a bit we store, do not optimize + ) + (i32.const 17) + ) + ) + (i32.store16 + (i32.const 8) + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 14) ;; 17 bits, this is good to optimize + ) + (i32.const 14) + ) + ) + (i32.store + (i32.const 8) + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 16) ;; 4 bytes stored, do nothing + ) + (i32.const 16) + ) + ) + (i32.store + (i32.const 8) + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 8) ;; 4 bytes stored, do nothing + ) + (i32.const 8) + ) + ) + ) ) |