summaryrefslogtreecommitdiff
path: root/test/lit/passes/simplify-globals-prefer_earlier.wast
blob: 4d8b17abb2e96ef66ce5cac80ba0e1ef88ca6630 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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)
    )
  )
)