Skip to content

Commit 8e5f4ee

Browse files
committed
[spec] Various fixes to SIMD stuff
1 parent e9cbf1a commit 8e5f4ee

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed

document/core/exec/instructions.rst

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,21 @@ Most other vector instructions are defined in terms of numeric operators that ar
16011601
:math:`\lanes_{\K{i32x4}}(v_1)` and :math:`\lanes_{\K{i32x4}}(v_2)`
16021602
respectively.
16031603

1604+
For non-deterministic operators this definition is generalized to sets:
1605+
1606+
.. math::
1607+
\begin{array}{lll}
1608+
\X{op}_{t\K{x}N}(n_1,\dots,n_k) &=&
1609+
\{ \lanes^{-1}_{t\K{x}N}(i^\ast) ~|~ i^\ast \in \Large\times\xref{Step_pure/instructions}{exec-instr-numeric}{\X{op}}_t(i_1,\dots,i_k)^\ast \land i_1^\ast = \lanes_{t\K{x}N}(n_1) \land \dots \land i_k^\ast = \lanes_{t\K{x}N}(n_k) \} \\
1610+
\end{array}
1611+
1612+
where :math:`\Large\times \{x^\ast\}^N` transforms a sequence of :math:`N` sets of values into a set of sequences of :math:`N` values by computing the set product:
1613+
1614+
.. math::
1615+
\begin{array}{lll}
1616+
\Large\times (S_1 \dots S_N) &=& \{ x_1 \dots x_N ~|~ x_1 \in S_1 \land \dots \land x_N \in S_N \}
1617+
\end{array}
1618+
16041619
16051620
.. _exec-vconst:
16061621

@@ -2335,9 +2350,9 @@ where:
23352350

23362351
3. Pop the value :math:`\V128.\VCONST~c_1` from the stack.
23372352

2338-
4. Let :math:`(i_1~i_2)^8` be the result of computing :math:`\irelaxeddotmul_{8, 16}(\lanes_{\I8X16}(c_1), \lanes_{\I8X16}(c_2))`
2353+
4. Let :math:`(i_1~i_2)^8` be the result of computing :math:`\irelaxeddotmul_{8,16}(\lanes_{\I8X16}(c_1), \lanes_{\I8X16}(c_2))`
23392354

2340-
5. Let :math:`j^8` be the result of computing :math:`\sats_{16}(i_1 + i_2)^8`.
2355+
5. Let :math:`j^8` be the result of computing :math:`\iaddsats_{16}(i_1, i_2)^8`.
23412356

23422357
6. Let :math:`c` be the result of computing :math:`\lanes^{-1}_{\I16X8}(j^8)`.
23432358

@@ -2351,7 +2366,7 @@ where:
23512366
\\ \qquad
23522367
\begin{array}[t]{@{}r@{~}l@{}}
23532368
(\iff & (i_1~i_2)^8 = \irelaxeddotmul_{8,16}(\lanes_{\I8X16}(c_1), \lanes_{\I8X16}(c_2)) \\
2354-
\wedge & j^8 = \sats_{16}(i_1, i_2)^8 \\
2369+
\wedge & j^8 = \iaddsats_{16}(i_1, i_2)^8 \\
23552370
\wedge & c = \lanes^{-1}_{\I16X8}(j^8))
23562371
\end{array}
23572372
\end{array}
@@ -2370,11 +2385,11 @@ where:
23702385

23712386
4. Pop the value :math:`\V128.\VCONST~c_1` from the stack.
23722387

2373-
5. Let :math:`(i_1~i_2)^8` be the result of computing :math:`\irelaxeddotmul_{8, 16}(\lanes_{\I8X16}(c_1), \lanes_{\I8X16}(c_2))`
2388+
5. Let :math:`(i_1~i_2)^8` be the result of computing :math:`\irelaxeddotmul_{8,16}(\lanes_{\I8X16}(c_1), \lanes_{\I8X16}(c_2))`
23742389

2375-
6. Let :math:`(j_1~j_2)^4` be the result of computing :math:`\sats_{16}(i_1 + i_2)^8`.
2390+
6. Let :math:`(j_1~j_2)^4` be the result of computing :math:`\iaddsats_{16}(i_1, i_2)^8`.
23762391

