public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Christian Hildner <christian.hildner@hob.de>
To: gcc@gnu.org
Subject: Switch statement optimization
Date: Mon, 10 Jul 2006 09:39:00 -0000	[thread overview]
Message-ID: <44B2202D.3090203@hob.de> (raw)

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 optimization) then GCC uses compare instruction rather than a branch table. What I am wondering is why no real cost estimation is done here. In my case there are around 200 to 1500 labels within the 16K range, so they are completely resolved to compares. In contrast the Intel compiler outputs branch tables more likely.

The question now is whether the factors 10 (3 for size opt) have been found using any standard benchmark. And shouldn't at least the factor be optimized for a standard benchmark (like the upcoming SPEC CPU 2006 INT) if this simple linear method is used for modeling a logarithmic behavior? Or should a cost estimation be introduced?

For size optimization there could be a quite accurate architecture dependent size estimation.

Opinions, Comments?

Christian

PS: Please CC me.


             reply	other threads:[~2006-07-10  9:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-10  9:39 Christian Hildner [this message]
2006-07-10 11:06 ` Ben Elliston
2006-07-10 14:48 Joern RENNECKE
2006-07-11 10:03 ` Christian Hildner
2022-04-18 14:41 Paul Koning
2022-04-19 14:33 ` Martin Liška

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44B2202D.3090203@hob.de \
    --to=christian.hildner@hob.de \
    --cc=gcc@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).