summaryrefslogtreecommitdiff
path: root/test/lit/passes/optimize-instructions-nontrapping-float-to-int.wast
blob: d3e759e1c0071dfc125c3ae58f45aa8ba5724fc8 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
;; RUN: wasm-opt %s --optimize-instructions --enable-nontrapping-float-to-int -S -o - | filecheck %s

(module
  (memory 0)

  ;; CHECK:      (func $simplify_int_float_sat_conversion_roundtrips (param $x i32) (param $y i64)
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (local.get $x)
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (local.get $x)
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (i32.trunc_sat_f64_s
  ;; CHECK-NEXT:    (f64.convert_i32_u
  ;; CHECK-NEXT:     (local.get $x)
  ;; CHECK-NEXT:    )
  ;; CHECK-NEXT:   )
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (i32.trunc_sat_f64_u
  ;; CHECK-NEXT:    (f64.convert_i32_s
  ;; CHECK-NEXT:     (local.get $x)
  ;; CHECK-NEXT:    )
  ;; CHECK-NEXT:   )
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (i32.trunc_sat_f32_u
  ;; CHECK-NEXT:    (f32.convert_i32_u
  ;; CHECK-NEXT:     (local.get $x)
  ;; CHECK-NEXT:    )
  ;; CHECK-NEXT:   )
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (i32.trunc_sat_f64_u
  ;; CHECK-NEXT:    (f64.convert_i64_u
  ;; CHECK-NEXT:     (local.get $y)
  ;; CHECK-NEXT:    )
  ;; CHECK-NEXT:   )
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (i64.trunc_sat_f64_s
  ;; CHECK-NEXT:    (f64.convert_i64_s
  ;; CHECK-NEXT:     (local.get $y)
  ;; CHECK-NEXT:    )
  ;; CHECK-NEXT:   )
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (i64.trunc_sat_f32_u
  ;; CHECK-NEXT:    (f32.convert_i32_s
  ;; CHECK-NEXT:     (local.get $x)
  ;; CHECK-NEXT:    )
  ;; CHECK-NEXT:   )
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (i64.trunc_sat_f32_s
  ;; CHECK-NEXT:    (f32.convert_i64_s
  ;; CHECK-NEXT:     (local.get $y)
  ;; CHECK-NEXT:    )
  ;; CHECK-NEXT:   )
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT: )
  (func $simplify_int_float_sat_conversion_roundtrips (param $x i32) (param $y i64)
    (drop (i32.trunc_sat_f64_u (f64.convert_i32_u (local.get $x))))
    (drop (i32.trunc_sat_f64_s (f64.convert_i32_s (local.get $x))))

    ;; skips
    (drop (i32.trunc_sat_f64_s (f64.convert_i32_u (local.get $x))))
    (drop (i32.trunc_sat_f64_u (f64.convert_i32_s (local.get $x))))
    (drop (i32.trunc_sat_f32_u (f32.convert_i32_u (local.get $x))))
    (drop (i32.trunc_sat_f64_u (f64.convert_i64_u (local.get $y))))
    (drop (i64.trunc_sat_f64_s (f64.convert_i64_s (local.get $y))))
    (drop (i64.trunc_sat_f32_u (f32.convert_i32_s (local.get $x))))
    (drop (i64.trunc_sat_f32_s (f32.convert_i64_s (local.get $y))))
  )
)