Re: Algoritmic Complexity Attacks and 2.4.20 the dcache code

Scott A Crosby
2003-05-30T14:53:12Z

On Fri, 30 May 2003 02:00:40 -0700 (PDT), "David S. Miller" <davem@redhat.com> writes:

> From: Alex Riesen <alexander.riesen@synopsys.COM>
> Date: Fri, 30 May 2003 10:59:01 +0200
>
> static
> int hash_3(int hi, int c)
> {
> return (hi + (c << 4) + (c >> 4)) * 11;
> }
>
> gcc-3.2.1 -O2 -march=pentium
> ...
> It is not guaranteed to be this way on all architectures, of course.
> But still - no multiplications.
>
> Indeed, I'd missed this. GCC will emit the constant multiply
> expansion unless the multiply cost is set VERY low.

It may still be a win. This does a bit under a dozen instructions per
byte. However, jenkin's does many bytes at a time.

Scott