2377-
7. Let :math:`j^4` be the result of computing :math:`\iadd_{32}(\extend^{s}_{16, 32}(j_1), \extend^{s}_{16, 32}(j_2))^4`.
2392+
7. Let :math:`j^4` be the result of computing :math:`\iadd_{32}(\extends_{16,32}(j_1), \extends_{16,32}(j_2))^4`.
23782393

23792394
8. Let :math:`k^4` be the result of computing :math:`\lanes_{\I32X4}(c_3)`.
23802395

@@ -2392,8 +2407,8 @@ where:
23922407
\\ \qquad
23932408
\begin{array}[t]{@{}r@{~}l@{}}
23942409
(\iff & (i_1~i_2)^8 = \irelaxeddotmul_{8,16}(\lanes_{\I8X16}(c_1), \lanes_{\I8X16}(c_2)) \\
2395-
\wedge & (j_1~j_2)^4 = \sats_{16}(i_1 + i_2)^8 \\
2396-
\wedge & j^4 = \iadd_{32}(\extend^{s}_{16, 32}(j_1), \extend^{s}_{16, 32}(j_2))^4 \\
2410+
\wedge & (j_1~j_2)^4 = \iaddsats_{16}(i_1, i_2)^8 \\
2411+
\wedge & j^4 = \iadd_{32}(\extends_{16,32}(j_1), \extends_{16,32}(j_2))^4 \\
23972412
\wedge & k^4 = \lanes_{\I32X4}(c_3) \\
23982413
\wedge & l^4 = \iadd_{32}(j, k)^4 \\
23992414
\wedge & c = \lanes^{-1}_{\I32X4}(l^4))

document/core/exec/numerics.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,17 @@ Conventions:
8888

8989
.. math::
9090
\begin{array}{lll@{\qquad}l}
91-
\satu_N(i) &=& 2^N-1 & (\iff i > 2^N-1)\\
9291
\satu_N(i) &=& 0 & (\iff i < 0) \\
92+
\satu_N(i) &=& 2^N-1 & (\iff i > 2^N-1)\\
9393
\satu_N(i) &=& i & (\otherwise) \\
9494
\end{array}
9595
9696
* Signed saturation, :math:`\sats_N(i)` clamps :math:`i` to between :math:`-2^{N-1}` and :math:`2^{N-1}-1`:
9797

9898
.. math::
9999
\begin{array}{lll@{\qquad}l}
100-
\sats_N(i) &=& \signed_N^{-1}(-2^{N-1}) & (\iff i < -2^{N-1})\\
101-
\sats_N(i) &=& \signed_N^{-1}(2^{N-1}-1) & (\iff i > 2^{N-1}-1)\\
100+
\sats_N(i) &=& -2^{N-1} & (\iff i < -2^{N-1})\\
101+
\sats_N(i) &=& 2^{N-1}-1 & (\iff i > 2^{N-1}-1)\\
102102
\sats_N(i) &=& i & (\otherwise)
103103
\end{array}
104104
@@ -860,11 +860,11 @@ The integer result of predicates -- i.e., :ref:`tests <syntax-testop>` and :ref:
860860

861861
* Let :math:`j` be the result of adding :math:`j_1` and :math:`j_2`.
862862

863-
* Return :math:`\sats_N(j)`.
863+
* Return the value whose signed interpretation is :math:`\sats_N(j)`.
864864

865865
.. math::
866866
\begin{array}{lll@{\qquad}l}
867-
\iaddsats_N(i_1, i_2) &=& \sats_N(\signed_N(i_1) + \signed_N(i_2))
867+
\iaddsats_N(i_1, i_2) &=& \signed_N^{-1}(\sats_N(\signed_N(i_1) + \signed_N(i_2)))
868868
\end{array}
869869
870870
@@ -894,11 +894,11 @@ The integer result of predicates -- i.e., :ref:`tests <syntax-testop>` and :ref:
894894

895895
* Let :math:`j` be the result of subtracting :math:`j_2` from :math:`j_1`.
896896

