[FFmpeg-devel] [PATCH] md5: optimize second round by using 4-operation form of G()

Clément Bœsch ubitux at gmail.com
Mon May 20 03:15:23 CEST 2013


> From f33000be40325dabf70be6fe631f92b7d4b031a7 Mon Sep 17 00:00:00 2001
> From: Giorgio Vazzana <mywing81 at gmail.com>
> Date: Sat, 18 May 2013 13:53:52 +0200
> Subject: [PATCH] md5: optimize second round by using 4-operation form of G()
> 
> 4-operation form is preferred over 3-operation because it breaks a long
> dependency chain, thus allowing a superscalar processor to execute more
> operations in parallel.
> The idea was taken from: http://www.zorinaq.com/papers/md5-amd64.html
> ---
>  libavutil/md5.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/libavutil/md5.c b/libavutil/md5.c
> index 7375ce5..e3c4981 100644
> --- a/libavutil/md5.c
> +++ b/libavutil/md5.c
> @@ -84,7 +84,7 @@ static const uint32_t T[64] = { // T[i]= fabs(sin(i+1)<<32)
>                                                                          \
>          if (i < 32) {                                                   \
>              if (i < 16) a += (d ^ (b & (c ^ d))) + X[       i  & 15];   \
> -            else        a += (c ^ (d & (c ^ b))) + X[(1 + 5*i) & 15];   \
> +            else        a += ((d & b) | (~d & c))+ X[(1 + 5*i) & 15];   \

Why not use the same trick for the i < 16 case, with something like
(b & c) | (~b & d) ?

>          } else {                                                        \
>              if (i < 48) a += (b ^ c ^ d)         + X[(5 + 3*i) & 15];   \
>              else        a += (c ^ (b | ~d))      + X[(    7*i) & 15];   \

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130520/5153db0e/attachment.asc>


More information about the ffmpeg-devel mailing list