summaryrefslogtreecommitdiff
path: root/test/passes/local-cse.txt
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-03-08 13:54:04 -0800
committerGitHub <noreply@github.com>2017-03-08 13:54:04 -0800
commitd6508e1f9cef33c43016e4da7dd4b94392f280a9 (patch)
treed0a12833a0ea08ed7c317bec7b4ef6fa936a70f3 /test/passes/local-cse.txt
parent71804e2bfd1ba49b7dd4ce82b6ad26ba13f1bca8 (diff)
downloadbinaryen-d6508e1f9cef33c43016e4da7dd4b94392f280a9.tar.gz
binaryen-d6508e1f9cef33c43016e4da7dd4b94392f280a9.tar.bz2
binaryen-d6508e1f9cef33c43016e4da7dd4b94392f280a9.zip
Local CSE (#930)
Simple local common subexpression elimination. Useful mostly to reduce code size (as VMs do GVN etc.). Enabled by default in -Oz.
Diffstat (limited to 'test/passes/local-cse.txt')
-rw-r--r--test/passes/local-cse.txt183
1 files changed, 183 insertions, 0 deletions
diff --git a/test/passes/local-cse.txt b/test/passes/local-cse.txt
new file mode 100644
index 000000000..1b740236e
--- /dev/null
+++ b/test/passes/local-cse.txt
@@ -0,0 +1,183 @@
+(module
+ (type $0 (func))
+ (type $1 (func (param i32) (result i32)))
+ (memory $0 100 100)
+ (func $basics (type $0)
+ (local $x i32)
+ (local $y i32)
+ (local $2 i32)
+ (local $3 i32)
+ (drop
+ (tee_local $2
+ (i32.add
+ (i32.const 1)
+ (i32.const 2)
+ )
+ )
+ )
+ (drop
+ (get_local $2)
+ )
+ (if
+ (i32.const 0)
+ (nop)
+ )
+ (drop
+ (i32.add
+ (i32.const 1)
+ (i32.const 2)
+ )
+ )
+ (drop
+ (tee_local $3
+ (i32.add
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ )
+ (drop
+ (get_local $3)
+ )
+ (drop
+ (get_local $3)
+ )
+ (call $basics)
+ (drop
+ (get_local $3)
+ )
+ (set_local $x
+ (i32.const 100)
+ )
+ (drop
+ (i32.add
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ )
+ (func $recursive1 (type $0)
+ (local $x i32)
+ (local $y i32)
+ (local $2 i32)
+ (drop
+ (i32.add
+ (i32.const 1)
+ (tee_local $2
+ (i32.add
+ (i32.const 2)
+ (i32.const 3)
+ )
+ )
+ )
+ )
+ (drop
+ (i32.add
+ (i32.const 1)
+ (get_local $2)
+ )
+ )
+ (drop
+ (get_local $2)
+ )
+ )
+ (func $recursive2 (type $0)
+ (local $x i32)
+ (local $y i32)
+ (local $2 i32)
+ (drop
+ (i32.add
+ (i32.const 1)
+ (tee_local $2
+ (i32.add
+ (i32.const 2)
+ (i32.const 3)
+ )
+ )
+ )
+ )
+ (drop
+ (get_local $2)
+ )
+ (drop
+ (i32.add
+ (i32.const 1)
+ (get_local $2)
+ )
+ )
+ )
+ (func $self (type $0)
+ (local $x i32)
+ (local $y i32)
+ (local $2 i32)
+ (drop
+ (i32.add
+ (tee_local $2
+ (i32.add
+ (i32.const 2)
+ (i32.const 3)
+ )
+ )
+ (get_local $2)
+ )
+ )
+ (drop
+ (get_local $2)
+ )
+ )
+ (func $loads (type $0)
+ (drop
+ (i32.load
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.load
+ (i32.const 10)
+ )
+ )
+ )
+ (func $8 (type $1) (param $var$0 i32) (result i32)
+ (local $var$1 i32)
+ (local $var$2 i32)
+ (local $var$3 i32)
+ (local $4 i32)
+ (block $label$0 i32
+ (i32.store
+ (tee_local $var$2
+ (tee_local $4
+ (i32.add
+ (get_local $var$1)
+ (i32.const 4)
+ )
+ )
+ )
+ (i32.and
+ (i32.load
+ (get_local $var$2)
+ )
+ (i32.xor
+ (tee_local $var$2
+ (i32.const 74)
+ )
+ (i32.const -1)
+ )
+ )
+ )
+ (i32.store
+ (tee_local $var$1
+ (get_local $4)
+ )
+ (i32.or
+ (i32.load
+ (get_local $var$1)
+ )
+ (i32.and
+ (get_local $var$2)
+ (i32.const 8)
+ )
+ )
+ )
+ )
+ )
+)