diff options
author | Alon Zakai <azakai@google.com> | 2023-02-03 08:02:10 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-03 08:02:10 -0800 |
commit | f8261babf4c3b69c9339ddbd4d2b0318062833a8 (patch) | |
tree | cabe0526b882c7bc1de09b1fc1897536cb016a3f /test | |
parent | 6a2ec34a24f0dba63b851e800cc88653c1c74c9b (diff) | |
download | binaryen-f8261babf4c3b69c9339ddbd4d2b0318062833a8.tar.gz binaryen-f8261babf4c3b69c9339ddbd4d2b0318062833a8.tar.bz2 binaryen-f8261babf4c3b69c9339ddbd4d2b0318062833a8.zip |
Optimize ref.as_non_null removal effect computation (#5479)
Followup to #5474
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/optimize-instructions-gc-tnh.wast | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/lit/passes/optimize-instructions-gc-tnh.wast b/test/lit/passes/optimize-instructions-gc-tnh.wast index 87795f31d..b7ddc2357 100644 --- a/test/lit/passes/optimize-instructions-gc-tnh.wast +++ b/test/lit/passes/optimize-instructions-gc-tnh.wast @@ -608,6 +608,7 @@ ) ;; TNH: (func $null.cast-other.effects (type $ref?|$struct|_=>_none) (param $x (ref null $struct)) + ;; TNH-NEXT: (local $i i32) ;; TNH-NEXT: (struct.set $struct 0 ;; TNH-NEXT: (local.get $x) ;; TNH-NEXT: (call $import) @@ -616,8 +617,15 @@ ;; TNH-NEXT: (local.get $x) ;; TNH-NEXT: (i32.const 10) ;; TNH-NEXT: ) + ;; TNH-NEXT: (struct.set $struct 0 + ;; TNH-NEXT: (local.get $x) + ;; TNH-NEXT: (local.tee $i + ;; TNH-NEXT: (i32.const 10) + ;; TNH-NEXT: ) + ;; TNH-NEXT: ) ;; TNH-NEXT: ) ;; NO_TNH: (func $null.cast-other.effects (type $ref?|$struct|_=>_none) (param $x (ref null $struct)) + ;; NO_TNH-NEXT: (local $i i32) ;; NO_TNH-NEXT: (struct.set $struct 0 ;; NO_TNH-NEXT: (ref.as_non_null ;; NO_TNH-NEXT: (local.get $x) @@ -628,8 +636,15 @@ ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: (i32.const 10) ;; NO_TNH-NEXT: ) + ;; NO_TNH-NEXT: (struct.set $struct 0 + ;; NO_TNH-NEXT: (local.get $x) + ;; NO_TNH-NEXT: (local.tee $i + ;; NO_TNH-NEXT: (i32.const 10) + ;; NO_TNH-NEXT: ) + ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) (func $null.cast-other.effects (param $x (ref null $struct)) + (local $i i32) (struct.set $struct 0 ;; We cannot remove this ref.as_non_null, even though the struct.set will ;; trap if the ref is null, because that would move the trap from before @@ -648,6 +663,17 @@ ) (i32.const 10) ) + (struct.set $struct 0 + ;; This one can be removed even without TNH, even though there are effects + ;; in it. A tee only has local effects, which do not interfere with a + ;; trap. + (ref.as_non_null + (local.get $x) + ) + (local.tee $i + (i32.const 10) + ) + ) ) ;; Helper functions. |