Forwarding this to the list, in case someone else is curious why Crypto++
tends to avoid intrinsics in favor of inline assembly.
--------------------------------------------------
From: "Wei Dai"
A couple of reasons for not using intrinsics:
1. Many compilers tend to be buggy when compiling complex (or sometimes
even simple) intrinsics code. I suspect they don't test much on
intrinsics. I often write the first version using intrinsics and then are
forced to re-write in assembly because I can't work around the compiler
bugs.
2. GCC doesn't allow SSE2 intrinsics for example unless you
specify -msse2 or -march= where the microarchitecture supports SSE2, but
then it might generate SSE2 code even for non-intrinsic code that do not
go through CPU feature detection tests, which would cause a SIGILL on
non-SSE2 CPUs. Last night I ended up writing my own versions of some
intrinsic functions using inline assembly to work around this. See
http://www.kaourantin.net/2006/09/gcc-challenges.html for someone's blog
post complaining about this.
Oh, I'm not sure what you mean by MASM-specific assembly code. There might
be a misunderstanding there. I use some preprocessor tricks to generate
the MASM code from the .cpp files. So the MASM code is the same as the
inline assembly code, except for function prologues etc. I do this because
MSVC doesn't support inline assembly when compiling for x64.
Do you mind if I sent a copy of this to the Crypto++ mailing list, in case
someone else is curious?
--------------------------------------------------
From: "Samuel Neves"
One question, while we're at it. Is there a reason to use MASM-specific
assembly code instead of using compiler intrinsics for the same
functions? From what I've seen, most of it is MMX/SSE2, which is fully
supported by both GCC, MSVC and Intel's compiler. The exception would be
Baseline_Add/Sub, which makes use of the add-with-carry instructions
that are not available through instrinsics.
Is there a significant performance drop between intrinsic code and
hand-coded assembly?
Best regards,
Samuel Neves
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.