[PATCH] D26890: SHA1: unroll loop in hashBlock.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 19 15:36:12 PST 2016


davide added subscribers: chandlerc, davide.
davide added inline comments.


================
Comment at: lib/Support/SHA1.cpp:12
+// (http://oauth.googlecode.com/svn/code/c/liboauth/src/sha1.c and
+// https://github.com/jsonn/src/blob/trunk/common/lib/libc/hash/sha1/sha1.c)
 // and modified by wrapping it in a C++ interface for LLVM,
----------------
I'd rather link the original NetBSD repo rather than Joerg's mirror (anoncvs.netbsd.org)


================
Comment at: lib/Support/SHA1.cpp:95-174
+  R0(a, b, c, d, e, 0);
+  R0(e, a, b, c, d, 1);
+  R0(d, e, a, b, c, 2);
+  R0(c, d, e, a, b, 3);
+  R0(b, c, d, e, a, 4);
+  R0(a, b, c, d, e, 5);
+  R0(e, a, b, c, d, 6);
----------------
I don't think this is terrible per-se (not quite readable), but @chandlerc pointed out during the DevSummit (at the libc++ performance BOF IIRC) that we should try to avoid unrolling loops by hand in our algorithms (and make sure the compiler does that on our behalf).
Now, for this case, I'm not sure if LLVM knows how to unroll this loop (and if it doesn't, I'm not sure how profitable it is to teach how to do it), but something to keep in mind in general.


https://reviews.llvm.org/D26890





More information about the llvm-commits mailing list