From e261fdde169d96dba5e0f15a5977adc7431f0f07 Mon Sep 17 00:00:00 2001 From: Marat Dukhan Date: Mon, 28 Oct 2019 16:15:48 -0700 Subject: [PATCH] Integer absolute value instructions --- proposals/simd/BinarySIMD.md | 3 +++ proposals/simd/ImplementationStatus.md | 3 +++ proposals/simd/SIMD.md | 14 +++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/proposals/simd/BinarySIMD.md b/proposals/simd/BinarySIMD.md index 74ec47ab9..a43dd8d05 100644 --- a/proposals/simd/BinarySIMD.md +++ b/proposals/simd/BinarySIMD.md @@ -199,3 +199,6 @@ The `v8x16.shuffle` instruction has 16 bytes after `simdop`. | `v128.andnot` | `0xd8`| - | | `i8x16.avgr_u` | `0xd9`| | | `i16x8.avgr_u` | `0xda`| | +| `i8x16.abs` | `0xe1`| - | +| `i16x8.abs` | `0xe2`| - | +| `i32x4.abs` | `0xe3`| - | diff --git a/proposals/simd/ImplementationStatus.md b/proposals/simd/ImplementationStatus.md index 8a19c9e32..514cdd58e 100644 --- a/proposals/simd/ImplementationStatus.md +++ b/proposals/simd/ImplementationStatus.md @@ -92,6 +92,7 @@ | `i8x16.max_s` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | | | `i8x16.max_u` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | | | `i8x16.avgr_u` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | | +| `i8x16.abs` | | | | | | `i16x8.neg` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | `i16x8.any_true` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | `i16x8.all_true` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | @@ -110,6 +111,7 @@ | `i16x8.max_s` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | | | `i16x8.max_u` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | | | `i16x8.avgr_u` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | | +| `i16x8.abs` | | | | | | `i32x4.neg` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | `i32x4.any_true` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | `i32x4.all_true` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | @@ -123,6 +125,7 @@ | `i32x4.min_u` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | | | `i32x4.max_s` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | | | `i32x4.max_u` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | | +| `i32x4.abs` | | | | | | `i64x2.neg` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | `i64x2.shl` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | `i64x2.shr_s` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | diff --git a/proposals/simd/SIMD.md b/proposals/simd/SIMD.md index 4f8169f05..24739ec4a 100644 --- a/proposals/simd/SIMD.md +++ b/proposals/simd/SIMD.md @@ -503,6 +503,18 @@ def S.avgr_u(a, b): return S.lanewise_binary(S.RoundingAverage, S.AsUnsigned(a), S.AsUnsigned(b)) ``` +### Lane-wise integer absolute value +* `i8x16.abs(a: v128) -> v128` +* `i16x8.abs(a: v128) -> v128` +* `i32x4.abs(a: v128) -> v128` + +Lane-wise wrapping absolute value. + +```python +def S.abs(a): + return S.lanewise_unary(abs, S.AsSigned(a)) +``` + ## Bit shifts ### Left shift by scalar @@ -791,7 +803,7 @@ def S.neg(a): return S.lanewise_unary(ieee.negate, a) ``` -### Absolute value +### Floating-point absolute value * `f32x4.abs(a: v128) -> v128` * `f64x2.abs(a: v128) -> v128`