File: sink-float-but-dont-trap.wast

package info (click to toggle)
rust-wasmtime 26.0.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 48,492 kB
  • sloc: ansic: 4,003; sh: 561; javascript: 542; cpp: 254; asm: 175; ml: 96; makefile: 55
file content (51 lines) | stat: -rw-r--r-- 1,550 bytes parent folder | download | duplicates (3)
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
(module
  (memory 1)

  ;; make sure that the sunk load here doesn't try to load past the end of
  ;; memory.
  (func (export "select-with-sink") (param i32) (result f64)
    local.get 0
    f64.load
    f64.const 1
    local.get 0
    select
    return)

  ;; same as above but with a slightly different codegen pattern.
  (func (export "select-with-fcmp-and-sink") (param i32 f64 f64) (result f64)
    local.get 0
    f64.load
    f64.const 1
    local.get 1
    local.get 2
    f64.ne
    select
    return)

  ;; Same as the above two but the order of operands to the `select` are
  ;; swapped.
  (func (export "select-with-sink-other-way") (param i32) (result f64)
    f64.const 1
    local.get 0
    f64.load
    local.get 0
    select
    return)
  (func (export "select-with-fcmp-and-sink-other-way") (param i32 f64 f64) (result f64)
    f64.const 1
    local.get 0
    f64.load
    local.get 1
    local.get 2
    f64.ne
    select
    return)
)

(assert_return (invoke "select-with-sink" (i32.const 0xfff8)) (f64.const 0))
(assert_return (invoke "select-with-fcmp-and-sink" (i32.const 0xfff8) (f64.const 0) (f64.const 0)) (f64.const 1))

(assert_trap (invoke "select-with-sink" (i32.const 0xfff9)) "out of bounds")
(assert_trap (invoke "select-with-fcmp-and-sink" (i32.const 0xfff9) (f64.const 0) (f64.const 0)) "out of bounds")
(assert_trap (invoke "select-with-sink-other-way" (i32.const 0xfff9)) "out of bounds")
(assert_trap (invoke "select-with-fcmp-and-sink-other-way" (i32.const 0xfff9) (f64.const 0) (f64.const 0)) "out of bounds")