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

Commit

Permalink
Pseudo-Minimum and Pseudo-Maximum instructions (#122)
Browse files Browse the repository at this point in the history
Introduce Pseudo-Minimum (`f32x4.pmin` and `f64x2.pmin`) and Pseudo-Maximum (`f32x4.pmax` and `f64x2.pmax`) instructions, which implement Pseudo-Minimum and Pseudo-Maximum operations with slightly different semantics than the Minimum and Maximum in the current spec. Pseudo-Minimum is defined as `pmin(a, b) := b < a ? b : a` and Pseudo-Maximum is defined as `pmax(a, b) := a < b ? b : a`. "Pseudo" in the name refers to the fact that these operations may not return the minimum in case of signed zero inputs, in particular:
- `pmin(+0.0, -0.0) == +0.0`
- `pmax(-0.0, +0.0) == -0.0`
  • Loading branch information
Maratyszcza authored Sep 11, 2020
1 parent e7c2002 commit e1ff82e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions proposals/simd/BinarySIMD.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ For example, `ImmLaneIdx16` is a byte with values in the range 0-15 (inclusive).
| `f32x4.div` | `0xe7`| - |
| `f32x4.min` | `0xe8`| - |
| `f32x4.max` | `0xe9`| - |
| `f32x4.pmin` | `0xea`| - |
| `f32x4.pmax` | `0xeb`| - |
| `f64x2.abs` | `0xec`| - |
| `f64x2.neg` | `0xed`| - |
| `f64x2.sqrt` | `0xef`| - |
Expand All @@ -206,6 +208,8 @@ For example, `ImmLaneIdx16` is a byte with values in the range 0-15 (inclusive).
| `f64x2.div` | `0xf3`| - |
| `f64x2.min` | `0xf4`| - |
| `f64x2.max` | `0xf5`| - |
| `f64x2.pmin` | `0xf6`| - |
| `f64x2.pmax` | `0xf7`| - |
| `i32x4.trunc_sat_f32x4_s` | `0xf8`| - |
| `i32x4.trunc_sat_f32x4_u` | `0xf9`| - |
| `f32x4.convert_i32x4_s` | `0xfa`| - |
Expand Down
12 changes: 12 additions & 0 deletions proposals/simd/SIMD.md
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,18 @@ Lane-wise minimum value, propagating NaNs.

Lane-wise maximum value, propagating NaNs.

### Pseudo-minimum
* `f32x4.pmin(a: v128, b: v128) -> v128`
* `f64x2.pmin(a: v128, b: v128) -> v128`

Lane-wise minimum value, defined as `b < a ? b : a`.

### Pseudo-maximum
* `f32x4.pmax(a: v128, b: v128) -> v128`
* `f64x2.pmax(a: v128, b: v128) -> v128`

Lane-wise maximum value, defined as `a < b ? b : a`.

## Floating-point arithmetic

The floating-point arithmetic operations are all lane-wise versions of the
Expand Down

0 comments on commit e1ff82e

Please sign in to comment.