summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-07-08 16:16:15 -0700
committerGitHub <noreply@github.com>2022-07-08 16:16:15 -0700
commit44fa122bec913d66bc3ce1271bf4f63f6d5d31f2 (patch)
tree51afad3b7166a5acee0ee21a99818fd72a2657a2 /test
parent83f48ed96357cdde61d898ca05f201d38e6d4222 (diff)
downloadbinaryen-44fa122bec913d66bc3ce1271bf4f63f6d5d31f2.tar.gz
binaryen-44fa122bec913d66bc3ce1271bf4f63f6d5d31f2.tar.bz2
binaryen-44fa122bec913d66bc3ce1271bf4f63f6d5d31f2.zip
[Wasm GC] RefIs / RefEq / RefTest return a boolean (#4786)
This marks all reference operations that return 0/1 as doing so. This allows various bitwise operations to be optimized on them. This also marks StringEq as a boolean, though we can't test that fully yet as Strings support is wip (no interpreter or other stuff yet). As a driveby this moves emitsBoolean to its own file, and uses it in getMaxBits to avoid redundancy (the redundant code paths now have a WASM_UNREACHABLE).
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/optimize-instructions-gc.wast66
1 files changed, 66 insertions, 0 deletions
diff --git a/test/lit/passes/optimize-instructions-gc.wast b/test/lit/passes/optimize-instructions-gc.wast
index 2c6498ec3..643aad5ed 100644
--- a/test/lit/passes/optimize-instructions-gc.wast
+++ b/test/lit/passes/optimize-instructions-gc.wast
@@ -2876,4 +2876,70 @@
)
)
)
+
+ ;; CHECK: (func $ref-boolean (param $x eqref) (param $y eqref)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (ref.eq
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: (local.get $y)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (ref.is_func
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (ref.test_static $A
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; NOMNL: (func $ref-boolean (type $eqref_eqref_=>_none) (param $x eqref) (param $y eqref)
+ ;; NOMNL-NEXT: (drop
+ ;; NOMNL-NEXT: (ref.eq
+ ;; NOMNL-NEXT: (local.get $x)
+ ;; NOMNL-NEXT: (local.get $y)
+ ;; NOMNL-NEXT: )
+ ;; NOMNL-NEXT: )
+ ;; NOMNL-NEXT: (drop
+ ;; NOMNL-NEXT: (ref.is_func
+ ;; NOMNL-NEXT: (local.get $x)
+ ;; NOMNL-NEXT: )
+ ;; NOMNL-NEXT: )
+ ;; NOMNL-NEXT: (drop
+ ;; NOMNL-NEXT: (ref.test_static $A
+ ;; NOMNL-NEXT: (local.get $x)
+ ;; NOMNL-NEXT: )
+ ;; NOMNL-NEXT: )
+ ;; NOMNL-NEXT: )
+ (func $ref-boolean (param $x eqref) (param $y eqref)
+ ;; ref.eq returns a boolean, so &1 on it is not needed.
+ (drop
+ (i32.and
+ (ref.eq
+ (local.get $x)
+ (local.get $y)
+ )
+ (i32.const 1)
+ )
+ )
+ ;; likewise ref.is and ref.test
+ (drop
+ (i32.and
+ (ref.is_func
+ (local.get $x)
+ )
+ (i32.const 1)
+ )
+ )
+ (drop
+ (i32.and
+ (ref.test_static $A
+ (local.get $x)
+ )
+ (i32.const 1)
+ )
+ )
+ )
)