diff options
Diffstat (limited to 'test/lit/passes/optimize-instructions-gc-extern.wast')
-rw-r--r-- | test/lit/passes/optimize-instructions-gc-extern.wast | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/test/lit/passes/optimize-instructions-gc-extern.wast b/test/lit/passes/optimize-instructions-gc-extern.wast index 658b2b115..067efb0ec 100644 --- a/test/lit/passes/optimize-instructions-gc-extern.wast +++ b/test/lit/passes/optimize-instructions-gc-extern.wast @@ -3,6 +3,9 @@ ;; RUN: | filecheck %s (module + ;; CHECK: (type $array (array (mut i8))) + (type $array (array (mut i8))) + ;; CHECK: (func $extern.convert_any (type $0) (param $x anyref) (param $y externref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (extern.convert_any @@ -10,8 +13,8 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (extern.convert_any - ;; CHECK-NEXT: (ref.as_non_null + ;; CHECK-NEXT: (ref.as_non_null + ;; CHECK-NEXT: (extern.convert_any ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -22,20 +25,22 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (any.convert_extern - ;; CHECK-NEXT: (ref.as_non_null + ;; CHECK-NEXT: (ref.as_non_null + ;; CHECK-NEXT: (any.convert_extern ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $extern.convert_any (export "ext") (param $x (ref null any)) (param $y (ref null extern)) + (func $extern.convert_any (param $x (ref null any)) (param $y (ref null extern)) ;; We should not change anything here, and also not hit an internal error. (drop (extern.convert_any (local.get $x) ) ) + ;; We can reorder the externalize with the ref.as_non_null, which sometimes + ;; helps later optimizations, see below. (drop (extern.convert_any (ref.as_non_null @@ -43,6 +48,7 @@ ) ) ) + ;; As the above two cases, but for internalize. (drop (any.convert_extern (local.get $y) @@ -56,4 +62,27 @@ ) ) ) + + ;; CHECK: (func $convert.optimize.parent (type $1) (param $ext externref) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (ref.cast (ref $array) + ;; CHECK-NEXT: (any.convert_extern + ;; CHECK-NEXT: (local.get $ext) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $convert.optimize.parent (param $ext externref) + ;; The ref.cast can fold in the ref.as_non_null, after it is moved + ;; outside of the any.convert_extern. + (drop + (ref.cast (ref null $array) + (any.convert_extern + (ref.as_non_null + (local.get $ext) + ) + ) + ) + ) + ) ) |