summaryrefslogtreecommitdiff
path: root/test/lit/help
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-09-03 11:00:10 -0700
committerGitHub <noreply@github.com>2021-09-03 11:00:10 -0700
commit99ccc313b2c1d91bbfcee48fe99d70a2867befbc (patch)
treeb52a466a3d9eaf8685edfc52e393230c099cf8de /test/lit/help
parent548d1971c3c844e8dab8c0da4e97aa5c339937df (diff)
downloadbinaryen-99ccc313b2c1d91bbfcee48fe99d70a2867befbc.tar.gz
binaryen-99ccc313b2c1d91bbfcee48fe99d70a2867befbc.tar.bz2
binaryen-99ccc313b2c1d91bbfcee48fe99d70a2867befbc.zip
Optimize away dominated calls to functions that run only once (#4111)
Some functions run only once with this pattern: function foo() { if (foo$ran) return; foo$ran = 1; ... } If that global is not ever set to 0, then the function's payload (after the initial if and return) will never execute more than once. That means we can optimize away dominated calls: foo(); foo(); // we can remove this To do this, we find which globals are "once", which means they can fit in that pattern, as they are never set to 0. If a function looks like the above pattern, and it's global is "once", then the function is "once" as well, and we can perform this optimization. This removes over 8% of static calls in j2cl.
Diffstat (limited to 'test/lit/help')
-rw-r--r--test/lit/help/optimization-opts.test3
1 files changed, 3 insertions, 0 deletions
diff --git a/test/lit/help/optimization-opts.test b/test/lit/help/optimization-opts.test
index 52695077a..18f8970c2 100644
--- a/test/lit/help/optimization-opts.test
+++ b/test/lit/help/optimization-opts.test
@@ -348,6 +348,9 @@
;; CHECK-NEXT: is valid if the C runtime will
;; CHECK-NEXT: never be exited
;; CHECK-NEXT:
+;; CHECK-NEXT: --once-reduction reduces calls to code that only
+;; CHECK-NEXT: runs once
+;; CHECK-NEXT:
;; CHECK-NEXT: --optimize-added-constants optimizes added constants into
;; CHECK-NEXT: load/store offsets
;; CHECK-NEXT: