public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Rahul Kharche" <rahul@IceraSemi.com>
To: "Steven Bosscher" <stevenb.gcc@gmail.com>
Cc: "Jan Hubicka" <hubicka@ucw.cz>, 	<gcc@gcc.gnu.org>,
		"sdkteam-gnu" <sdkteam-gnu@IceraSemi.com>
Subject: RE: branch probabilities on multiway branches
Date: Thu, 15 Apr 2010 14:54:00 -0000	[thread overview]
Message-ID: <4D60B0700D1DB54A8C0C6E9BE69163700E67D567@EXCHANGEVS.IceraSemi.local> (raw)
In-Reply-To: <z2i571f6b511004150456h5c4ce5f9g13704b78b64182ad@mail.gmail.com>

>>What is the problem you're trying to solve?

Generally speaking I was looking for a better logic based on estimated
branch probability to decide between using binary search tree and jump
table implementation of a switch case.

One interesting test case is where the gross structure of a function
is a switch case. The function is parameterized on input to the switch
i.e. of the following type:

void foo (int val, int arg1, ...)
{
  switch (val)
  {
  case 100: /* blah1 */ break;
  case 101: /* blah2 */ break;
    .
    .
    .
  case 10000: /* blah10000 */ break;

  default:
    ;
  }
}

On the basis of the static call graph, the estimated frequencies of
the calls to foo (), and assuming argument val is constant at each
call site, is it possible to optimize the switch case in foo ()?
Perhaps along the line of pulling out the most frequent case like you
mentioned in your example. Or specializing foo () on frequent cases of
val.

In this case inlining and VRP would have automatically done what I am
suggesting. Inlining however is not attempted because foo () is
estimated to be large.


Many Thanks,
Rahul

  reply	other threads:[~2010-04-15 14:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-13 16:51 Rahul Kharche
2010-04-14  0:08 ` Jan Hubicka
2010-04-15 11:56   ` Rahul Kharche
2010-04-15 11:57     ` Steven Bosscher
2010-04-15 14:54       ` Rahul Kharche [this message]
2010-04-15 16:59       ` Rahul Kharche
2010-04-15 22:54       ` Jan Hubicka
2010-04-20 18:20       ` Rahul Kharche
     [not found]         ` <l2ld17039311004211227l9c7de73ex9cb83c186a945a51@mail.gmail.com>
2010-04-22 11:29           ` Rahul Kharche
2010-05-04 12:01             ` Rahul Kharche

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=4D60B0700D1DB54A8C0C6E9BE69163700E67D567@EXCHANGEVS.IceraSemi.local \
    --to=rahul@icerasemi.com \
    --cc=gcc@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=sdkteam-gnu@IceraSemi.com \
    --cc=stevenb.gcc@gmail.com \
    /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).