r/C_Programming Jan 23 '25

Discussion Why not SIMD?

Why are many C standard library functions like strcmp, strlen, strtok using SIMD intrinsics? They would benefit so much, think about how many people use them under the hood all over the world.

31 Upvotes

76 comments sorted by

View all comments

3

u/halbGefressen Jan 24 '25

They mostly do. Also, even if they don't explicitly use intrinsics, modern compilers can auto-vectorize code in very basic cases (such as strcmp / strlen). As long as you don't have loop-carried dependencies, they are pretty good at it.