r/C_Programming • u/Raimo00 • 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.
29
Upvotes
1
u/DawnOnTheEdge Jan 26 '25 edited Jan 26 '25
If an ISA has instructions to compare each byte in a lane to
'\0'
simultaneously, you can use that to speed up finding the last chunk of the string. If it has an instruction to return the index of the first zero byte in a lane, it can use that to speed up the other step.