diff options
author | Alon Zakai <azakai@google.com> | 2021-08-05 11:03:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-05 11:03:34 -0700 |
commit | 243ac8942e1e0136b8d91242642d9bc825a9cfd9 (patch) | |
tree | 15a354159162a566251383913cee329be0c1d1f5 /test/lit/help/optimization-opts.test | |
parent | 4ba4d31eafb723a28503faffae1702940b6926ca (diff) | |
download | binaryen-243ac8942e1e0136b8d91242642d9bc825a9cfd9.tar.gz binaryen-243ac8942e1e0136b8d91242642d9bc825a9cfd9.tar.bz2 binaryen-243ac8942e1e0136b8d91242642d9bc825a9cfd9.zip |
[Wasm GC] Constant Field Propagation (#4052)
A field in a struct is constant if we can see that in the entire program we
only ever write the same constant value to it. For example, imagine a
vtable type that we construct with the same funcrefs each time, then (if
we have no struct.sets, or if we did, and they had the same value), we
could replace a get with that constant value, since it cannot be anything
else:
(struct.new $T (i32.const 10) (rtt))
..no other conflicting values..
(struct.get $T 0) => (i32.const 10)
If the value is a function reference, then this may allow other passes
to turn what was a call_ref into a direct call and perhaps also get
inlined, effectively a form of devirtualization.
This only works in nominal typing, as we need to know the supertype
of each type. (It could work in theory in structural, but we'd need to do
hard work to find all the possible supertypes, and it would also
become far less effective.)
This deletes a trivial test for running -O on GC content. We have
many more tests for GC at this point, so that test is not needed, and
this PR also optimizes the code into something trivial and
uninteresting anyhow.
Diffstat (limited to 'test/lit/help/optimization-opts.test')
-rw-r--r-- | test/lit/help/optimization-opts.test | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/test/lit/help/optimization-opts.test b/test/lit/help/optimization-opts.test index c6d45332d..d189c6398 100644 --- a/test/lit/help/optimization-opts.test +++ b/test/lit/help/optimization-opts.test @@ -182,6 +182,9 @@ ;; CHECK-NEXT: --avoid-reinterprets Tries to avoid reinterpret ;; CHECK-NEXT: operations via more loads ;; CHECK-NEXT: +;; CHECK-NEXT: --cfp propagate constant struct field +;; CHECK-NEXT: values +;; CHECK-NEXT: ;; CHECK-NEXT: --coalesce-locals reduce # of locals by coalescing ;; CHECK-NEXT: ;; CHECK-NEXT: --coalesce-locals-learning reduce # of locals by coalescing |