diff options
Diffstat (limited to 'test/lit/passes/optimize-casts-tnh.wast')
-rw-r--r-- | test/lit/passes/optimize-casts-tnh.wast | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/lit/passes/optimize-casts-tnh.wast b/test/lit/passes/optimize-casts-tnh.wast new file mode 100644 index 000000000..ced59bd0c --- /dev/null +++ b/test/lit/passes/optimize-casts-tnh.wast @@ -0,0 +1,45 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. +;; RUN: wasm-opt %s --optimize-casts -all -tnh -S -o - | filecheck %s + +(module + ;; CHECK: (type $A (struct )) + (type $A (struct_subtype data)) + + ;; CHECK: (global $a (mut i32) (i32.const 0)) + (global $a (mut i32) (i32.const 0)) + + ;; CHECK: (func $best (type $ref|struct|_=>_none) (param $x (ref struct)) + ;; CHECK-NEXT: (local $1 (ref $A)) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.tee $1 + ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (global.set $a + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $best (param $x (ref struct)) + (drop + (local.get $x) + ) + ;; global.sets normally prevent casts from being moved before them, but + ;; if traps are assumed to never happen then we can still optimize. + (global.set $a + (i32.const 10) + ) + (drop + (ref.cast $A + (local.get $x) + ) + ) + ) +) + |