Commit 6d125697 authored by Daniel Black's avatar Daniel Black

MDEV-9872: crc32 initialization (innodb/xtradb)

Reorder logic as suggested by Svoj.
Signed-off-by: default avatarDaniel Black <daniel.black@au.ibm.com>
parent ba6af68c
...@@ -699,9 +699,13 @@ void ...@@ -699,9 +699,13 @@ void
ut_crc32_init() ut_crc32_init()
/*===========*/ /*===========*/
{ {
bool ut_crc32_sse2_enabled = false; ut_crc32_slice8_table_init();
bool ut_crc32_power8_enabled = false; ut_crc32 = ut_crc32_sw;
#if defined(__GNUC__) && defined(__x86_64__) ut_crc32_legacy_big_endian = ut_crc32_legacy_big_endian_sw;
ut_crc32_byte_by_byte = ut_crc32_byte_by_byte_sw;
ut_crc32_implementation = "Using generic crc32 instructions";
#if defined(__GNUC__) && defined(__x86_64__) && !defined(UNIV_DEBUG_VALGRIND)
uint32_t vend[3]; uint32_t vend[3];
uint32_t model; uint32_t model;
uint32_t family; uint32_t family;
...@@ -728,30 +732,17 @@ ut_crc32_init() ...@@ -728,30 +732,17 @@ ut_crc32_init()
probably kill your program. probably kill your program.
*/ */
#ifndef UNIV_DEBUG_VALGRIND
ut_crc32_sse2_enabled = (features_ecx >> 20) & 1;
#endif /* UNIV_DEBUG_VALGRIND */
if (ut_crc32_sse2_enabled) { if ((features_ecx >> 20) & 1) {
ut_crc32 = ut_crc32_hw; ut_crc32 = ut_crc32_hw;
ut_crc32_legacy_big_endian = ut_crc32_legacy_big_endian_hw; ut_crc32_legacy_big_endian = ut_crc32_legacy_big_endian_hw;
ut_crc32_byte_by_byte = ut_crc32_byte_by_byte_hw; ut_crc32_byte_by_byte = ut_crc32_byte_by_byte_hw;
ut_crc32_implementation = "Using SSE2 crc32 instructions"; ut_crc32_implementation = "Using SSE2 crc32 instructions";
} }
#endif /* defined(__GNUC__) && defined(__x86_64__) */ #elif defined(HAVE_CRC32_VPMSUM)
#ifdef HAVE_CRC32_VPMSUM
ut_crc32_power8_enabled = true;
ut_crc32 = ut_crc32_power8; ut_crc32 = ut_crc32_power8;
ut_crc32_implementation = "Using POWER8 crc32 instructions"; ut_crc32_implementation = "Using POWER8 crc32 instructions";
#endif #endif
if (!ut_crc32_sse2_enabled && !ut_crc32_power8_enabled) {
ut_crc32_slice8_table_init();
ut_crc32 = ut_crc32_sw;
ut_crc32_legacy_big_endian = ut_crc32_legacy_big_endian_sw;
ut_crc32_byte_by_byte = ut_crc32_byte_by_byte_sw;
ut_crc32_implementation = "Using generic crc32 instructions";
}
} }
...@@ -299,8 +299,11 @@ void ...@@ -299,8 +299,11 @@ void
ut_crc32_init() ut_crc32_init()
/*===========*/ /*===========*/
{ {
bool ut_crc32_sse2_enabled = false; ut_crc32_slice8_table_init();
#if defined(__GNUC__) && defined(__x86_64__) ut_crc32 = ut_crc32_slice8;
ut_crc32_implementation = "Using generic crc32 instructions";
#if defined(__GNUC__) && defined(__x86_64__) && !defined(UNIV_DEBUG_VALGRIND)
ib_uint32_t vend[3]; ib_uint32_t vend[3];
ib_uint32_t model; ib_uint32_t model;
ib_uint32_t family; ib_uint32_t family;
...@@ -327,23 +330,13 @@ ut_crc32_init() ...@@ -327,23 +330,13 @@ ut_crc32_init()
probably kill your program. probably kill your program.
*/ */
#ifndef UNIV_DEBUG_VALGRIND if ((features_ecx >> 20) & 1) {
ut_crc32_sse2_enabled = (features_ecx >> 20) & 1;
#endif /* UNIV_DEBUG_VALGRIND */
#endif /* defined(__GNUC__) && defined(__x86_64__) */
#ifdef HAVE_CRC32_VPMSUM
ut_crc32 = ut_crc32_power8;
ut_crc32_implementation = "Using POWER8 crc32 instructions";
#else
if (ut_crc32_sse2_enabled) {
ut_crc32 = ut_crc32_sse42; ut_crc32 = ut_crc32_sse42;
ut_crc32_implementation = "Using SSE2 crc32 instructions"; ut_crc32_implementation = "Using SSE2 crc32 instructions";
} else {
ut_crc32_slice8_table_init();
ut_crc32 = ut_crc32_slice8;
ut_crc32_implementation = "Using generic crc32 instructions";
} }
#elif defined(HAVE_CRC32_VPMSUM)
ut_crc32 = ut_crc32_power8;
ut_crc32_implementation = "Using POWER8 crc32 instructions";
#endif #endif
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment