Re: Switch statement optimization

2022-04-19 Thread Martin Liška
On 4/18/22 16:41, Paul Koning via Gcc wrote: In switch statements with dense case values, the typical result is a jump table, which is fast. If the values are sparse, a tree of compares is generated instead. What if nearly all cases are dense but there are a few outliers? An example appears

Switch statement optimization

2022-04-18 Thread Paul Koning via Gcc
In switch statements with dense case values, the typical result is a jump table, which is fast. If the values are sparse, a tree of compares is generated instead. What if nearly all cases are dense but there are a few outliers? An example appears in the NFS protocol parser, where you get a sw

Re: Switch statement optimization

2006-07-11 Thread Christian Hildner
Joern RENNECKE schrieb: In http://gcc.gnu.org/ml/gcc/2006-07/msg00156.html, your wrote: We could use a cheap hash and base start compare / branch trees in every hash bin. Say we have a 16 k range, 200 nodes, and want to keep the hash bin/node ratio between 2 and 4. Let i be the switch argume

Re: Switch statement optimization

2006-07-10 Thread Joern RENNECKE
In http://gcc.gnu.org/ml/gcc/2006-07/msg00156.html, your wrote: A paper at this year's GCC Summit talked about this: http://www.gccsummit.org/2006/view_abstract.php?content_key=18 You might like to follow up with Edmar (the author of the paper). But that was about optimizing the trees for an

Re: Switch statement optimization

2006-07-10 Thread Ben Elliston
A paper at this year's GCC Summit talked about this: http://www.gccsummit.org/2006/view_abstract.php?content_key=18 You might like to follow up with Edmar (the author of the paper). Cheers, Ben

Switch statement optimization

2006-07-10 Thread Christian Hildner
Hi, while dealing with autogenerated code I found that GCC often outputs compare trees instead of branch tables for switch statements. I found that GCC uses the density of case labels within their spanned range as the key criterion. If the density of labels is smaller than 10% (33% for size op