Inline memove for small constant sizes and refactor memcpy and memset.
The memory intrinsics are only optimized at -O1 and higher unless the
-fmem-intrin-opt flag is set to force to optimization to take place.
This change also introduces the xchg instruction for two register operands. This
is no longer used in the memory intrinsic lowering (or by anything else) but the
implementation is left for future use.
BUG=
R=jvoung@chromium.org, stichnot@chromium.org
Review URL: https://codereview.chromium.org/1278173009.
diff --git a/crosstest/mem_intrin_main.cpp b/crosstest/mem_intrin_main.cpp
index e1102ec..3b5135d 100644
--- a/crosstest/mem_intrin_main.cpp
+++ b/crosstest/mem_intrin_main.cpp
@@ -14,27 +14,6 @@
#define XSTR(s) STR(s)
#define STR(s) #s
-void testFixedLen(SizeT &TotalTests, SizeT &Passes, SizeT &Failures) {
-#define do_test_fixed(test_func) \
- for (uint8_t init_val = 0; init_val < 100; ++init_val) { \
- ++TotalTests; \
- int llc_result = test_func(init_val); \
- int sz_result = Subzero_::test_func(init_val); \
- if (llc_result == sz_result) { \
- ++Passes; \
- } else { \
- ++Failures; \
- printf("Failure (%s): init_val=%d, llc=%d, sz=%d\n", STR(test_func), \
- init_val, llc_result, sz_result); \
- } \
- }
-
- do_test_fixed(memcpy_test_fixed_len);
- do_test_fixed(memmove_test_fixed_len);
- do_test_fixed(memset_test_fixed_len)
-#undef do_test_fixed
-}
-
void testVariableLen(SizeT &TotalTests, SizeT &Passes, SizeT &Failures) {
uint8_t buf[256];
uint8_t buf2[256];
@@ -60,6 +39,30 @@
#undef do_test_variable
}
+void testFixedLen(SizeT &TotalTests, SizeT &Passes, SizeT &Failures) {
+#define do_test_fixed(test_func, NBYTES) \
+ for (uint8_t init_val = 0; init_val < 100; ++init_val) { \
+ ++TotalTests; \
+ int llc_result = test_func##_##NBYTES(init_val); \
+ int sz_result = Subzero_::test_func##_##NBYTES(init_val); \
+ if (llc_result == sz_result) { \
+ ++Passes; \
+ } else { \
+ ++Failures; \
+ printf("Failure (%s): init_val=%d, len=%d, llc=%d, sz=%d\n", \
+ STR(test_func), init_val, NBYTES, llc_result, sz_result); \
+ } \
+ }
+
+#define X(NBYTES) \
+ do_test_fixed(memcpy_test_fixed_len, NBYTES); \
+ do_test_fixed(memmove_test_fixed_len, NBYTES); \
+ do_test_fixed(memset_test_fixed_len, NBYTES);
+ MEMINTRIN_SIZE_TABLE
+#undef X
+#undef do_test_fixed
+}
+
#ifdef X8664_STACK_HACK
extern "C" int wrapped_main(int argc, char *argv[]) {
#else // !defined(X8664_STACK_HACK)