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

Commit

Permalink
Floating-point rounding instructions (#232)
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
Maratyszcza authored Sep 11, 2020
1 parent e1ff82e commit 8e87db7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions proposals/simd/BinarySIMD.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ For example, `ImmLaneIdx16` is a byte with values in the range 0-15 (inclusive).
| `i64x2.add` | `0xce`| - |
| `i64x2.sub` | `0xd1`| - |
| `i64x2.mul` | `0xd5`| - |
| `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`| - |
Expand Down
8 changes: 8 additions & 0 deletions proposals/simd/ImplementationStatus.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.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: |
Expand All @@ -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.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: |
Expand Down
24 changes: 24 additions & 0 deletions proposals/simd/SIMD.md
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,30 @@ Lane-wise IEEE `multiplication`.

Lane-wise IEEE `squareRoot`.

### 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.

### 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`
Expand Down

0 comments on commit 8e87db7

Please sign in to comment.