Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Commit 8e87db7

Browse files
authored
Floating-point rounding instructions (#232)
New floating-point rounding instructions: - Round to nearest integer, ties to even: `f32x4.nearest`/`f64x2.nearest` - Round to integer towards zero (truncate to integer): `f32x4.trunc`/`f64x2.trunc` - Round to integer above (ceiling): `f32x4.ceil`/`f64x2.ceil` - Round to integer below (floor): `f32x4.floor`/`f64x2.floor`
1 parent e1ff82e commit 8e87db7

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

proposals/simd/BinarySIMD.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ For example, `ImmLaneIdx16` is a byte with values in the range 0-15 (inclusive).
188188
| `i64x2.add` | `0xce`| - |
189189
| `i64x2.sub` | `0xd1`| - |
190190
| `i64x2.mul` | `0xd5`| - |
191+
| `f32x4.ceil` | `0xd8`| - |
192+
| `f32x4.floor` | `0xd9`| - |
193+
| `f32x4.trunc` | `0xda`| - |
194+
| `f32x4.nearest` | `0xdb`| - |
195+
| `f64x2.ceil` | `0xdc`| - |
196+
| `f64x2.floor` | `0xdd`| - |
197+
| `f64x2.trunc` | `0xde`| - |
198+
| `f64x2.nearest` | `0xdf`| - |
191199
| `f32x4.abs` | `0xe0`| - |
192200
| `f32x4.neg` | `0xe1`| - |
193201
| `f32x4.sqrt` | `0xe3`| - |

proposals/simd/ImplementationStatus.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@
165165
| `f32x4.div` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
166166
| `f32x4.min` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
167167
| `f32x4.max` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
168+
| `f32x4.ceil` | | | | | |
169+
| `f32x4.floor` | | | | | |
170+
| `f32x4.trunc` | | | | | |
171+
| `f32x4.nearest` | | | | | |
168172
| `f64x2.abs` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
169173
| `f64x2.neg` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
170174
| `f64x2.sqrt` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
@@ -174,6 +178,10 @@
174178
| `f64x2.div` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
175179
| `f64x2.min` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
176180
| `f64x2.max` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
181+
| `f64x2.ceil` | | | | | |
182+
| `f64x2.floor` | | | | | |
183+
| `f64x2.trunc` | | | | | |
184+
| `f64x2.nearest` | | | | | |
177185
| `i32x4.trunc_sat_f32x4_s` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
178186
| `i32x4.trunc_sat_f32x4_u` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |
179187
| `f32x4.convert_i32x4_s` | `-msimd128` | :heavy_check_mark: | | | :heavy_check_mark: |

proposals/simd/SIMD.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,30 @@ Lane-wise IEEE `multiplication`.
914914

915915
Lane-wise IEEE `squareRoot`.
916916

917+
### Round to integer above (ceiling)
918+
* `f32x4.ceil(a: v128) -> v128`
919+
* `f64x2.ceil(a: v128) -> v128`
920+
921+
Lane-wise rounding to the nearest integral value not smaller than the input.
922+
923+
### Round to integer below (floor)
924+
* `f32x4.floor(a: v128) -> v128`
925+
* `f64x2.floor(a: v128) -> v128`
926+
927+
Lane-wise rounding to the nearest integral value not greater than the input.
928+
929+
### Round to integer toward zero (truncate to integer)
930+
* `f32x4.trunc(a: v128) -> v128`
931+
* `f64x2.trunc(a: v128) -> v128`
932+
933+
Lane-wise rounding to the nearest integral value with the magnitude not larger than the input.
934+
935+
### Round to nearest integer, ties to even
936+
* `f32x4.nearest(a: v128) -> v128`
937+
* `f64x2.nearest(a: v128) -> v128`
938+
939+
Lane-wise rounding to the nearest integral value; if two values are equally near, rounds to the even one.
940+
917941
## Conversions
918942
### Integer to floating point
919943
* `f32x4.convert_i32x4_s(a: v128) -> v128`

0 commit comments

Comments
 (0)