summaryrefslogtreecommitdiff
path: root/test/lit/passes/O3_Oz.wast
blob: cc129c964ce8457f188e74b28e145ff9720d4579 (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
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.

;; RUN: foreach %s %t wasm-opt -O3 -Oz -S -o - | filecheck %s

(module
  (func $inline.me (param $x i32) (result i32)
    (i32.add
      (local.get $x)
      (i32.const 2)
    )
  )

  ;; CHECK:      (type $0 (func (param i32) (result i32)))

  ;; CHECK:      (export "export" (func $export))

  ;; CHECK:      (func $export (param $0 i32) (result i32)
  ;; CHECK-NEXT:  (i32.add
  ;; CHECK-NEXT:   (local.tee $0
  ;; CHECK-NEXT:    (i32.add
  ;; CHECK-NEXT:     (local.get $0)
  ;; CHECK-NEXT:     (i32.const 2)
  ;; CHECK-NEXT:    )
  ;; CHECK-NEXT:   )
  ;; CHECK-NEXT:   (local.get $0)
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT: )
  (func $export (export "export") (param $x i32) (result i32)
    ;; $inline.me is called twice, so we do not always inline it like called-
    ;; once functions are. -Oz is too cautious to inline such things that may
    ;; end up increasing total code size, but we are running -O3 -Oz here and so
    ;; the first -O3 will inline there. That is, this test verifies that the
    ;; later -Oz does not affect the earlier -O3 (which it could, if -Oz set
    ;; global state that -O3 then reads to see the optimization and shrink
    ;; levels).
    (i32.add
      (call $inline.me
        (local.get $x)
      )
      (call $inline.me
        (local.get $x)
      )
    )
  )
)