This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Hashing of "switch/case" selections
- To: gcc at gcc dot gnu dot org, jawalker at stl dot quik dot com
- Subject: Re: Hashing of "switch/case" selections
- From: dewar at gnat dot com (Robert Dewar)
- Date: Thu, 28 Dec 2000 10:19:01 -0500 (EST)
<<associated register loads, to be at least the equivalent of three test
and conditional branch instruction pairs. (no divide instructions -- I
am allergic to those).
>>
Conditional jumps can be extremely expensive if mispredicted as will happen
in this case (they can cost 10's of cycles), so your relative estimate of
efficiencies here is badly off for most modern architectures.
<<Just for peace of mind, the present tool (binary tree) handles most
situations in the most efficient manner, IMHO. Also, none of the
algorithms I found could guarantee a near-minimal, perfect Hash in
linear time. A few wild stabs in the dark often bring success. When
they do not, the binary tree is the reliable backup plan.
>>
Who cares if the compilation time algorithm is linear time, that's a
quite inappropriate criterion.