summaryrefslogtreecommitdiff
path: root/test/unit.fromasm.clamp
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit.fromasm.clamp')
-rw-r--r--test/unit.fromasm.clamp63
1 files changed, 54 insertions, 9 deletions
diff --git a/test/unit.fromasm.clamp b/test/unit.fromasm.clamp
index 4393c362c..c4f133481 100644
--- a/test/unit.fromasm.clamp
+++ b/test/unit.fromasm.clamp
@@ -168,6 +168,32 @@
)
)
)
+ (func $f32-to-int (param $0 f32) (result i32)
+ (if (result i32)
+ (f32.ne
+ (get_local $0)
+ (get_local $0)
+ )
+ (i32.const -2147483648)
+ (if (result i32)
+ (f32.ge
+ (get_local $0)
+ (f32.const 2147483648)
+ )
+ (i32.const -2147483648)
+ (if (result i32)
+ (f32.le
+ (get_local $0)
+ (f32.const -2147483648)
+ )
+ (i32.const -2147483648)
+ (i32.trunc_s/f32
+ (get_local $0)
+ )
+ )
+ )
+ )
+ )
(func $conversions (param $0 i32) (param $1 f64) (param $2 f32)
(drop
(call $f64-to-int
@@ -175,10 +201,8 @@
)
)
(drop
- (call $f64-to-int
- (f64.promote/f32
- (get_local $2)
- )
+ (call $f32-to-int
+ (get_local $2)
)
)
)
@@ -1186,9 +1210,30 @@
)
)
)
- (func $f2u (param $0 f64) (result i32)
- (call $f64-to-int
- (get_local $0)
+ (func $f64-to-uint (param $0 f64) (result i32)
+ (if (result i32)
+ (f64.ne
+ (get_local $0)
+ (get_local $0)
+ )
+ (i32.const 0)
+ (if (result i32)
+ (f64.ge
+ (get_local $0)
+ (f64.const 4294967296)
+ )
+ (i32.const 0)
+ (if (result i32)
+ (f64.le
+ (get_local $0)
+ (f64.const -1)
+ )
+ (i32.const 0)
+ (i32.trunc_u/f64
+ (get_local $0)
+ )
+ )
+ )
)
)
(func $keepAlive
@@ -1203,12 +1248,12 @@
)
)
(drop
- (call $f2u
+ (call $f64-to-uint
(f64.const 100)
)
)
(drop
- (call $f2u
+ (call $f64-to-int
(f64.const 100)
)
)