summaryrefslogtreecommitdiff
path: root/test/lit/help/wasm2js.test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-06-27 15:34:07 -0700
committerGitHub <noreply@github.com>2024-06-27 15:34:07 -0700
commitcdf8139a441c27c16eff02ccee65c463500fc00f (patch)
tree478313c6b1b1d41df76421fd7f52cfe3d76f04f7 /test/lit/help/wasm2js.test
parent53712b6d6e93449a6faf18a55e0fb29022f158df (diff)
downloadbinaryen-cdf8139a441c27c16eff02ccee65c463500fc00f.tar.gz
binaryen-cdf8139a441c27c16eff02ccee65c463500fc00f.tar.bz2
binaryen-cdf8139a441c27c16eff02ccee65c463500fc00f.zip
ConstantFieldPropagation: Add a variation that picks between 2 values using RefTest (#6692)
CFP focuses on finding when a field always contains a constant, and then replaces a struct.get with that constant. If we find there are two constant values, then in some cases we can still optimize, if we have a way to pick between them. All we have is the struct.get and its reference, so we must use a ref.test: (struct.get $T x (..ref..)) => (select (..constant1..) (..constant2..) (ref.test $U (..ref..)) ) This is valid if, of all the subtypes of $T, those that pass the test have constant1 in that field, and those that fail the test have constant2. For example, a simple case is where $T has two subtypes, $T is never created itself, and each of the two subtypes has a different constant value. This is a somewhat risky operation, as ref.test is not necessarily cheap. To mitigate that, this is a new pass, --cfp-reftest that is not run by default, and also we only optimize when we can use a ref.test on what we think will be a final type (because ref.test on a final type can be faster in VMs).
Diffstat (limited to 'test/lit/help/wasm2js.test')
-rw-r--r--test/lit/help/wasm2js.test3
1 files changed, 3 insertions, 0 deletions
diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test
index 3c1da7ff2..8e305cfb9 100644
--- a/test/lit/help/wasm2js.test
+++ b/test/lit/help/wasm2js.test
@@ -57,6 +57,9 @@
;; CHECK-NEXT: --cfp propagate constant struct field
;; CHECK-NEXT: values
;; CHECK-NEXT:
+;; CHECK-NEXT: --cfp-reftest propagate constant struct field
+;; CHECK-NEXT: values, using ref.test
+;; CHECK-NEXT:
;; CHECK-NEXT: --coalesce-locals reduce # of locals by coalescing
;; CHECK-NEXT:
;; CHECK-NEXT: --coalesce-locals-learning reduce # of locals by coalescing