diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/simplify-globals-prefer_earlier.wast | 53 | ||||
-rw-r--r-- | test/passes/simplify-globals-optimizing_all-features.txt | 4 | ||||
-rw-r--r-- | test/passes/simplify-globals_all-features.txt | 4 |
3 files changed, 57 insertions, 4 deletions
diff --git a/test/lit/passes/simplify-globals-prefer_earlier.wast b/test/lit/passes/simplify-globals-prefer_earlier.wast new file mode 100644 index 000000000..4d8b17abb --- /dev/null +++ b/test/lit/passes/simplify-globals-prefer_earlier.wast @@ -0,0 +1,53 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; NOTE: This test was ported using port_passes_tests_to_lit.py and could be cleaned up. + +;; RUN: foreach %s %t wasm-opt -all --simplify-globals -S -o - | filecheck %s + +;; When a global is copied into another, prefer the earlier one in later gets. +;; +;; The global.gets in the definitions of $global2,3,4 should all point to +;; $global1, as should the gets in the function below. +(module + ;; CHECK: (type $0 (func)) + + ;; CHECK: (import "a" "b" (global $global1 i32)) + (import "a" "b" (global $global1 i32)) + + ;; CHECK: (global $global2 i32 (global.get $global1)) + (global $global2 i32 (global.get $global1)) + + ;; CHECK: (global $global3 i32 (global.get $global1)) + (global $global3 i32 (global.get $global2)) + + ;; CHECK: (global $global4 i32 (global.get $global1)) + (global $global4 i32 (global.get $global3)) + + ;; CHECK: (func $simple (type $0) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (global.get $global1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (global.get $global1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (global.get $global1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (global.get $global1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $simple + (drop + (global.get $global1) + ) + (drop + (global.get $global2) + ) + (drop + (global.get $global3) + ) + (drop + (global.get $global4) + ) + ) +) diff --git a/test/passes/simplify-globals-optimizing_all-features.txt b/test/passes/simplify-globals-optimizing_all-features.txt index 1ffd2a2b3..72c0620a6 100644 --- a/test/passes/simplify-globals-optimizing_all-features.txt +++ b/test/passes/simplify-globals-optimizing_all-features.txt @@ -15,8 +15,8 @@ (type $0 (func)) (import "env" "global-1" (global $g1 i32)) (global $g2 i32 (global.get $g1)) - (global $g3 i32 (global.get $g2)) - (global $g4 i32 (global.get $g3)) + (global $g3 i32 (global.get $g1)) + (global $g4 i32 (global.get $g1)) (func $foo (type $0) (drop (global.get $g1) diff --git a/test/passes/simplify-globals_all-features.txt b/test/passes/simplify-globals_all-features.txt index 3273148e1..e885b3cfe 100644 --- a/test/passes/simplify-globals_all-features.txt +++ b/test/passes/simplify-globals_all-features.txt @@ -15,8 +15,8 @@ (type $0 (func)) (import "env" "global-1" (global $g1 i32)) (global $g2 i32 (global.get $g1)) - (global $g3 i32 (global.get $g2)) - (global $g4 i32 (global.get $g3)) + (global $g3 i32 (global.get $g1)) + (global $g4 i32 (global.get $g1)) (func $foo (type $0) (drop (global.get $g1) |