summaryrefslogtreecommitdiff
path: root/test/lit/passes/denan-simd.wast
blob: 6508b36eb4b6187710bdea211233e950463f6c7e (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.

;; RUN: foreach %s %t wasm-opt --denan -all -S -o - | filecheck %s

(module
  ;; CHECK:      (type $0 (func (param v128) (result v128)))

  ;; CHECK:      (type $1 (func (param f32) (result f32)))

  ;; CHECK:      (type $2 (func (param f64) (result f64)))

  ;; CHECK:      (func $foo128 (type $0) (param $x v128) (result v128)
  ;; CHECK-NEXT:  (local.set $x
  ;; CHECK-NEXT:   (call $deNan128
  ;; CHECK-NEXT:    (local.get $x)
  ;; CHECK-NEXT:   )
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (v128.const i32x4 0x00000001 0x00000002 0x00000003 0x00000004)
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000)
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (drop
  ;; CHECK-NEXT:   (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000)
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT:  (call $deNan128
  ;; CHECK-NEXT:   (call $foo128
  ;; CHECK-NEXT:    (local.get $x)
  ;; CHECK-NEXT:   )
  ;; CHECK-NEXT:  )
  ;; CHECK-NEXT: )
  (func $foo128 (param $x v128) (result v128)
    ;; The incoming param will be de-naned.

    ;; This is not a NaN.
    (drop
      (v128.const i32x4 0x00000001 0x00000002 0x00000003 0x00000004)
    )
    ;; This is an f64 NaN and also an f32. It will become 0's.
    (drop
      (v128.const i32x4 0xffffffff 0x00000002 0x00000003 0x00000004)
    )
    ;; This is an f32 NaN and not an f64. It will also become 0's.
    (drop
      (v128.const i32x4 0x00000001 0xffffffff 0x00000003 0x00000004)
    )

    ;; The result here will be de-naned.
    (call $foo128 (local.get $x))
  )
)
;; CHECK:      (func $deNan32 (type $1) (param $0 f32) (result f32)
;; CHECK-NEXT:  (if (result f32)
;; CHECK-NEXT:   (f32.eq
;; CHECK-NEXT:    (local.get $0)
;; CHECK-NEXT:    (local.get $0)
;; CHECK-NEXT:   )
;; CHECK-NEXT:   (then
;; CHECK-NEXT:    (local.get $0)
;; CHECK-NEXT:   )
;; CHECK-NEXT:   (else
;; CHECK-NEXT:    (f32.const 0)
;; CHECK-NEXT:   )
;; CHECK-NEXT:  )
;; CHECK-NEXT: )

;; CHECK:      (func $deNan64 (type $2) (param $0 f64) (result f64)
;; CHECK-NEXT:  (if (result f64)
;; CHECK-NEXT:   (f64.eq
;; CHECK-NEXT:    (local.get $0)
;; CHECK-NEXT:    (local.get $0)
;; CHECK-NEXT:   )
;; CHECK-NEXT:   (then
;; CHECK-NEXT:    (local.get $0)
;; CHECK-NEXT:   )
;; CHECK-NEXT:   (else
;; CHECK-NEXT:    (f64.const 0)
;; CHECK-NEXT:   )
;; CHECK-NEXT:  )
;; CHECK-NEXT: )

;; CHECK:      (func $deNan128 (type $0) (param $0 v128) (result v128)
;; CHECK-NEXT:  (if (result v128)
;; CHECK-NEXT:   (i32.and
;; CHECK-NEXT:    (i32.and
;; CHECK-NEXT:     (f32.eq
;; CHECK-NEXT:      (f32x4.extract_lane 0
;; CHECK-NEXT:       (local.get $0)
;; CHECK-NEXT:      )
;; CHECK-NEXT:      (f32x4.extract_lane 0
;; CHECK-NEXT:       (local.get $0)
;; CHECK-NEXT:      )
;; CHECK-NEXT:     )
;; CHECK-NEXT:     (f32.eq
;; CHECK-NEXT:      (f32x4.extract_lane 1
;; CHECK-NEXT:       (local.get $0)
;; CHECK-NEXT:      )
;; CHECK-NEXT:      (f32x4.extract_lane 1
;; CHECK-NEXT:       (local.get $0)
;; CHECK-NEXT:      )
;; CHECK-NEXT:     )
;; CHECK-NEXT:    )
;; CHECK-NEXT:    (i32.and
;; CHECK-NEXT:     (f32.eq
;; CHECK-NEXT:      (f32x4.extract_lane 2
;; CHECK-NEXT:       (local.get $0)
;; CHECK-NEXT:      )
;; CHECK-NEXT:      (f32x4.extract_lane 2
;; CHECK-NEXT:       (local.get $0)
;; CHECK-NEXT:      )
;; CHECK-NEXT:     )
;; CHECK-NEXT:     (f32.eq
;; CHECK-NEXT:      (f32x4.extract_lane 3
;; CHECK-NEXT:       (local.get $0)
;; CHECK-NEXT:      )
;; CHECK-NEXT:      (f32x4.extract_lane 3
;; CHECK-NEXT:       (local.get $0)
;; CHECK-NEXT:      )
;; CHECK-NEXT:     )
;; CHECK-NEXT:    )
;; CHECK-NEXT:   )
;; CHECK-NEXT:   (then
;; CHECK-NEXT:    (local.get $0)
;; CHECK-NEXT:   )
;; CHECK-NEXT:   (else
;; CHECK-NEXT:    (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000)
;; CHECK-NEXT:   )
;; CHECK-NEXT:  )
;; CHECK-NEXT: )