🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #12633

Re: % in hash table

#12633
From: david r chase
Date: Thu, 12 Oct 1995 16:15
29 lines
1488 bytes
In article <1995Oct1102.48.02.1823@silverton.berkeley.edu>,
D. J. Bernstein <djb@silverton.berkeley.edu> wrote:
>Joe Buck <jbuck@synopsys.com> wrote:
>> 	/* now res is at most 32767+4 */
>> 	return (res < 32767) ? res : res - 32767;

>Branching is bad. Look at the routines that use res, and rewrite them so
>that they won't mind inputs up to 32771.

Branches aren't necesssary, nor are they necessarily bad.  On some
machines, if well-scheduled, they have effectively zero cost, or very
close to it.  If you've got conditional move (e.g., Sparc V9), I think
you could do that with something like:

  sethi %hi(32767),%g1
  or    %g1,%lo(32767),%g1
  cmp   res,%g1
  movl  %icc,0,
  sub   res,%g1,res

It would be helpful to spread this out more (in scheduling terms) since each
instruction depends on its predecessor.  Inlining would be a win.

There are also branchless idioms for doing this in Sparc V8, but
they're probably not a win over the cost of the branches.

speaking for myself,

David Chase
Technical Details
Message-ID: <DGCFt9.GH7@world.std.com>
Path: arc1-ca.pugleaf.net!news.kei.com!world!chase
References: <43tqr6$3au@mikasa.iol.it> <812838189snz@genesis.demon.co.uk> <4522pb$cid@hermes.synopsys.com> <1995Oct1102.48.02.1823@silverton.berkeley.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.arch,comp.arch.arithmetic,comp.lang.c
Path: arc1-ca.pugleaf.net!news.kei.com!world!chase
From: chase@world.std.com (david r chase)
Subject: Re: % in hash table
Message-ID: <DGCFt9.GH7@world.std.com>
Organization: The World Public Access UNIX, Brookline, MA
References: <43tqr6$3au@mikasa.iol.it> <812838189snz@genesis.demon.co.uk> <4522pb$cid@hermes.synopsys.com> <1995Oct1102.48.02.1823@silverton.berkeley.edu>
Date: Thu, 12 Oct 1995 16:15:09 GMT