flâneur — a map of the web's best reading

LLVM is Smarter Than Me - sulami's blog

blog.sulami.xyz · 773 words · saved by 1 readers

I was reading Algorithms for Modern Hardware recently, specifically the chapter on SIMD, and was impressed by auto-vectorization. The basic idea is that modern CPUs have so-called SIMD1 instructions that allow applying an operation to several values at once, which is much faster than performing the equivalent scalar instructions one at a time. Modern compilers can detect certain programming patterns where an operation is performed repeatedly on scalar values and group the operations to make use of the faster instructions.2 The book uses primarily C++ for its examples, but I was curious if the same pattern would work in Rust as well, without having to manually annotate anything. So I opened up the compiler explorer and typed in my first test, which looked like this: To make sure I the compiler would feel safe to use SIMD instructions, I used -C opt-level=3 -C target-cpu=skylake, telling it that the target CPU supports them. But instead of SIMD instructions I got this assembly: Turns out

LLVM is Smarter Than Me Weak Opinions, Strongly Held Feed • Now • Uses • About LLVM is Smarter Than Me Published on 2024-04-19 Tags: rust , compilers I was reading Algorithms for Modern Hardware recently, specifically the chapter on SIMD , and was impressed by auto-vectorization. The basic idea is that modern CPUs have so-called SIMD 1 Single Instruction Multiple Data instructions that allow applying an operation to several values at once, which is much faster than performing the equivalent scalar instructions one at a time. Modern compilers can detect certain programming patterns where an ope

Explore this link on the map →

saved by

related reading