summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulio Magno Quites Machado Filho <tuliom@linux.ibm.com>2020-03-26 13:13:31 +1100
committerAnel Husakovic <anel@mariadb.org>2020-04-02 07:31:27 +0200
commitcc5462567487054f47b380062f4303f83c902b66 (patch)
tree8a1dc986ccd72fc04f4ace57b4dd4c756839b9ab
parentb40b3720cbba133ee76ef336bf89bbf5c03ac403 (diff)
downloadmariadb-git-bb-10.3-anel-PR1477.tar.gz
MDEV-21984: POWER crc32 acceleration - fix clang's behavior on versions >= 7bb-10.3-anel-PR1477
Clang 7 changed the behavior of vec_xxpermdi in order to match GCC's behavior. After this change, code that used to work on Clang 6 stopped to work on Clang >= 7. Tested on Clang 6, 7, 8 and 9. Reference: https://bugs.llvm.org/show_bug.cgi?id=38192 Upstream fix: https://github.com/antonblanchard/crc32-vpmsum/commit/361aaf77a599995e23acd50c9c50d48d30c69241 PR 1477
-rw-r--r--extra/crc32-vpmsum/clang_workaround.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/extra/crc32-vpmsum/clang_workaround.h b/extra/crc32-vpmsum/clang_workaround.h
index b5e7dae011c..915f7e5282f 100644
--- a/extra/crc32-vpmsum/clang_workaround.h
+++ b/extra/crc32-vpmsum/clang_workaround.h
@@ -39,7 +39,12 @@ __vector unsigned long long __builtin_pack_vector (unsigned long __a,
return __v;
}
-#ifndef vec_xxpermdi
+/*
+ * Clang 7 changed the behavior of vec_xxpermdi in order to provide the same
+ * behavior of GCC. That means code adapted to Clang >= 7 does not work on
+ * Clang <= 6. So, fallback to __builtin_unpack_vector() on Clang <= 6.
+ */
+#if !defined vec_xxpermdi || __clang_major__ <= 6
static inline
unsigned long __builtin_unpack_vector (__vector unsigned long long __v,
@@ -62,9 +67,9 @@ static inline
unsigned long __builtin_unpack_vector_0 (__vector unsigned long long __v)
{
#if defined(__BIG_ENDIAN__)
- return vec_xxpermdi(__v, __v, 0x0)[1];
- #else
return vec_xxpermdi(__v, __v, 0x0)[0];
+ #else
+ return vec_xxpermdi(__v, __v, 0x3)[0];
#endif
}
@@ -72,9 +77,9 @@ static inline
unsigned long __builtin_unpack_vector_1 (__vector unsigned long long __v)
{
#if defined(__BIG_ENDIAN__)
- return vec_xxpermdi(__v, __v, 0x3)[1];
- #else
return vec_xxpermdi(__v, __v, 0x3)[0];
+ #else
+ return vec_xxpermdi(__v, __v, 0x0)[0];
#endif
}
#endif /* vec_xxpermdi */