diff options
author | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2013-12-11 19:32:08 +0200 |
---|---|---|
committer | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2013-12-12 23:41:37 +0200 |
commit | e1a3931263e67aacec3c0bfcaa86c7d1441d5c6a (patch) | |
tree | e38a42a3222c07e83bf1e438e4d02092392fa221 /configure.ac | |
parent | 5e1239b1e2948211ff2675f45cce2b28c3379cfb (diff) | |
download | libgcrypt-e1a3931263e67aacec3c0bfcaa86c7d1441d5c6a.tar.gz |
SHA-256: Add SSSE3 implementation for x86-64
* cipher/Makefile.am: Add 'sha256-ssse3-amd64.S'.
* cipher/sha256-ssse3-amd64.S: New.
* cipher/sha256.c (USE_SSSE3): New.
(SHA256_CONTEXT) [USE_SSSE3]: Add 'use_ssse3'.
(sha256_init, sha224_init) [USE_SSSE3]: Initialize 'use_ssse3'.
(transform): Rename to...
(_transform): This.
[USE_SSSE3] (_gcry_sha256_transform_amd64_ssse3): New.
(transform): New.
* configure.ac (HAVE_INTEL_SYNTAX_PLATFORM_AS): New check.
(sha256): Add 'sha256-ssse3-amd64.lo'.
* doc/gcrypt.texi: Document 'intel-ssse3'.
* src/g10lib.h (HWF_INTEL_SSSE3): New.
* src/hwfeatures.c (hwflist): Add "intel-ssse3".
* src/hwf-x86.c (detect_x86_gnuc): Test for SSSE3.
--
Patch adds fast SSSE3 implementation of SHA-256 by Intel Corporation. The
assembly source is licensed under 3-clause BSD license, thus compatible
with LGPL2.1+. Original source can be accessed at:
http://www.intel.com/p/en_US/embedded/hwsw/technology/packet-processing#docs
Implementation is described in white paper
"Fast SHA - 256 Implementations on IntelĀ® Architecture Processors"
http://www.intel.com/content/www/us/en/intelligent-systems/intel-technology/sha-256-implementations-paper.html
Benchmarks:
cpu Old New Diff
Intel i5-4570 13.99 c/B 10.66 c/B 1.31x
Intel i5-2450M 21.53 c/B 15.79 c/B 1.36x
Intel Core2 T8100 20.84 c/B 15.07 c/B 1.38x
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 6d403436..97401c3a 100644 --- a/configure.ac +++ b/configure.ac @@ -1077,6 +1077,40 @@ fi # +# Check whether GCC assembler supports features needed for assembly +# implementations that use Intel syntax +# +AC_CACHE_CHECK([whether GCC assembler is compatible for Intel syntax assembly implementations], + [gcry_cv_gcc_platform_as_ok_for_intel_syntax], + [gcry_cv_gcc_platform_as_ok_for_intel_syntax=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [[__asm__( + ".intel_syntax noprefix\n\t" + "pxor xmm1, xmm7;\n\t" + /* Intel syntax implementation also use GAS macros, so check + * for them here. */ + "VAL_A = xmm4\n\t" + "VAL_B = xmm2\n\t" + ".macro SET_VAL_A p1\n\t" + " VAL_A = \\\\p1 \n\t" + ".endm\n\t" + ".macro SET_VAL_B p1\n\t" + " VAL_B = \\\\p1 \n\t" + ".endm\n\t" + "vmovdqa VAL_A, VAL_B;\n\t" + "SET_VAL_A eax\n\t" + "SET_VAL_B ebp\n\t" + "add VAL_A, VAL_B;\n\t" + "add VAL_B, 0b10101;\n\t" + );]])], + [gcry_cv_gcc_platform_as_ok_for_intel_syntax=yes])]) +if test "$gcry_cv_gcc_platform_as_ok_for_intel_syntax" = "yes" ; then + AC_DEFINE(HAVE_INTEL_SYNTAX_PLATFORM_AS,1, + [Defined if underlying assembler is compatible with Intel syntax assembly implementations]) +fi + + +# # Check whether compiler is configured for ARMv6 or newer architecture # AC_CACHE_CHECK([whether compiler is configured for ARMv6 or newer architecture], @@ -1676,6 +1710,13 @@ LIST_MEMBER(sha256, $enabled_digests) if test "$found" = "1" ; then GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo" AC_DEFINE(USE_SHA256, 1, [Defined if this module should be included]) + + case "${host}" in + x86_64-*-*) + # Build with the assembly implementation + GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256-ssse3-amd64.lo" + ;; + esac fi LIST_MEMBER(sha512, $enabled_digests) |