blob: ed8951e8f14c490003789861305d318823cd4b3e [file] [log] [blame] [edit]
;; 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 (sub (struct)))
(type $A (sub (struct)))
;; CHECK: (global $a (mut i32) (i32.const 0))
(global $a (mut i32) (i32.const 0))
;; CHECK: (func $best (type $1) (param $x (ref struct))
;; CHECK-NEXT: (local $1 (ref $A))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (local.tee $1
;; CHECK-NEXT: (ref.cast (ref $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 (ref $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 (ref $A)
(local.get $x)
)
)
)
)