Optimization method of memcpy function

The invention discloses an optimization method of a memcpy function. The optimization method of the memcpy function comprises the following steps of 1) copying data to be copied of a len length through a single-byte copy instruction, and enabling at least one of a source address/destination address to meet N-byte alignment, wherein N is the number of bytes which an instruction of the highest bit width in a system can process at a time, namely, after the copy, the source address/destination address meets (x, N) alignment or (N, x) alignment, and x is 1, 2, ...,N; 2) for the (x, N) alignment or the (N, x) alignment, reading data from the source address through x-byte instructions or N-byte instructions to store the data in a register, reading data from the register through the N-byte instructions or the x-byte instruction to store the data into the destination address, and copying the remaining data to be copied through the single-byte copy instruction when the remaining data to be copied is less than N bytes. According to the optimization method of the memcpy function, the instructions of the bit width as high as possible are utilized for copying, and the copy efficiency is improved.