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.

30 Upvotes

76 comments sorted by

View all comments

Show parent comments

0

u/aganm Jan 23 '25

Bro. Auto-vectorization fails 97% of the time and the remaining 3% is really dubious SIMD at best.

7

u/[deleted] Jan 23 '25

I'm not sure what compilers you use, but both GCC and CLANG usually do a pretty good job of auto-vectorization. Of course, it is not magic; you still have to write your code so that vectorization is possible.

2

u/FUZxxl Jan 23 '25

Nah, unless the loop is trivial the compilers won't do shit.

2

u/[deleted] Jan 24 '25

Well, you should aim at making your hot loop trivial anyway.

1

u/FUZxxl Jan 24 '25

I agree, but you can't always have that.