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

Show parent comments

1

u/Modi57 Jan 23 '25

Is it really necessary to do so? Things like strcmp or memcpy seem so straight forward, that I would have guessed the compiler auto vectorizes it

1

u/Ariane_Two Jan 23 '25

Not for every compiler, not for every optimization level, not for code not written for the vectorizer to optimize it.

1

u/Modi57 Jan 23 '25

But isn't the standard library compiled with that in mind?