1 /* Copyright 2002 Andi Kleen, SuSE Labs */
3 #include <linux/linkage.h>
4 #include <asm/dwarf2.h>
5 #include <asm/cpufeature.h>
6 #include <asm/alternative-asm.h>
11 * ISO C memset - set a memory block to a byte value. This function uses fast
12 * string to get better performance than the original function. The code is
13 * simpler and shorter than the orignal function as well.
19 * rax original destination
24 * Some CPUs support enhanced REP MOVSB/STOSB feature. It is recommended
25 * to use it when possible. If not available, use fast string instructions.
27 * Otherwise, use original memset function.
29 ALTERNATIVE_2 "jmp memset_orig", "", X86_FEATURE_REP_GOOD, \
30 "jmp memset_erms", X86_FEATURE_ERMS
36 /* expand byte value */
38 movabs $0x0101010101010101,%rax
49 * ISO C memset - set a memory block to a byte value. This function uses
50 * enhanced rep stosb to override the fast string function.
51 * The code is simpler and shorter than the fast string function as well.
57 * rax original destination
72 /* expand byte value */
74 movabs $0x0101010101010101,%rax
82 .Lafter_bad_alignment:
102 /* Handle tail in loops. The loops should be faster than hard
103 to predict jump tables. */
135 movq %rax,(%rdi) /* unaligned store */
140 jmp .Lafter_bad_alignment