diff options
Diffstat (limited to 'test/lit/passes/optimize-instructions-gc-tnh.wast')
-rw-r--r-- | test/lit/passes/optimize-instructions-gc-tnh.wast | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/test/lit/passes/optimize-instructions-gc-tnh.wast b/test/lit/passes/optimize-instructions-gc-tnh.wast index 155ac82cf..4d7ed0c48 100644 --- a/test/lit/passes/optimize-instructions-gc-tnh.wast +++ b/test/lit/passes/optimize-instructions-gc-tnh.wast @@ -23,10 +23,10 @@ ;; TNH-NEXT: ) ;; NO_TNH: (func $ref.eq (type $eqref_eqref_=>_i32) (param $a eqref) (param $b eqref) (result i32) ;; NO_TNH-NEXT: (ref.eq - ;; NO_TNH-NEXT: (ref.cast $struct + ;; NO_TNH-NEXT: (ref.cast (ref $struct) ;; NO_TNH-NEXT: (local.get $a) ;; NO_TNH-NEXT: ) - ;; NO_TNH-NEXT: (ref.cast struct + ;; NO_TNH-NEXT: (ref.cast (ref struct) ;; NO_TNH-NEXT: (local.get $b) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -37,16 +37,16 @@ (ref.eq ;; When traps can happen we can still improve this by removing and ;; combining redundant casts. - (ref.cast struct + (ref.cast (ref struct) (ref.as_non_null - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $a) ) ) ) ;; Note that we can remove the non-null casts here in both modes, as the ;; ref.cast struct also checks for null. - (ref.cast struct + (ref.cast (ref struct) (ref.as_non_null (ref.as_non_null (local.get $b) @@ -64,10 +64,10 @@ ;; NO_TNH: (func $ref.eq-no (type $eqref_eqref_anyref_=>_none) (param $a eqref) (param $b eqref) (param $any anyref) ;; NO_TNH-NEXT: (drop ;; NO_TNH-NEXT: (ref.eq - ;; NO_TNH-NEXT: (ref.cast null $struct + ;; NO_TNH-NEXT: (ref.cast (ref null $struct) ;; NO_TNH-NEXT: (local.get $any) ;; NO_TNH-NEXT: ) - ;; NO_TNH-NEXT: (ref.cast struct + ;; NO_TNH-NEXT: (ref.cast (ref struct) ;; NO_TNH-NEXT: (local.get $any) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -77,11 +77,11 @@ ;; We must leave the inputs to ref.eq of type eqref or a subtype. (drop (ref.eq - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $any) ;; *Not* an eqref! ) (ref.as_non_null - (ref.cast struct + (ref.cast (ref struct) (ref.as_non_null (local.get $any) ;; *Not* an eqref! ) @@ -93,7 +93,7 @@ ;; TNH: (func $ref.is (type $eqref_=>_i32) (param $a eqref) (result i32) ;; TNH-NEXT: (drop - ;; TNH-NEXT: (ref.cast $struct + ;; TNH-NEXT: (ref.cast (ref $struct) ;; TNH-NEXT: (local.get $a) ;; TNH-NEXT: ) ;; TNH-NEXT: ) @@ -101,7 +101,7 @@ ;; TNH-NEXT: ) ;; NO_TNH: (func $ref.is (type $eqref_=>_i32) (param $a eqref) (result i32) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $struct + ;; NO_TNH-NEXT: (ref.cast (ref $struct) ;; NO_TNH-NEXT: (local.get $a) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -111,9 +111,9 @@ ;; In this case non-nullability is enough to tell that the ref.is will ;; return 0. TNH does not help here. (ref.is_null - (ref.cast $struct + (ref.cast (ref $struct) (ref.as_non_null - (ref.cast struct + (ref.cast (ref struct) (local.get $a) ) ) @@ -134,13 +134,13 @@ ;; NO_TNH: (func $ref.is_b (type $eqref_funcref_=>_i32) (param $a eqref) (param $f funcref) (result i32) ;; NO_TNH-NEXT: (drop ;; NO_TNH-NEXT: (ref.is_null - ;; NO_TNH-NEXT: (ref.cast null $struct + ;; NO_TNH-NEXT: (ref.cast (ref null $struct) ;; NO_TNH-NEXT: (local.get $a) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (ref.is_null - ;; NO_TNH-NEXT: (ref.cast null $void + ;; NO_TNH-NEXT: (ref.cast (ref null $void) ;; NO_TNH-NEXT: (local.get $f) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -151,14 +151,14 @@ ;; remove the cast in TNH. (drop (ref.is_null - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $a) ) ) ) ;; It works on func references, too. (ref.is_null - (ref.cast null $void + (ref.cast (ref null $void) (local.get $f) ) ) @@ -168,7 +168,7 @@ ;; TNH-NEXT: (drop ;; TNH-NEXT: (block (result i32) ;; TNH-NEXT: (drop - ;; TNH-NEXT: (ref.cast null i31 + ;; TNH-NEXT: (ref.cast i31ref ;; TNH-NEXT: (local.get $a) ;; TNH-NEXT: ) ;; TNH-NEXT: ) @@ -188,7 +188,7 @@ ;; NO_TNH-NEXT: (drop ;; NO_TNH-NEXT: (block (result i32) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast null i31 + ;; NO_TNH-NEXT: (ref.cast i31ref ;; NO_TNH-NEXT: (local.get $a) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -206,14 +206,14 @@ ;; NO_TNH-NEXT: ) (func $ref.test (param $a eqref) (result i32) (drop - (ref.test null i31 - (ref.cast null i31 + (ref.test i31ref + (ref.cast i31ref (local.get $a) ) ) ) - (ref.test eq - (ref.cast eq + (ref.test (ref eq) + (ref.cast (ref eq) (local.get $a) ) ) @@ -559,19 +559,19 @@ ;; TNH: (func $set-get-cast (type $structref_=>_none) (param $ref structref) ;; TNH-NEXT: (drop ;; TNH-NEXT: (struct.get $struct 0 - ;; TNH-NEXT: (ref.cast $struct + ;; TNH-NEXT: (ref.cast (ref $struct) ;; TNH-NEXT: (local.get $ref) ;; TNH-NEXT: ) ;; TNH-NEXT: ) ;; TNH-NEXT: ) ;; TNH-NEXT: (struct.set $struct 0 - ;; TNH-NEXT: (ref.cast $struct + ;; TNH-NEXT: (ref.cast (ref $struct) ;; TNH-NEXT: (local.get $ref) ;; TNH-NEXT: ) ;; TNH-NEXT: (i32.const 1) ;; TNH-NEXT: ) ;; TNH-NEXT: (struct.set $struct 0 - ;; TNH-NEXT: (ref.cast null $struct + ;; TNH-NEXT: (ref.cast (ref null $struct) ;; TNH-NEXT: (local.get $ref) ;; TNH-NEXT: ) ;; TNH-NEXT: (block (result i32) @@ -583,19 +583,19 @@ ;; NO_TNH: (func $set-get-cast (type $structref_=>_none) (param $ref structref) ;; NO_TNH-NEXT: (drop ;; NO_TNH-NEXT: (struct.get $struct 0 - ;; NO_TNH-NEXT: (ref.cast $struct + ;; NO_TNH-NEXT: (ref.cast (ref $struct) ;; NO_TNH-NEXT: (local.get $ref) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (struct.set $struct 0 - ;; NO_TNH-NEXT: (ref.cast null $struct + ;; NO_TNH-NEXT: (ref.cast (ref null $struct) ;; NO_TNH-NEXT: (local.get $ref) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (i32.const 1) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (struct.set $struct 0 - ;; NO_TNH-NEXT: (ref.cast null $struct + ;; NO_TNH-NEXT: (ref.cast (ref null $struct) ;; NO_TNH-NEXT: (local.get $ref) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (block (result i32) @@ -609,7 +609,7 @@ ;; non-nullable cast. (drop (struct.get $struct 0 - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $ref) ) ) @@ -618,7 +618,7 @@ ;; TODO handle non-TNH as well, but we need to be careful of effects in ;; other children. (struct.set $struct 0 - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $ref) ) (i32.const 1) @@ -627,7 +627,7 @@ ;; prevents us from optimizing - if the parent is not necessarily reached, ;; we cannot infer the child won't trap. (struct.set $struct 0 - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $ref) ) (block (result i32) @@ -665,7 +665,7 @@ ;; We can remove the unreachable arm of the if here in TNH mode. While doing ;; so we must refinalize properly or else we'll hit an error in pass-debug ;; mode. - (ref.cast $struct + (ref.cast (ref $struct) (if (result (ref none)) (i32.const 1) (unreachable) @@ -697,7 +697,7 @@ ;; NO_TNH-NEXT: ) (func $cast-if-null-flip (param $x (ref none)) (result (ref $struct)) ;; As above but with arms flipped. - (ref.cast $struct + (ref.cast (ref $struct) (if (result (ref none)) (i32.const 1) (local.get $x) @@ -766,7 +766,7 @@ ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast null none + ;; NO_TNH-NEXT: (ref.cast nullref ;; NO_TNH-NEXT: (local.get $nullable-ref) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -775,19 +775,19 @@ ;; Non-nullable casts to none must trap (regardless of whether the input is ;; nullable or not, the output is an impossible type). (drop - (ref.cast none + (ref.cast (ref none) (local.get $ref) ) ) (drop - (ref.cast none + (ref.cast (ref none) (local.get $nullable-ref) ) ) ;; Nullable casts to null have more possibilities. First, if the input is ;; non-nullable then we trap. (drop - (ref.cast null none + (ref.cast nullref (local.get $ref) ) ) @@ -796,7 +796,7 @@ ;; return a null here. (In non-TNH mode we could do a check for null etc., ;; but we'd be increasing code size.) (drop - (ref.cast null none + (ref.cast nullref (local.get $nullable-ref) ) ) @@ -892,7 +892,7 @@ ;; then process the select. While doing so we must not error, as the select ;; itself will still have a reachable type (a full refinalize only ;; happens at the very end of the function). - (ref.cast $struct + (ref.cast (ref $struct) (select (result (ref $struct)) (ref.as_non_null (ref.null none) @@ -919,7 +919,7 @@ ;; NO_TNH-NEXT: ) (func $select.unreachable.child.flip (param $x (ref $struct)) (result (ref $struct)) ;; Flip case of the above. - (ref.cast $struct + (ref.cast (ref $struct) (select (result (ref $struct)) (local.get $x) (ref.as_non_null @@ -965,7 +965,7 @@ ;; the false arm (that would trap, and change the behavior; tnh can remove ;; traps, not add them). (drop - (ref.cast func + (ref.cast (ref func) (if (result (ref nofunc)) (i32.const 1) (block (result (ref nofunc)) |