Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: crosstest/mem_intrin_main.cpp

Issue 1278173009: Inline memove for small constant sizes and refactor memcpy and memset. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Simplify xtests and add flags for memory intrinsic optimization. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: crosstest/mem_intrin_main.cpp
diff --git a/crosstest/mem_intrin_main.cpp b/crosstest/mem_intrin_main.cpp
index 70e3a6784a16c371b27974c6f1f4260e189fdcf3..0ea8adca1b918f13b490c7409c65918c66bb3b15 100644
--- a/crosstest/mem_intrin_main.cpp
+++ b/crosstest/mem_intrin_main.cpp
@@ -12,27 +12,6 @@ namespace Subzero_ {
#define XSTR(s) STR(s)
#define STR(s) #s
-void testFixedLen(size_t &TotalTests, size_t &Passes, size_t &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(size_t &TotalTests, size_t &Passes, size_t &Failures) {
uint8_t buf[256];
uint8_t buf2[256];
@@ -58,6 +37,30 @@ void testVariableLen(size_t &TotalTests, size_t &Passes, size_t &Failures) {
#undef do_test_variable
}
+void testFixedLen(size_t &TotalTests, size_t &Passes, size_t &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);
+ VALUES
+#undef X
+#undef do_test_fixed
+}
+
int main(int argc, char **argv) {
unsigned TotalTests = 0;
unsigned Passes = 0;

Powered by Google App Engine
This is Rietveld 408576698