Debugging SIMD in LLDB

submited by
Style Pass
2024-03-30 20:00:02

Contrary to some opinions, it can be quite useful to have some visibility into what your code is doing1. Unfortunately, if you are writing x86 SIMD code (SSE or AVX), the support provided by gdb and lldb is not so great.

For starters, each SIMD register can be divided into multiple lanes. For example, a 128-bit wide register can be divided the following way:

The register doesn’t care what’s inside, it just holds 128 bits of data. The instructions that operate on the register, however, do care. It matters a lot if you want to add four 32-bit integers, or if you want to add sixteen 8-bit integers.

The ARM implementation of SIMD, called NEON, got it right when it comes to data types. Each of the possible lane splits has its own type, and the debugger knows how to print it. For example, the following variables:

Are printed out, as we would expect, as either 16 or 8 values, even though the underlying register is the same width in both cases:

Leave a Comment