summaryrefslogtreecommitdiff
path: root/test/passes/post-emscripten.wast
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-03-10 10:44:37 -0800
committerGitHub <noreply@github.com>2017-03-10 10:44:37 -0800
commitd54c03e99f9a43bde1b6cec94f05b0af412d0e4f (patch)
tree94128b81f1f1d2e9ecf83fe2e699e2528f6c49fc /test/passes/post-emscripten.wast
parentd79d71ac7dfe807a5e98b94c9d1f67df4da7998a (diff)
downloadbinaryen-d54c03e99f9a43bde1b6cec94f05b0af412d0e4f.tar.gz
binaryen-d54c03e99f9a43bde1b6cec94f05b0af412d0e4f.tar.bz2
binaryen-d54c03e99f9a43bde1b6cec94f05b0af412d0e4f.zip
optimize pow (#934)
* optimize pow(x,2) => x*x * optimize pow(x, 0.5) => sqrt(x)
Diffstat (limited to 'test/passes/post-emscripten.wast')
-rw-r--r--test/passes/post-emscripten.wast56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/passes/post-emscripten.wast b/test/passes/post-emscripten.wast
index f262975f5..5c255ffca 100644
--- a/test/passes/post-emscripten.wast
+++ b/test/passes/post-emscripten.wast
@@ -1,6 +1,7 @@
(module
(memory 256 256)
(type $0 (func (param i32)))
+ (import "global.Math" "pow" (func $Math_pow (param f64 f64) (result f64)))
(func $b0 (type $0) (param $x i32)
(drop
(i32.load
@@ -152,4 +153,59 @@
)
)
)
+ (func $pow2
+ (local $x f64)
+ (local $y f64)
+ (drop
+ (call $Math_pow
+ (f64.const 1)
+ (f64.const 2)
+ )
+ )
+ (drop
+ (call $Math_pow
+ (f64.const 1)
+ (f64.const 3)
+ )
+ )
+ (drop
+ (call $Math_pow
+ (f64.const 2)
+ (f64.const 1)
+ )
+ )
+ (set_local $x (f64.const 5))
+ (drop
+ (call $Math_pow
+ (get_local $x)
+ (f64.const 2)
+ )
+ )
+ (drop
+ (call $Math_pow
+ (tee_local $y (f64.const 7))
+ (f64.const 2)
+ )
+ )
+ (drop
+ (call $Math_pow
+ (f64.const 8)
+ (f64.const 2)
+ )
+ )
+ )
+ (func $pow.2
+ (drop
+ (call $Math_pow
+ (f64.const 1)
+ (f64.const 0.5)
+ )
+ )
+ (drop
+ (call $Math_pow
+ (f64.const 1)
+ (f64.const 0.51)
+ )
+ )
+ )
)