summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Naylor2025-06-16 02:27:15 +0000
committerJohn Naylor2025-06-16 02:27:15 +0000
commitf83f14881c7a09198863cb46033af8959a462d8b (patch)
tree22e2c031bd4c93831040da97d9715543cc6baafb
parentfd385c4c62d1762c88c0cdb145f354c834875dce (diff)
Workaround code generation bug in clang
At optimization level -O0, builds on recent clang fail to produce the correct CRC32C with our AVX-512 implementation. For now, just disable the runtime check for clang at -O0. When this is fixed upstream and we know the extent of the breakage, we can adjust to be version-specific. Reported-by: Soumyadeep Chakraborty <[email protected]> Reported-by: Andy Fan <[email protected]> Tested-by: Andy Fan <[email protected]> Discussion: https://postgr.es/m/CAE-ML%2B-OV6p9uvCFBcSQjZUEh__y0h-KjN%2BBseyGJHt7u8EP%2Bw%40mail.gmail.com Discussion: https://postgr.es/m/87o6uqd3iv.fsf%40163.com
-rw-r--r--src/port/pg_crc32c_sse42_choose.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/port/pg_crc32c_sse42_choose.c b/src/port/pg_crc32c_sse42_choose.c
index 74d2421ba2b..802e47788c1 100644
--- a/src/port/pg_crc32c_sse42_choose.c
+++ b/src/port/pg_crc32c_sse42_choose.c
@@ -95,7 +95,9 @@ pg_comp_crc32c_choose(pg_crc32c crc, const void *data, size_t len)
__cpuidex(exx, 7, 0);
#endif
-#ifdef USE_AVX512_CRC32C_WITH_RUNTIME_CHECK
+#if defined(__clang__) && !defined(__OPTIMIZE__)
+ /* Some versions of clang are broken at -O0 */
+#elif defined(USE_AVX512_CRC32C_WITH_RUNTIME_CHECK)
if (exx[2] & (1 << 10) && /* VPCLMULQDQ */
exx[1] & (1 << 31)) /* AVX512-VL */
pg_comp_crc32c = pg_comp_crc32c_avx512;