897-
* Return :math:`\sats_N(j)`.
897+
* Return the value whose signed interpretation is :math:`\sats_N(j)`.
898898

899899
.. math::
900900
\begin{array}{lll@{\qquad}l}
901-
\isubsats_N(i_1, i_2) &=& \sats_N(\signed_N(i_1) - \signed_N(i_2))
901+
\isubsats_N(i_1, i_2) &=& \signed_N^{-1}(\sats_N(\signed_N(i_1) - \signed_N(i_2)))
902902
\end{array}
903903
904904
@@ -922,11 +922,11 @@ The integer result of predicates -- i.e., :ref:`tests <syntax-testop>` and :ref:
922922
:math:`\iq15mulrsats_N(i_1, i_2)`
923923
.................................
924924

925-
* Return the result of :math:`\sats_N(\ishrs_N(i_1 \cdot i_2 + 2^{14}, 15))`.
925+
* Return the whose signed interpretation is the result of :math:`\sats_N(\ishrs_N(i_1 \cdot i_2 + 2^{14}, 15))`.
926926

927927
.. math::
928928
\begin{array}{lll@{\qquad}l}
929-
\iq15mulrsats_N(i_1, i_2) &=& \sats_N(\ishrs_N(i_1 \cdot i_2 + 2^{14}, 15))
929+
\iq15mulrsats_N(i_1, i_2) &=& \signed_N^{-1}(\sats_N(\ishrs_N(i_1 \cdot i_2 + 2^{14}, 15)))
930930
\end{array}
931931
932932
@@ -1901,14 +1901,14 @@ Conversions
19011901

19021902
* Else if :math:`z` is positive infinity, then return :math:`2^{N-1} - 1`.
19031903

1904-
* Else, return :math:`\sats_N(\trunc(z))`.
1904+
* Else, return the value whose signed interpretation is :math:`\sats_N(\trunc(z))`.
19051905

19061906
.. math::
19071907
\begin{array}{lll@{\qquad}l}
19081908
\truncsats_{M,N}(\pm \NAN(n)) &=& 0 \\
19091909
\truncsats_{M,N}(- \infty) &=& -2^{N-1} \\
19101910
\truncsats_{M,N}(+ \infty) &=& 2^{N-1}-1 \\
1911-
\truncsats_{M,N}(z) &=& \sats_N(\trunc(z)) \\
1911+
\truncsats_{M,N}(z) &=& \signed_N^{-1}(\sats_N(\trunc(z))) \\
19121912
\end{array}
19131913
19141914
@@ -2006,11 +2006,11 @@ Conversions
20062006

20072007
* Let :math:`j` be the :ref:`signed interpretation <aux-signed>` of :math:`i` of size :math:`M`.
20082008

2009-
* Return :math:`\sats_N(j)`.
2009+
* Return the value whose signed interpretation is :math:`\sats_N(j)`.
20102010

20112011
.. math::
20122012
\begin{array}{lll@{\qquad}l}
2013-
\narrows_{M,N}(i) &=& \sats_N(\signed_M(i))
2013+
\narrows_{M,N}(i) &=& \signed_N^{-1}(\sats_N(\signed_M(i)))
20142014
\end{array}
20152015
20162016
@@ -2220,7 +2220,7 @@ The implementation-specific behaviour of this operation is determined by the glo
22202220
.. note::
22212221
Relaxed unsigned truncation is implementation-dependent for NaNs and out-of-range values.
22222222
In the :ref:`deterministic profile <profile-deterministic>`,
2223-
it behaves like regular :math:`\truncu`.
2223+
it behaves like regular :math:`\truncsatu`.
22242224

22252225

22262226
.. _op-relaxed_trunc_s:
@@ -2243,7 +2243,7 @@ The implementation-specific behaviour of this operation is determined by the glo
22432243
.. note::
22442244
Relaxed signed truncation is implementation-dependent for NaNs and out-of-range values.
22452245
In the :ref:`deterministic profile <profile-deterministic>`,
2246-
it behaves like regular :math:`\truncs`.
2246+
it behaves like regular :math:`\truncsats`.
22472247

22482248

22492249
.. _op-irelaxed_swizzle:

0 commit comments

Comments
 (0)