Skip to content

Commit 2fd9172

Browse files
committed
Fix relaxed laneselect to allow looking at top bit of byte
This allows using pblendvb for i16x8 lane select. See WebAssembly#125.
1 parent ba2d5eb commit 2fd9172

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

document/core/exec/numerics.rst

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,25 +2168,33 @@ The result for NaN's and out-of-range values is host-dependent.
21682168
:math:`\relaxedlane_N(i_1, i_2, i_3)`
21692169
.....................................
21702170

2171-
* If :math:`i_3` is :math:`2^N - 1`, return :math:`i_1`.
2171+
* :math:`\EXPROFDET` If :math:`i_3` is :math:`2^N - 1`, return :math:`i_1`.
21722172

2173-
* Else if :math:`i_3` is :math:`0`, return :math:`i_2`.
2173+
* :math:`\EXPROFDET` Else if :math:`i_3` is :math:`0`, return :math:`i_2`.
21742174

2175-
* :math:`\EXPROFDET` Else if :math:`\signed_n(i_3)` is less than :math:`0`, return either :math:`\ibitselect_n(i_1, i_2, i_3)` or :math:`i_1`.
2175+
* :math:`\EXPROFDET` Otherwise return either :math:`\ibitselect_n(i_1, i_2, i_3)` or :math:`i_1` or :math:`i_2` or :math:`\F{top\_bit\_byteselect_N}(i_1, i_2, i_3)`.
21762176

2177-
* :math:`\EXPROFDET` Otherwise return either :math:`\ibitselect_n(i_1, i_2, i_3)` or :math:`i_2`.
2178-
2179-
* Otherwise return :math:`\ibitselect_n(i_1, i_2, i_3)`.
2177+
* Return :math:`\ibitselect_n(i_1, i_2, i_3)`.
21802178

21812179
.. math::
21822180
\begin{array}{@{}llcll}
2183-
& \relaxedlane_N(i_1, i_2, 2^N-1) &=& i_1 \\
2184-
& \relaxedlane_N(i_1, i_2, 0) &=& i_2 \\
2185-
\EXPROFDET & \relaxedlane_N(i_1, i_2, i_3) &=& [ \ibitselect_N(i_1, i_2, i_3), i_1 ] & (\iff \signed_N(i_3) < 0) \\
2186-
\EXPROFDET & \relaxedlane_N(i_1, i_2, i_3) &=& [ \ibitselect_N(i_1, i_2, i_3), i_2 ] & (\otherwise) \\
2181+
\EXPROFDET & \relaxedlane_N(i_1, i_2, 2^N-1) &=& i_1 \\
2182+
\EXPROFDET & \relaxedlane_N(i_1, i_2, 0) &=& i_2 \\
2183+
\EXPROFDET & \relaxedlane_N(i_1, i_2, i_3) &=& [ \ibitselect_N(i_1, i_2, i_3), i_2, i_3, \\
2184+
& & & \qquad \F{top\_bit\_byteselect}(i_1, i_2, i_3)] & (\otherwise) \\
21872185
& \relaxedlane_N(i_1, i_2, i_3) &=& \ibitselect_N(i_1, i_2, i_3) & (\otherwise) \\
21882186
\end{array}
21892187
2188+
where:
2189+
2190+
.. math::
2191+
\begin{array}{@{}llcll}
2192+
& \F{top\_bit\_byteselect}_N(i_1, i_2, i_3) &=& tbb_0 ... tbb_{N/8 - 1} \\
2193+
& \F{tbb_j} &=& \F{byteselect}(\bytes_8(i_1)[j], \bytes_8(i_2)[j], \bytes_8(i_3)[j]) \\
2194+
& \F{byteselect}(a, b, 0~c^7) &=& a \\
2195+
& \F{byteselect}(a, b, c) &=& b \\
2196+
\end{array}
2197+
21902198
21912199
.. _op-relaxed_lane_select:
21922200

@@ -2195,7 +2203,8 @@ The result for NaN's and out-of-range values is host-dependent.
21952203

21962204
Relaxed lane selection is deterministic when all bits are set or unset in the
21972205
mask. Otherwise depending on the host, either only the top bit is examined, or
2198-
all bits are examined (i.e. it becomes a bit select).
2206+
all bits are examined (i.e. it becomes a bit select), or the top bit of each
2207+
byte in the lane is examined.
21992208

22002209
* Return :math:`rll_0 \dots rll_{n-1}` where :math:`rll_i = \relaxedlane_B(a^n[i], b^n[i], c^n[i])`.
22012210

0 commit comments

Comments
 (0)