------- Comment #5 from pinskia at gcc dot gnu dot org 2007-04-30 17:25 ------- > AFAIK the libc memset/cpy choose the algorithm depending the the size etc., so > you have to do a big block to make up for all the overhead. But what could be > done for small multidimensional arrays would be to "flatten" the nested loops > into the equivalent 1D loop? Perhaps this is something better done in the > middle end?
Well libc's memcpy/memset does optimize by size but the compiler also optimizes memcpy/memset if the size is constant and also based on the alignment so it could optimize it down to two instructions instead of a couple (and on PPC, with -maltivec, GCC can optimize using VMX also which makes the instruction count go down even more). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31016