1 /* Copyright 2002 Andi Kleen, SuSE Labs */
3 #include <linux/linkage.h>
4 #include <asm/cpufeatures.h>
5 #include <asm/alternative-asm.h>
10 * ISO C memset - set a memory block to a byte value. This function uses fast
11 * string to get better performance than the original function. The code is
12 * simpler and shorter than the original function as well.
18 * rax original destination
23 * Some CPUs support enhanced REP MOVSB/STOSB feature. It is recommended
24 * to use it when possible. If not available, use fast string instructions.
26 * Otherwise, use original memset function.
28 ALTERNATIVE_2 "jmp memset_orig", "", X86_FEATURE_REP_GOOD, \
29 "jmp memset_erms", X86_FEATURE_ERMS
35 /* expand byte value */
37 movabs $0x0101010101010101,%rax
48 * ISO C memset - set a memory block to a byte value. This function uses
49 * enhanced rep stosb to override the fast string function.
50 * The code is simpler and shorter than the fast string function as well.
56 * rax original destination
70 /* expand byte value */
72 movabs $0x0101010101010101,%rax
79 .Lafter_bad_alignment:
99 /* Handle tail in loops. The loops should be faster than hard
100 to predict jump tables. */
131 movq %rax,(%rdi) /* unaligned store */
136 jmp .Lafter_bad_alignment