[PATCH] small sha512 cleanup

From: Denis Vlasenko
Date: Fri Oct 01 2004 - 14:37:22 EST


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
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