diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/simplify-globals-dominance.wast | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/lit/passes/simplify-globals-dominance.wast b/test/lit/passes/simplify-globals-dominance.wast new file mode 100644 index 000000000..948e8c5ec --- /dev/null +++ b/test/lit/passes/simplify-globals-dominance.wast @@ -0,0 +1,55 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. + +;; RUN: foreach %s %t wasm-opt --simplify-globals -all -S -o - | filecheck %s + +(module + ;; CHECK: (type $none_=>_none (func)) + + ;; CHECK: (global $global (mut i32) (i32.const 0)) + (global $global (mut i32) (i32.const 0)) + + ;; CHECK: (func $test (type $none_=>_none) + ;; CHECK-NEXT: (global.set $global + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $test) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (global.get $global) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (global.get $global) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $test + (global.set $global + (i32.const 10) + ) + (if + (i32.const 0) + (block + ;; This is dominated by the set, so we can apply 10 here. + (drop + (global.get $global) + ) + (call $test) + ;; This is after a call, so we do nothing (we are still dominated by the + ;; global.set, but the call might set the global to another value). + (drop + (global.get $global) + ) + ) + ;; This is dominated by the set, but we do not optimize it yet. TODO + (drop + (global.get $global) + ) + ) + ) +) |