[Tfug] GCC optimizations

Robert Hunter hunter at tfug.org
Wed Oct 18 10:47:45 MST 2006


Don,

It seems that GCC generates either binary search or jump table code
based on a hueristic which considers the number of cases and the
range of case values.  For very small numbers of cases, or for very
large ranges of values, gcc generates binary search code.  Otherwise
it generates a jump table.  Previously I ran across some literature
that discussed using different branching techniques, such as perfect
hashes, but I don't have a reference.

The article linked below addresses gcc for the cell, but I think it
is generally relevant.

http://www.cellperformance.com/articles/2006/04/programming_with_branches_patt.html#rule_3

-- 
Rob




More information about the tfug mailing list