From 44252303d7c24c2287b449d29b7a766aec537668 Mon Sep 17 00:00:00 2001 From: Petr Penzin Date: Thu, 15 Aug 2019 09:59:11 -0700 Subject: [PATCH 1/2] Introduce unsigned narrowing with signed inputs For issue #94 --- proposals/simd/BinarySIMD.md | 22 ++++++++++++---------- proposals/simd/ImplementationStatus.md | 2 ++ proposals/simd/SIMD.md | 10 +++++++--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/proposals/simd/BinarySIMD.md b/proposals/simd/BinarySIMD.md index 13615d363..168335225 100644 --- a/proposals/simd/BinarySIMD.md +++ b/proposals/simd/BinarySIMD.md @@ -174,13 +174,15 @@ The `v8x16.shuffle` instruction has 16 bytes after `simdop`. | `i64x2.load_splat` | `0xc5`| - | | `i8x16.narrow_i16x8_s` | `0xc6`| - | | `i8x16.narrow_i16x8_u` | `0xc7`| - | -| `i16x8.narrow_i32x4_s` | `0xc8`| - | -| `i16x8.narrow_i32x4_u` | `0xc9`| - | -| `i16x8.widen_low_i8x16_s` | `0xca`| - | -| `i16x8.widen_high_i8x16_s` | `0xcb`| - | -| `i16x8.widen_low_i8x16_u` | `0xcc`| - | -| `i16x8.widen_high_i8x16_u` | `0xcd`| - | -| `i32x4.widen_low_i16x8_s` | `0xce`| - | -| `i32x4.widen_high_i16x8_s` | `0xcf`| - | -| `i32x4.widen_low_i16x8_u` | `0xd0`| - | -| `i32x4.widen_high_i16x8_u` | `0xd1`| - | +| `i8x16.narrow_u16x8_u` | `0xc8`| - | +| `i16x8.narrow_i32x4_s` | `0xc9`| - | +| `i16x8.narrow_i32x4_u` | `0xca`| - | +| `i16x8.narrow_u32x4_u` | `0xcb`| - | +| `i16x8.widen_low_i8x16_s` | `0xcc`| - | +| `i16x8.widen_high_i8x16_s` | `0xcd`| - | +| `i16x8.widen_low_i8x16_u` | `0xce`| - | +| `i16x8.widen_high_i8x16_u` | `0xcf`| - | +| `i32x4.widen_low_i16x8_s` | `0xd0`| - | +| `i32x4.widen_high_i16x8_s` | `0xd1`| - | +| `i32x4.widen_low_i16x8_u` | `0xd2`| - | +| `i32x4.widen_high_i16x8_u` | `0xd3`| - | diff --git a/proposals/simd/ImplementationStatus.md b/proposals/simd/ImplementationStatus.md index a911adf89..ae25e7010 100644 --- a/proposals/simd/ImplementationStatus.md +++ b/proposals/simd/ImplementationStatus.md @@ -147,8 +147,10 @@ | `v8x16.shuffle` | | | :heavy_check_mark: | :heavy_check_mark: | | `i8x16.narrow_i16x8_s` | | :heavy_check_mark: | :heavy_check_mark: | | | `i8x16.narrow_i16x8_u` | | :heavy_check_mark: | :heavy_check_mark: | | +| `i8x16.narrow_u16x8_u` | | | | | | `i16x8.narrow_i32x4_s` | | :heavy_check_mark: | :heavy_check_mark: | | | `i16x8.narrow_i32x4_u` | | :heavy_check_mark: | :heavy_check_mark: | | +| `i16x8.narrow_u32x4_u` | | | | | | `i16x8.widen_low_i8x16_s` | | :heavy_check_mark: | :heavy_check_mark: | | | `i16x8.widen_high_i8x16_s` | | :heavy_check_mark: | :heavy_check_mark: | | | `i16x8.widen_low_i8x16_u` | | :heavy_check_mark: | :heavy_check_mark: | | diff --git a/proposals/simd/SIMD.md b/proposals/simd/SIMD.md index fd4736946..afa0e0c1c 100644 --- a/proposals/simd/SIMD.md +++ b/proposals/simd/SIMD.md @@ -788,13 +788,17 @@ representable integer value. ### Integer to integer narrowing * `i8x16.narrow_i16x8_s(a: v128, b: v128) -> v128` * `i8x16.narrow_i16x8_u(a: v128, b: v128) -> v128` +* `i8x16.narrow_u16x8_u(a: v128, b: v128) -> v128` * `i16x8.narrow_i32x4_s(a: v128, b: v128) -> v128` * `i16x8.narrow_i32x4_u(a: v128, b: v128) -> v128` +* `i16x8.narrow_u32x4_u(a: v128, b: v128) -> v128` Converts two input vectors into a smaller lane vector by narrowing each lane, -signed or unsigned. The signed narrowing operation will use signed saturation -to handle overflow, 0x7f or 0x80 for i8x16, the unsigned narrowing operation -will use unsigned saturation to handle overflow, 0x00 or 0xff for i8x16. +signed or unsigned, the latter with either signed or unsigned inputs +(`narrow_i..` and `narrow_u..`, respectively). The signed narrowing operation +will use signed saturation to handle overflow, 0x7f or 0x80 for i8x16, the +unsigned narrowing operation will use unsigned saturation to handle overflow, +0x00 or 0xff for i8x16. ### Integer to integer widening * `i16x8.widen_low_i8x16_s(a: v128) -> v128` From 400ed429e86f62c801dfeaf82746ada11ca19b0a Mon Sep 17 00:00:00 2001 From: Petr Penzin Date: Wed, 28 Aug 2019 15:20:12 -0700 Subject: [PATCH 2/2] Clarify unsigned narrowing Use opcodes from unsigned narrowing for `unsigned narrowing with unsigned inputs`, as that was the semantics assumed by the spec and inmplemented in the runtimes. Unsigned narrowing with signed inputs is intended to be the new instruction introduced in the previous change. --- proposals/simd/BinarySIMD.md | 8 ++++---- proposals/simd/ImplementationStatus.md | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/proposals/simd/BinarySIMD.md b/proposals/simd/BinarySIMD.md index 168335225..38896ee7c 100644 --- a/proposals/simd/BinarySIMD.md +++ b/proposals/simd/BinarySIMD.md @@ -173,11 +173,11 @@ The `v8x16.shuffle` instruction has 16 bytes after `simdop`. | `i32x4.load_splat` | `0xc4`| - | | `i64x2.load_splat` | `0xc5`| - | | `i8x16.narrow_i16x8_s` | `0xc6`| - | -| `i8x16.narrow_i16x8_u` | `0xc7`| - | -| `i8x16.narrow_u16x8_u` | `0xc8`| - | +| `i8x16.narrow_u16x8_u` | `0xc7`| - | +| `i8x16.narrow_i16x8_u` | `0xc8`| - | | `i16x8.narrow_i32x4_s` | `0xc9`| - | -| `i16x8.narrow_i32x4_u` | `0xca`| - | -| `i16x8.narrow_u32x4_u` | `0xcb`| - | +| `i16x8.narrow_u32x4_u` | `0xca`| - | +| `i16x8.narrow_i32x4_u` | `0xcb`| - | | `i16x8.widen_low_i8x16_s` | `0xcc`| - | | `i16x8.widen_high_i8x16_s` | `0xcd`| - | | `i16x8.widen_low_i8x16_u` | `0xce`| - | diff --git a/proposals/simd/ImplementationStatus.md b/proposals/simd/ImplementationStatus.md index ae25e7010..49a459203 100644 --- a/proposals/simd/ImplementationStatus.md +++ b/proposals/simd/ImplementationStatus.md @@ -146,11 +146,11 @@ | `v8x16.swizzle` | | | :heavy_check_mark: | | | `v8x16.shuffle` | | | :heavy_check_mark: | :heavy_check_mark: | | `i8x16.narrow_i16x8_s` | | :heavy_check_mark: | :heavy_check_mark: | | -| `i8x16.narrow_i16x8_u` | | :heavy_check_mark: | :heavy_check_mark: | | -| `i8x16.narrow_u16x8_u` | | | | | +| `i8x16.narrow_u16x8_u` | | :heavy_check_mark: | :heavy_check_mark: | | +| `i8x16.narrow_i16x8_u` | | | | | | `i16x8.narrow_i32x4_s` | | :heavy_check_mark: | :heavy_check_mark: | | -| `i16x8.narrow_i32x4_u` | | :heavy_check_mark: | :heavy_check_mark: | | -| `i16x8.narrow_u32x4_u` | | | | | +| `i16x8.narrow_u32x4_u` | | :heavy_check_mark: | :heavy_check_mark: | | +| `i16x8.narrow_i32x4_u` | | | | | | `i16x8.widen_low_i8x16_s` | | :heavy_check_mark: | :heavy_check_mark: | | | `i16x8.widen_high_i8x16_s` | | :heavy_check_mark: | :heavy_check_mark: | | | `i16x8.widen_low_i8x16_u` | | :heavy_check_mark: | :heavy_check_mark: | |