From 7e5d70675b49acd2dc782158b7ed048a255f479d Mon Sep 17 00:00:00 2001 From: Marat Dukhan Date: Tue, 24 Sep 2019 04:53:21 -0700 Subject: [PATCH] Sign Select instructions --- proposals/simd/BinarySIMD.md | 4 ++++ proposals/simd/ImplementationStatus.md | 5 +++++ proposals/simd/SIMD.md | 11 +++++++++++ 3 files changed, 20 insertions(+) diff --git a/proposals/simd/BinarySIMD.md b/proposals/simd/BinarySIMD.md index 8617d725d..071b8f55f 100644 --- a/proposals/simd/BinarySIMD.md +++ b/proposals/simd/BinarySIMD.md @@ -189,3 +189,7 @@ The `v8x16.shuffle` instruction has 16 bytes after `simdop`. | `i64x2.load32x2_s` | `0xd6`| m:memarg | | `i64x2.load32x2_u` | `0xd7`| m:memarg | | `v128.andnot` | `0xd8`| - | +| `v8x16.signselect` | `0xd9`| | +| `v16x8.signselect` | `0xda`| | +| `v32x4.signselect` | `0xdb`| | +| `v64x2.signselect` | `0xdc`| | diff --git a/proposals/simd/ImplementationStatus.md b/proposals/simd/ImplementationStatus.md index 4778d4fa0..dcf0ea32e 100644 --- a/proposals/simd/ImplementationStatus.md +++ b/proposals/simd/ImplementationStatus.md @@ -1,3 +1,4 @@ +<<<<<<< HEAD | Instruction | LLVM[1] | V8[2] | WAVM[3] | ChakraCore[4] | | ---------------------------|---------------------------|-----------------------|--------------------|--------------------| | `v128.load` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | @@ -75,6 +76,10 @@ | `v128.or` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | `v128.xor` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | `v128.bitselect` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| `v8x16.signselect` | | | | | +| `v16x8.signselect` | | | | | +| `v32x4.signselect` | | | | | +| `v64x2.signselect` | | | | | | `i8x16.neg` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | `i8x16.any_true` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | `i8x16.all_true` | `-msimd128` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | diff --git a/proposals/simd/SIMD.md b/proposals/simd/SIMD.md index 0f1379207..b933e9456 100644 --- a/proposals/simd/SIMD.md +++ b/proposals/simd/SIMD.md @@ -539,6 +539,17 @@ Note that the normal WebAssembly `select` instruction also works with vector types. It selects between two whole vectors controlled by a single scalar value, rather than selecting bits controlled by a control mask vector. +### Sign select +* `v8x16.signselect(v1: v128, v2: v128, c: v128) -> v128` +* `v16x8.signselect(v1: v128, v2: v128, c: v128) -> v128` +* `v32x4.signselect(v1: v128, v2: v128, c: v128) -> v128` +* `v64x2.signselect(v1: v128, v2: v128, c: v128) -> v128` + +Use the sign bits in the control mask `c` to select the corresponding element +from `v1` when 1 (negative sign) and `v2` when 0 (positive sign). + +Note that these instructions work for both signed integer and floating-point +control masks. ## Boolean horizontal reductions