Skip to content

Tests for correct page size and float conversion #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ml-proto/TestingTodo.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Operator semantics:
- ~~test that numbers slightly outside of the int32 range round into the int32 range in floating-to-int32 conversion~~
- ~~test that neg, abs, copysign, reinterpretcast, store+load, set+get, preserve the sign bit and significand bits of NaN and don't canonicalize~~
- ~~test that shifts don't mask their shift count. 32 is particularly nice to test.~~
- test that `page_size` returns a power of 2
- ~~test that `page_size` returns a power of 2~~
- ~~test that arithmetic operands are evaluated left-to-right~~
- ~~test that call and store operands are evaluated left-to-right too~~
- test that call and argument operands of call_indirect are evaluated left-to-right, too
Expand Down Expand Up @@ -66,8 +66,8 @@ Function pointer semantics:
Expression optimizer bait:
- ~~test that `a+1<b+1` isn't folded to `a<b`~~
- test that that demote-promote, wrap+sext, wrap+zext, shl+ashr, shl+lshr, div+mul, mul+div aren't folded away
- test that converting int32 to float and back isn't folded away
- test that converting int64 to double and back isn't folded away
- ~~test that converting int32 to float and back isn't folded away~~
- ~~test that converting int64 to double and back isn't folded away~~
- test that `float(double(float(x))+double(y))` is not `float(x)+float(y)` (and so on for other operators)
- ~~test that `x*0.0` is not folded to `0.0`~~
- ~~test that `0.0/x` is not folded to `0.0`~~
Expand Down
36 changes: 36 additions & 0 deletions ml-proto/test/float_exprs.wast
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,39 @@
(assert_return (invoke "f32.no_approximate_sqrt_reciprocal" (f32.const 0x1.125ec2p+69) (f32.const -0x1.a7f42ep+92)) (f32.const 0x1.5db572p-35))
(assert_return (invoke "f32.no_approximate_sqrt_reciprocal" (f32.const 0x1.ba4c5p+13) (f32.const 0x1.947784p-72)) (f32.const 0x1.136f16p-7))
(assert_return (invoke "f32.no_approximate_sqrt_reciprocal" (f32.const 0x1.4a5be2p+104) (f32.const 0x1.a7b718p-19)) (f32.const 0x1.c2b5bp-53))

;; Test that converting i32/i64 to f32/f64 and back isn't folded away

(module
(func $i32.no_fold_f32_s (param i32) (result i32)
(i32.trunc_s/f32 (f32.convert_s/i32 (get_local 0))))
(export "i32.no_fold_f32_s" $i32.no_fold_f32_s)

(func $i32.no_fold_f32_u (param i32) (result i32)
(i32.trunc_u/f32 (f32.convert_u/i32 (get_local 0))))
(export "i32.no_fold_f32_u" $i32.no_fold_f32_u)

(func $i64.no_fold_f64_s (param i64) (result i64)
(i64.trunc_s/f64 (f64.convert_s/i64 (get_local 0))))
(export "i64.no_fold_f64_s" $i64.no_fold_f64_s)

(func $i64.no_fold_f64_u (param i64) (result i64)
(i64.trunc_u/f64 (f64.convert_u/i64 (get_local 0))))
(export "i64.no_fold_f64_u" $i64.no_fold_f64_u)
)

(assert_return (invoke "i32.no_fold_f32_s" (i32.const 0x1000000)) (i32.const 0x1000000))
(assert_return (invoke "i32.no_fold_f32_s" (i32.const 0x1000001)) (i32.const 0x1000000))
(assert_return (invoke "i32.no_fold_f32_s" (i32.const 0xf0000010)) (i32.const 0xf0000010))

(assert_return (invoke "i32.no_fold_f32_u" (i32.const 0x1000000)) (i32.const 0x1000000))
(assert_return (invoke "i32.no_fold_f32_u" (i32.const 0x1000001)) (i32.const 0x1000000))
(assert_return (invoke "i32.no_fold_f32_u" (i32.const 0xf0000010)) (i32.const 0xf0000000))

(assert_return (invoke "i64.no_fold_f64_s" (i64.const 0x20000000000000)) (i64.const 0x20000000000000))
(assert_return (invoke "i64.no_fold_f64_s" (i64.const 0x20000000000001)) (i64.const 0x20000000000000))
(assert_return (invoke "i64.no_fold_f64_s" (i64.const 0xf000000000000400)) (i64.const 0xf000000000000400))

(assert_return (invoke "i64.no_fold_f64_u" (i64.const 0x20000000000000)) (i64.const 0x20000000000000))
(assert_return (invoke "i64.no_fold_f64_u" (i64.const 0x20000000000001)) (i64.const 0x20000000000000))
(assert_return (invoke "i64.no_fold_f64_u" (i64.const 0xf000000000000400)) (i64.const 0xf000000000000000))
6 changes: 6 additions & 0 deletions ml-proto/test/resizing.wast
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
(module
(memory 0)

(export "power_of_two" $power_of_two)
(func $power_of_two (result i32)
(i32.popcnt (page_size))
)

(export "round_up_to_page" $round_up_to_page)
(func $round_up_to_page (param i32) (result i32)
(i32.and (i32.add (get_local 0) (i32.sub (page_size) (i32.const 1)))
Expand Down Expand Up @@ -31,6 +36,7 @@
(func $size (result i32) (memory_size))
)

(assert_return (invoke "power_of_two") (i32.const 1))
(assert_return (invoke "size") (i32.const 0))
(assert_return (invoke "size_at_least" (i32.const 0)) (i32.const 1))
(assert_trap (invoke "store_at_zero") "runtime: out of bounds memory access")
Expand Down