Introduction
Two small extensions to SSE2 share this page. Both use the XMM registers and MXCSR, as SSE does.
- SSE3 came with the Pentium 4 core called Prescott, in 2004. It
adds floating-point instructions that work across a register (horizontal addition,
alternating addition and subtraction), moves that duplicate elements, and
lddqu. The same extension broughtmonitorandmwait, and the x87 instructionfisttp, which are described on their own pages. A program checks for SSE3 with CPUID leaf 1: ECX bit 0. - SSSE3 (Supplemental SSE3) came with the Core 2 in 2006. It adds
sixteen integer instructions, among them
pshufb, the byte shuffle, andpalignr. Each has a form on the 64-bit MMX registers with no prefix and a 128-bit form on the XMM registers with a 66 prefix; both forms are SSSE3. They live in the three-byte opcode maps 0F 38 and 0F 3A. A program checks for SSSE3 with CPUID leaf 1: ECX bit 9.
The 128-bit forms have VEX forms, which came with AVX; their names start with
v and they are described on the AVX
page. Each row below links to it.
The instructions
In the forms, xmm1 is the ModRM.reg operand and
xmm2/m128 the ModRM.r/m operand. NP means that no 66, F2 or
F3 prefix may be present.
SSE3: floating-point arithmetic
| Instruction | Forms | Encoding | What it does | Set |
|---|---|---|---|---|
addsubps | xmm1, xmm2/m128 | F2 0F D0 /r | Subtracts in elements 0 and 2 and adds in elements 1 and 3, single precision. Useful for complex multiplication. VEX form: vaddsubps. | SSE3 (Intel Pentium 4 (Prescott), 2004) |
addsubpd | xmm1, xmm2/m128 | 66 0F D0 /r | Subtracts in element 0 and adds in element 1, double precision. VEX form: vaddsubpd. | SSE3 (Intel Pentium 4 (Prescott), 2004) |
haddps | xmm1, xmm2/m128 | F2 0F 7C /r | Adds adjacent pairs: the first operand’s two sums fill the low half, the second operand’s the high half. VEX form: vhaddps. | SSE3 (Intel Pentium 4 (Prescott), 2004) |
haddpd | xmm1, xmm2/m128 | 66 0F 7C /r | The sum of the first operand’s two values goes low, the second operand’s sum high. VEX form: vhaddpd. | SSE3 (Intel Pentium 4 (Prescott), 2004) |
hsubps | xmm1, xmm2/m128 | F2 0F 7D /r | As haddps, subtracting the higher element of each pair from the lower. VEX form: vhsubps. | SSE3 (Intel Pentium 4 (Prescott), 2004) |
hsubpd | xmm1, xmm2/m128 | 66 0F 7D /r | As haddpd, subtracting. VEX form: vhsubpd. | SSE3 (Intel Pentium 4 (Prescott), 2004) |
SSE3: moves
| Instruction | Forms | Encoding | What it does | Set |
|---|---|---|---|---|
movsldup | xmm1, xmm2/m128 | F3 0F 12 /r | Copies the even single-precision elements into both places of each pair: s0, s0, s2, s2. VEX form: vmovsldup. | SSE3 (Intel Pentium 4 (Prescott), 2004) |
movshdup | xmm1, xmm2/m128 | F3 0F 16 /r | Copies the odd elements: s1, s1, s3, s3. VEX form: vmovshdup. | SSE3 (Intel Pentium 4 (Prescott), 2004) |
movddup | xmm1, xmm2/m64 | F2 0F 12 /r | Copies the low double-precision value into both halves. Reads 64 bits from memory. VEX form: vmovddup. | SSE3 (Intel Pentium 4 (Prescott), 2004) |
lddqu | xmm1, m128 | F2 0F F0 /r | Loads 128 unaligned bits. It may read a larger aligned block, which can be faster than movdqu when the data crosses a cache-line boundary. Not for uncacheable or write-combining memory. VEX form: vlddqu. | SSE3 (Intel Pentium 4 (Prescott), 2004) |
SSSE3: shuffles and alignment
Each SSSE3 row has two forms: the first on MMX registers (mm1, mm2/m64),
the second on XMM registers (xmm1, xmm2/m128).
| Instruction | Forms | Encoding | What it does | Set |
|---|---|---|---|---|
pshufb | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 00 /r66 0F 38 00 /r | Shuffles bytes: each byte of the second operand picks a byte of the first by its low bits (3 bits for MMX, 4 for XMM), or zeroes the result byte if its top bit is set. VEX form: vpshufb. | SSSE3 (Intel Core 2, 2006) |
palignr | mm1, mm2/m64, imm8xmm1, xmm2/m128, imm8 | NP 0F 3A 0F /r ib66 0F 3A 0F /r ib | Joins the first operand (high) and the second (low) into a value twice as wide, shifts it right by imm8 bytes and keeps the low half. VEX form: vpalignr. | SSSE3 (Intel Core 2, 2006) |
SSSE3: horizontal arithmetic
| Instruction | Forms | Encoding | What it does | Set |
|---|---|---|---|---|
phaddw | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 01 /r66 0F 38 01 /r | Adds adjacent pairs of words, wrapping around: the first operand’s sums fill the low half, the second operand’s the high half. VEX form: vphaddw. | SSSE3 (Intel Core 2, 2006) |
phaddd | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 02 /r66 0F 38 02 /r | The same for doublewords. VEX form: vphaddd. | SSSE3 (Intel Core 2, 2006) |
phaddsw | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 03 /r66 0F 38 03 /r | Adds adjacent pairs of signed words with saturation. VEX form: vphaddsw. | SSSE3 (Intel Core 2, 2006) |
phsubw | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 05 /r66 0F 38 05 /r | Subtracts the higher word of each adjacent pair from the lower, wrapping around. VEX form: vphsubw. | SSSE3 (Intel Core 2, 2006) |
phsubd | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 06 /r66 0F 38 06 /r | The same for doublewords. VEX form: vphsubd. | SSSE3 (Intel Core 2, 2006) |
phsubsw | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 07 /r66 0F 38 07 /r | Subtracts adjacent pairs of signed words with saturation. VEX form: vphsubsw. | SSSE3 (Intel Core 2, 2006) |
SSSE3: multiplication, signs and absolute values
| Instruction | Forms | Encoding | What it does | Set |
|---|---|---|---|---|
pmaddubsw | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 04 /r66 0F 38 04 /r | Multiplies the unsigned bytes of the first operand by the signed bytes of the second and adds each adjacent pair of products into a signed word, with saturation. VEX form: vpmaddubsw. | SSSE3 (Intel Core 2, 2006) |
pmulhrsw | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 0B /r66 0F 38 0B /r | Multiplies signed words and keeps bits 16:1 of each product after adding a rounding bit: ((a × b >> 14) + 1) >> 1. A fixed-point (Q15) multiply. VEX form: vpmulhrsw. | SSSE3 (Intel Core 2, 2006) |
psignb | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 08 /r66 0F 38 08 /r | Negates each byte of the first operand where the second operand’s byte is negative, zeroes it where that byte is zero, and keeps it where it is positive. VEX form: vpsignb. | SSSE3 (Intel Core 2, 2006) |
psignw | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 09 /r66 0F 38 09 /r | The same for words. VEX form: vpsignw. | SSSE3 (Intel Core 2, 2006) |
psignd | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 0A /r66 0F 38 0A /r | The same for doublewords. VEX form: vpsignd. | SSSE3 (Intel Core 2, 2006) |
pabsb | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 1C /r66 0F 38 1C /r | Absolute values of the source’s signed bytes, as unsigned bytes (−128 gives 128). VEX form: vpabsb. | SSSE3 (Intel Core 2, 2006) |
pabsw | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 1D /r66 0F 38 1D /r | The same for words. VEX form: vpabsw. | SSSE3 (Intel Core 2, 2006) |
pabsd | mm1, mm2/m64xmm1, xmm2/m128 | NP 0F 38 1E /r66 0F 38 1E /r | The same for doublewords. VEX form: vpabsd. | SSSE3 (Intel Core 2, 2006) |
Notes
- Alignment. In the legacy encodings a 128-bit memory operand must
be 16-byte aligned, or the instruction raises #GP;
lddquandmovddup’s 64-bit operand are the exceptions. The 64-bit MMX forms have no alignment rule. - MMX state. The MMX forms of SSSE3 use the x87 register stack as
the other MMX instructions do: a program must run
emmsbefore x87 code. - Exceptions. The SSE3 floating-point instructions set the exception flags in MXCSR, as SSE’s do. The SSSE3 instructions are integer instructions and raise no floating-point exceptions.
- Decoding. SSSE3 forms take no F2 or F3 prefix. With one, Intel’s manual calls the encoding reserved; LLVM, and so the disassembler, decodes the instruction as if the prefix were not there.
Links
Reference
- Intel 64 and IA-32 Architectures Software Developer’s Manuals – Intel’s manuals; volume 2 describes each instruction, volume 1 chapter 12 describes SSE3 and SSSE3
- AMD64 Architecture Programmer’s Manual, Volume 4 – AMD’s reference to the 128-bit, 256-bit and 512-bit media instructions
- x86 and amd64 instruction reference – Félix Cloutier’s web copy of the instruction pages of Intel’s manual