SIMD for Beginners: Vectors, Lanes and Intrinsics
Learn what SIMD means, how a vector register splits into lanes, and how C intrinsics map to instructions, with a first program that adds four floats at once.

A normal instruction adds two numbers. A SIMD instruction adds two groups of numbers, with one operation, in the same time. SIMD stands for single instruction, multiple data, and it is built into almost every processor you use: x86-64 laptops and servers, Arm phones and Apple silicon, and many microcontrollers. This post explains the vocabulary for a beginner: vector registers, lanes, element types and intrinsics. It shows a first program in C that adds four floats with one instruction, and ends with a map of the instruction sets you will meet. Everything is checked against the Intel Intrinsics Guide and the Arm Intrinsics reference, and the example compiles with GCC 15 or Clang 20 on x86-64 with no extra flags, since SSE2 is part of the x86-64 baseline.
The idea in one picture
Imagine adding two arrays of four numbers. A scalar processor does four separate additions. A SIMD processor loads the four numbers from each array into one wide register, adds the two registers with a single instruction, and stores the four results. The instruction works on all four pairs at the same moment, because the hardware has four adders side by side.
The wide register is called a vector register. The slots inside it are called lanes. A 128-bit register holds four 32-bit floats, so it has four lanes, or sixteen 8-bit integers, so it has sixteen lanes. The same register can be viewed either way, and the instruction you choose decides how the 128 bits are split. addps adds four floats, and paddb adds sixteen bytes.
Two properties follow from the design. The operation is applied lane by lane, so lane 0 of the result depends only on lane 0 of each input, with no mixing between lanes. And all lanes execute the same operation, so a vector instruction cannot do one thing in lane 0 and a different thing in lane 1, which is why branches inside a SIMD loop turn into masks.
Register widths
| Instruction set | Platform | Register width | Floats per register |
|---|---|---|---|
| SSE, SSE2 | x86-64 | 128 bits | 4 |
| AVX, AVX2 | x86-64 | 256 bits | 8 |
| AVX-512 | some x86-64 | 512 bits | 16 |
| NEON | Arm, AArch64 | 128 bits | 4 |
| SVE, SVE2 | some AArch64 | 128 to 2048 bits, set by the hardware | varies |
| RISC-V V | RISC-V | implementation defined | varies |
SSE2 is guaranteed on every x86-64 processor, so code that uses 128-bit vectors runs anywhere. AVX2 is common on processors from the last decade but is not universal, so code that uses it must check at run time, as the next posts in this cluster show. NEON is mandatory on AArch64. Scalable designs such as SVE do not fix the width in the program, and the hardware vendor chooses it.
What intrinsics are
You can write SIMD in assembly language, but C compilers give you a friendlier path: intrinsics. An intrinsic is a function-like construct that the compiler replaces with a specific instruction, while still handling register allocation, scheduling and loop code for you. They are declared in headers, <immintrin.h> for x86 and <arm_neon.h> for Arm. The vector register types are also provided: __m128 is a 128-bit register of floats, __m128i a 128-bit register of integers, and on Arm float32x4_t is four floats.
The names are systematic. On x86, _mm_add_ps reads as: the SSE family (_mm), the operation (add), and the data type, where ps means packed single-precision floats. _mm_add_epi32 adds packed 32-bit integers, and _mm256_add_ps is the 256-bit AVX form. The Intel Intrinsics Guide lets you search by name or instruction and shows the data types, the instruction generated and its latency on several processors.
A first program
This program adds two arrays of four floats with one vector addition:
#include <stdio.h>
#include <xmmintrin.h> // SSE: __m128, _mm_loadu_ps, _mm_add_ps, _mm_storeu_ps
int main(void)
{
float a[4] = {1.0f, 2.0f, 3.0f, 4.0f};
float b[4] = {10.0f, 20.0f, 30.0f, 40.0f};
float c[4];
__m128 va = _mm_loadu_ps(a); // load 4 floats into a vector register
__m128 vb = _mm_loadu_ps(b);
__m128 vc = _mm_add_ps(va, vb); // 4 additions, one instruction
_mm_storeu_ps(c, vc); // store 4 floats
printf("%.1f %.1f %.1f %.1f\n", c[0], c[1], c[2], c[3]);
return 0;
}11.0 22.0 33.0 44.0Compile it with gcc -O2 simd_first.c -o simd_first, with no special flags, since SSE is part of the x86-64 baseline. The u in _mm_loadu_ps means unaligned: it accepts any address. The aligned version _mm_load_ps requires the address to be a multiple of 16 and crashes otherwise, so beginners should start with the unaligned form.
If you look at the assembly with gcc -O2 -S, the function body contains movups for each load, addps for the addition, and movups for the store. That one-to-one match between intrinsic and instruction is the point of intrinsics.
Lanes, not elements
The lane view helps you reason about code. In vc = _mm_add_ps(va, vb), lane 0 of vc is a[0] + b[0], lane 1 is a[1] + b[1], and so on. Memory order matches lane order: when you load four consecutive floats, a[0] goes to lane 0. This holds for the intrinsics on both x86 and Arm, which keeps array code simple.
Operations that move data between lanes are different and more expensive. Adding the four lanes of a single register together, a horizontal sum, needs shuffles or special instructions, and is much slower than an add between registers. A beginner's rule: keep the lanes independent for as long as you can. Sum an array by keeping four running sums in the four lanes, and combine the lanes only once at the end.
Why SIMD is not automatic
You might expect the compiler to do all of this for you, and often it does. GCC and Clang vectorize simple loops automatically at -O2 or -O3, and a later post in this cluster shows how to ask for it and check. Intrinsics matter when the compiler does not vectorize the loop, when you want a specific instruction, or when you need control over how data is arranged. They cost you portability: an _mm_add_ps line only builds on x86, and you need a separate version for Arm.
Common mistakes
Forgetting the tail. A vector loop processes four floats at a time, and an array of 10 floats leaves two over. You need a scalar loop for the remainder, or padded storage, as covered in the padding post of this cluster. Reading past the end of an array to fill a final vector is undefined behavior and may crash.
Mixing types. A __m128 holds floats, and a __m128i holds integers. The compiler lets you cast between them with _mm_castps_si128 when you want the bits reinterpreted. Passing the wrong type to an intrinsic is a compile error, which catches most mistakes early.
Assuming a feature exists. Calling an AVX2 intrinsic on a processor without AVX2 raises an illegal instruction fault. Check support with __builtin_cpu_supports("avx2") on GCC and Clang before you take the fast path.
Expecting a speedup from tiny work. Loading, adding and storing four floats costs about the same time as doing it for one float on a modern core, but only if the loop has enough work to hide the setup. Measure real loops, with real data sizes, before you decide that vectors are faster.
Where to go next
The next posts in this cluster write an SSE loop over a whole array, port it to AVX2, translate it to Arm NEON, and show how to get the compiler to vectorize loops for you. The complete guide in this cluster covers the whole subject in order. For reference, keep the Intel Intrinsics Guide and the Arm Intrinsics documentation open in a browser tab, because the instruction names are easier to look up than to memorize.


