From de9189d3a391461034a2d2d5dcc30c37fb78db21 Mon Sep 17 00:00:00 2001 From: Marat Dukhan Date: Mon, 18 May 2020 20:07:22 -0700 Subject: [PATCH 1/5] Floating-point rounding instructions SIMD equivalents of the nearest/trunc/ceil/floor instructions --- proposals/simd/BinarySIMD.md | 8 ++++++++ proposals/simd/ImplementationStatus.md | 8 ++++++++ proposals/simd/SIMD.md | 24 ++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/proposals/simd/BinarySIMD.md b/proposals/simd/BinarySIMD.md index 6c8adcdb2..c4db08d10 100644 --- a/proposals/simd/BinarySIMD.md +++ b/proposals/simd/BinarySIMD.md @@ -183,6 +183,14 @@ The `v8x16.shuffle` instruction has 16 bytes after `simdop`. | `i64x2.add` | `0xce`| - | | `i64x2.sub` | `0xd1`| - | | `i64x2.mul` | `0xd5`| - | +| `f32x4.nearest` | `0xd8`| - | +| `f32x4.trunc` | `0xd9`| - | +| `f32x4.ceil` | `0xda`| - | +| `f32x4.floor` | `0xdb`| - | +| `f64x2.nearest` | `0xdc`| - | +| `f64x2.trunc` | `0xdd`| - | +| `f64x2.ceil` | `0xde`| - | +| `f64x2.floor` | `0xdf`| - | | `f32x4.abs` | `0xe0`| - | | `f32x4.neg` | `0xe1`| - | | `f32x4.sqrt` | `0xe3`| - | diff --git a/proposals/simd/ImplementationStatus.md b/proposals/simd/ImplementationStatus.md index 2353ae98f..8f9efa9df 100644 --- a/proposals/simd/ImplementationStatus.md +++ b/proposals/simd/ImplementationStatus.md @@ -165,6 +165,10 @@ | `f32x4.div` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `f32x4.min` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `f32x4.max` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | +| `f32x4.nearest` | | | | | | +| `f32x4.trunc` | | | | | | +| `f32x4.ceil` | | | | | | +| `f32x4.floor` | | | | | | | `f64x2.abs` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `f64x2.neg` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `f64x2.sqrt` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | @@ -174,6 +178,10 @@ | `f64x2.div` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `f64x2.min` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `f64x2.max` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | +| `f64x2.nearest` | | | | | | +| `f64x2.trunc` | | | | | | +| `f64x2.ceil` | | | | | | +| `f64x2.floor` | | | | | | | `i32x4.trunc_sat_f32x4_s` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `i32x4.trunc_sat_f32x4_u` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `f32x4.convert_i32x4_s` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | diff --git a/proposals/simd/SIMD.md b/proposals/simd/SIMD.md index 56940aa22..bdb8b4438 100644 --- a/proposals/simd/SIMD.md +++ b/proposals/simd/SIMD.md @@ -900,6 +900,30 @@ Lane-wise IEEE `multiplication`. Lane-wise IEEE `squareRoot`. +### Round to nearest integer, ties to even +* `f32x4.nearest(a: v128) -> v128` +* `f64x2.nearest(a: v128) -> v128` + +Lane-wise rounding to the nearest integral value; if two values are equally near, rounds to the even one. + +### Round to integer toward zero (truncate to integer) +* `f32x4.trunc(a: v128) -> v128` +* `f64x2.trunc(a: v128) -> v128` + +Lane-wise rounding to the nearest integral value with the magniture not larger than the input. + +### Round to integer above (ceiling) +* `f32x4.ceil(a: v128) -> v128` +* `f64x2.ceil(a: v128) -> v128` + +Lane-wise rounding to the nearest integral value not smaller than the input. + +### Round to integer below (floor) +* `f32x4.floor(a: v128) -> v128` +* `f64x2.floor(a: v128) -> v128` + +Lane-wise rounding to the nearest integral value not greater than the input. + ## Conversions ### Integer to floating point * `f32x4.convert_i32x4_s(a: v128) -> v128` From eb1de5f76eee8e3b4893a816f38ea9883900daa3 Mon Sep 17 00:00:00 2001 From: Marat Dukhan Date: Thu, 4 Jun 2020 12:06:05 -0700 Subject: [PATCH 2/5] Update proposals/simd/BinarySIMD.md Co-authored-by: Thomas Lively <7121787+tlively@users.noreply.github.com> --- proposals/simd/BinarySIMD.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/proposals/simd/BinarySIMD.md b/proposals/simd/BinarySIMD.md index c4db08d10..1cc11ab3c 100644 --- a/proposals/simd/BinarySIMD.md +++ b/proposals/simd/BinarySIMD.md @@ -183,14 +183,14 @@ The `v8x16.shuffle` instruction has 16 bytes after `simdop`. | `i64x2.add` | `0xce`| - | | `i64x2.sub` | `0xd1`| - | | `i64x2.mul` | `0xd5`| - | -| `f32x4.nearest` | `0xd8`| - | -| `f32x4.trunc` | `0xd9`| - | -| `f32x4.ceil` | `0xda`| - | -| `f32x4.floor` | `0xdb`| - | -| `f64x2.nearest` | `0xdc`| - | -| `f64x2.trunc` | `0xdd`| - | -| `f64x2.ceil` | `0xde`| - | -| `f64x2.floor` | `0xdf`| - | +| `f32x4.ceil` | `0xd8`| - | +| `f32x4.floor` | `0xd9`| - | +| `f32x4.trunc` | `0xda`| - | +| `f32x4.nearest` | `0xdb`| - | +| `f64x2.ceil` | `0xdc`| - | +| `f64x2.floor` | `0xdd`| - | +| `f64x2.trunc` | `0xde`| - | +| `f64x2.nearest` | `0xdf`| - | | `f32x4.abs` | `0xe0`| - | | `f32x4.neg` | `0xe1`| - | | `f32x4.sqrt` | `0xe3`| - | From 80d19f8a6fabf8a0733bddea96e4e4f6d3a2ab14 Mon Sep 17 00:00:00 2001 From: Marat Dukhan Date: Thu, 4 Jun 2020 12:06:19 -0700 Subject: [PATCH 3/5] Update proposals/simd/ImplementationStatus.md Co-authored-by: Thomas Lively <7121787+tlively@users.noreply.github.com> --- proposals/simd/ImplementationStatus.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proposals/simd/ImplementationStatus.md b/proposals/simd/ImplementationStatus.md index 8f9efa9df..98928defb 100644 --- a/proposals/simd/ImplementationStatus.md +++ b/proposals/simd/ImplementationStatus.md @@ -165,10 +165,10 @@ | `f32x4.div` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `f32x4.min` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `f32x4.max` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | -| `f32x4.nearest` | | | | | | -| `f32x4.trunc` | | | | | | | `f32x4.ceil` | | | | | | | `f32x4.floor` | | | | | | +| `f32x4.trunc` | | | | | | +| `f32x4.nearest` | | | | | | | `f64x2.abs` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `f64x2.neg` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `f64x2.sqrt` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | From dd43218455f352598b1da27266e30a8b72e672b6 Mon Sep 17 00:00:00 2001 From: Marat Dukhan Date: Thu, 4 Jun 2020 12:06:26 -0700 Subject: [PATCH 4/5] Update proposals/simd/ImplementationStatus.md Co-authored-by: Thomas Lively <7121787+tlively@users.noreply.github.com> --- proposals/simd/ImplementationStatus.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proposals/simd/ImplementationStatus.md b/proposals/simd/ImplementationStatus.md index 98928defb..aba09c2cb 100644 --- a/proposals/simd/ImplementationStatus.md +++ b/proposals/simd/ImplementationStatus.md @@ -178,10 +178,10 @@ | `f64x2.div` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `f64x2.min` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `f64x2.max` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | -| `f64x2.nearest` | | | | | | -| `f64x2.trunc` | | | | | | | `f64x2.ceil` | | | | | | | `f64x2.floor` | | | | | | +| `f64x2.trunc` | | | | | | +| `f64x2.nearest` | | | | | | | `i32x4.trunc_sat_f32x4_s` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `i32x4.trunc_sat_f32x4_u` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | | `f32x4.convert_i32x4_s` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: | From 70aba5e965500a2415113a1fff49ee40ab488d3d Mon Sep 17 00:00:00 2001 From: Marat Dukhan Date: Thu, 4 Jun 2020 12:06:42 -0700 Subject: [PATCH 5/5] Update proposals/simd/SIMD.md Co-authored-by: Thomas Lively <7121787+tlively@users.noreply.github.com> --- proposals/simd/SIMD.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/proposals/simd/SIMD.md b/proposals/simd/SIMD.md index bdb8b4438..dbd408597 100644 --- a/proposals/simd/SIMD.md +++ b/proposals/simd/SIMD.md @@ -900,18 +900,6 @@ Lane-wise IEEE `multiplication`. Lane-wise IEEE `squareRoot`. -### Round to nearest integer, ties to even -* `f32x4.nearest(a: v128) -> v128` -* `f64x2.nearest(a: v128) -> v128` - -Lane-wise rounding to the nearest integral value; if two values are equally near, rounds to the even one. - -### Round to integer toward zero (truncate to integer) -* `f32x4.trunc(a: v128) -> v128` -* `f64x2.trunc(a: v128) -> v128` - -Lane-wise rounding to the nearest integral value with the magniture not larger than the input. - ### Round to integer above (ceiling) * `f32x4.ceil(a: v128) -> v128` * `f64x2.ceil(a: v128) -> v128` @@ -924,6 +912,18 @@ Lane-wise rounding to the nearest integral value not smaller than the input. Lane-wise rounding to the nearest integral value not greater than the input. +### Round to integer toward zero (truncate to integer) +* `f32x4.trunc(a: v128) -> v128` +* `f64x2.trunc(a: v128) -> v128` + +Lane-wise rounding to the nearest integral value with the magnitude not larger than the input. + +### Round to nearest integer, ties to even +* `f32x4.nearest(a: v128) -> v128` +* `f64x2.nearest(a: v128) -> v128` + +Lane-wise rounding to the nearest integral value; if two values are equally near, rounds to the even one. + ## Conversions ### Integer to floating point * `f32x4.convert_i32x4_s(a: v128) -> v128`