← Back to context

Comment by pwdisswordfishq

15 hours ago

GNU C does the same: memory copies can be optimized into memcpy, various operations can be realized as calls into libgcc, etc.

And memcpy is kind of special to C/C++ compilers. Sure, it exists as a function, but it will often have special purpose code generated for that particular location.

It’s obvious why you want to inline memcpy, but the specialization is more interesting. For example, I’ve seen the compiler optimize a memcpy with a static number of bytes and then use SIMD registers to do the copying with no loop at all. It can even be smart enough to take advantage of memory alignment for this.

Those do for the most part correspond to operations which make sense in an embedded context, though.