public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] small sha512 cleanup
@ 2004-10-01 19:31 Denis Vlasenko
  2004-10-01 20:38 ` [PATCH] reduce sha512_transform() stack usage, speedup Denis Vlasenko
  0 siblings, 1 reply; 4+ messages in thread
From: Denis Vlasenko @ 2004-10-01 19:31 UTC (permalink / raw)
  To: jmorris, davem; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 299 bytes --]

Looks like open-coded be_to_cpu.
GCC produces rather poor code for this.
be_to_cpu produces asm()s which are ~4 times shorter.

Compile-tested only.

I am not sure whether input can be 64bit-unaligned.
If it indeed can be, replace:

((u64*)(input))[I]  ->  get_unaligned( ((u64*)(input))+I )
--
vda

[-- Attachment #2: sha512.c.diff --]
[-- Type: text/x-diff, Size: 1004 bytes --]

Replaces tons of GCC-produced horror code
with nice small one.
While we're at it, fix whitespace.

--- linux-2.6.9-rc3/crypto/sha512.c.org	Thu Sep 30 07:09:44 2004
+++ linux-2.6.9-rc3/crypto/sha512.c	Thu Sep 30 07:10:36 2004
@@ -104,27 +104,12 @@
 
 static inline void LOAD_OP(int I, u64 *W, const u8 *input)
 {
-        u64 t1  = input[(8*I)  ] & 0xff;
-        t1 <<= 8;
-        t1 |= input[(8*I)+1] & 0xff;
-        t1 <<= 8;
-        t1 |= input[(8*I)+2] & 0xff;
-        t1 <<= 8;
-        t1 |= input[(8*I)+3] & 0xff;
-        t1 <<= 8;
-        t1 |= input[(8*I)+4] & 0xff;
-        t1 <<= 8;
-        t1 |= input[(8*I)+5] & 0xff;
-        t1 <<= 8;
-        t1 |= input[(8*I)+6] & 0xff;
-        t1 <<= 8;
-        t1 |= input[(8*I)+7] & 0xff;
-        W[I] = t1;
+	W[I] = __be64_to_cpu( ((u64*)(input))[I] );
 }
 
 static inline void BLEND_OP(int I, u64 *W)
 {
-        W[I] = s1(W[I-2]) + W[I-7] + s0(W[I-15]) + W[I-16];
+	W[I] = s1(W[I-2]) + W[I-7] + s0(W[I-15]) + W[I-16];
 }
 
 static void

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-10-01 21:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-01 19:31 [PATCH] small sha512 cleanup Denis Vlasenko
2004-10-01 20:38 ` [PATCH] reduce sha512_transform() stack usage, speedup Denis Vlasenko
2004-10-01 20:43   ` David S. Miller
2004-10-01 21:22     ` Denis Vlasenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox