[PATCH 2/2] Disallow compiler from generating SSE instructions in mixed C+asm source

Jussi Kivilinna jussi.kivilinna at iki.fi
Sun Apr 26 13:47:30 CEST 2015


* cipher/cipher-gcm-intel-pclmul.c [gcc-version >= 4.4]: Add GCC target
pragma to disable compiler use of SSE.
* cipher/rijndael-aesni.c [gcc-version >= 4.4]: Ditto.
* cipher/rijndael-ssse3-amd64.c [gcc-version >= 4.4]: Ditto.
--

These implementations assume that compiler does not use XMM registers
between assembly blocks.

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 cipher/cipher-gcm-intel-pclmul.c |    7 +++++++
 cipher/rijndael-aesni.c          |    6 ++++++
 cipher/rijndael-ssse3-amd64.c    |    6 ++++++
 3 files changed, 19 insertions(+)

diff --git a/cipher/cipher-gcm-intel-pclmul.c b/cipher/cipher-gcm-intel-pclmul.c
index 0314458..446e6ad 100644
--- a/cipher/cipher-gcm-intel-pclmul.c
+++ b/cipher/cipher-gcm-intel-pclmul.c
@@ -32,6 +32,13 @@
 
 #ifdef GCM_USE_INTEL_PCLMUL
 
+
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
+/* Prevent compiler from issuing SSE instructions between asm blocks. */
+#  pragma GCC target("no-sse")
+#endif
+
+
 /*
  Intel PCLMUL ghash based on white paper:
   "Intel® Carry-Less Multiplication Instruction and its Usage for Computing the
diff --git a/cipher/rijndael-aesni.c b/cipher/rijndael-aesni.c
index 9a81602..15c799a 100644
--- a/cipher/rijndael-aesni.c
+++ b/cipher/rijndael-aesni.c
@@ -35,6 +35,12 @@
 #ifdef USE_AESNI
 
 
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
+/* Prevent compiler from issuing SSE instructions between asm blocks. */
+#  pragma GCC target("no-sse")
+#endif
+
+
 typedef struct u128_s { u32 a, b, c, d; } u128_t;
 
 
diff --git a/cipher/rijndael-ssse3-amd64.c b/cipher/rijndael-ssse3-amd64.c
index d72ec31..ebb640f 100644
--- a/cipher/rijndael-ssse3-amd64.c
+++ b/cipher/rijndael-ssse3-amd64.c
@@ -50,6 +50,12 @@
 #ifdef USE_SSSE3
 
 
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
+/* Prevent compiler from issuing SSE instructions between asm blocks. */
+#  pragma GCC target("no-sse")
+#endif
+
+
 /* Two macros to be called prior and after the use of SSSE3
   instructions.  There should be no external function calls between
   the use of these macros.  There purpose is to make sure that the




More information about the Gcrypt-devel mailing list