aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJussi Kivilinna <[email protected]>2022-02-24 19:28:15 +0200
committerJussi Kivilinna <[email protected]>2022-02-24 19:36:13 +0200
commit6951e0f591ccff24b9ce2e43c2dcab955e3302c4 (patch)
tree8c72a6247f6de0c511b2f1c53c8248b2207cf880
parentd8825601f10aec20db118496bb68a5cd1372b7da (diff)
downloadlibgcrypt-6951e0f591ccff24b9ce2e43c2dcab955e3302c4.tar.gz
libgcrypt-6951e0f591ccff24b9ce2e43c2dcab955e3302c4.tar.bz2
libgcrypt-6951e0f591ccff24b9ce2e43c2dcab955e3302c4.zip
powerpc: check for missing optimization level for vector register usage
* cipher/Makefile.am [ENABLE_PPC_VCRYPTO_EXTRA_CFLAGS] (ppc_vcrypto_cflags): Add '-O2'. * configure.ac (gcry_cv_cc_ppc_altivec): Check for missing compiler optimization with vec_sld_u32 inline function. * configure.ac (gcry_cv_cc_ppc_altivec_cflags): Check for missing compiler optimization with vec_sld_u32 inline function; Add '-O2' to CFLAGS. -- Attempt to enable optimization for PPC vector register implementations if PPC altivec check does not pass otherwise. GnuPG-bug-id: T5785 Signed-off-by: Jussi Kivilinna <[email protected]>
-rw-r--r--cipher/Makefile.am2
-rw-r--r--configure.ac16
2 files changed, 15 insertions, 3 deletions
diff --git a/cipher/Makefile.am b/cipher/Makefile.am
index 6c1c7693..a7cbf3fc 100644
--- a/cipher/Makefile.am
+++ b/cipher/Makefile.am
@@ -222,7 +222,7 @@ crc-intel-pclmul.lo: $(srcdir)/crc-intel-pclmul.c Makefile
`echo $(LTCOMPILE) -c $< | $(instrumentation_munging) `
if ENABLE_PPC_VCRYPTO_EXTRA_CFLAGS
-ppc_vcrypto_cflags = -maltivec -mvsx -mcrypto
+ppc_vcrypto_cflags = -O2 -maltivec -mvsx -mcrypto
else
ppc_vcrypto_cflags =
endif
diff --git a/configure.ac b/configure.ac
index 89df9434..f5363f22 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1909,7 +1909,7 @@ fi
#
# Check whether PowerPC AltiVec/VSX intrinsics
#
-AC_CACHE_CHECK([whether compiler supports PowerPC AltiVec/VSX intrinsics],
+AC_CACHE_CHECK([whether compiler supports PowerPC AltiVec/VSX/crypto intrinsics],
[gcry_cv_cc_ppc_altivec],
[if test "$mpi_cpu_arch" != "ppc" ||
test "$try_asm_modules" != "yes" ; then
@@ -1920,10 +1920,16 @@ AC_CACHE_CHECK([whether compiler supports PowerPC AltiVec/VSX intrinsics],
[[#include <altivec.h>
typedef vector unsigned char block;
typedef vector unsigned int vecu32;
+ static inline __attribute__((always_inline)) vecu32
+ vec_sld_u32(vecu32 a, vecu32 b, unsigned int idx)
+ {
+ return vec_sld (a, b, (4 * idx) & 15);
+ }
block fn(block in)
{
block t = vec_perm (in, in, vec_vsx_ld (0, (unsigned char*)0));
vecu32 y = vec_vsx_ld (0, (unsigned int*)0);
+ y = vec_sld_u32 (y, y, 3);
return vec_cipher_be (t, in) ^ (block)y;
}
]])],
@@ -1935,7 +1941,7 @@ if test "$gcry_cv_cc_ppc_altivec" = "yes" ; then
fi
_gcc_cflags_save=$CFLAGS
-CFLAGS="$CFLAGS -maltivec -mvsx -mcrypto"
+CFLAGS="$CFLAGS -O2 -maltivec -mvsx -mcrypto"
if test "$gcry_cv_cc_ppc_altivec" = "no" &&
test "$mpi_cpu_arch" = "ppc" &&
@@ -1947,10 +1953,16 @@ if test "$gcry_cv_cc_ppc_altivec" = "no" &&
[[#include <altivec.h>
typedef vector unsigned char block;
typedef vector unsigned int vecu32;
+ static inline __attribute__((always_inline)) vecu32
+ vec_sld_u32(vecu32 a, vecu32 b, unsigned int idx)
+ {
+ return vec_sld (a, b, (4 * idx) & 15);
+ }
block fn(block in)
{
block t = vec_perm (in, in, vec_vsx_ld (0, (unsigned char*)0));
vecu32 y = vec_vsx_ld (0, (unsigned int*)0);
+ y = vec_sld_u32 (y, y, 3);
return vec_cipher_be (t, in) ^ (block)y;
}]])],
[gcry_cv_cc_ppc_altivec_cflags=yes])])