public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/103429] Optimization of Auto-generated condition chain is not giving good lookup tables.
Date: Thu, 25 Nov 2021 18:19:40 +0000	[thread overview]
Message-ID: <bug-103429-4-2baUbU5eKu@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103429-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103429

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
So it's very funny what's happening here. iftoswitch pass is called for all
e.g.
f_dispatch_always_inline<10>, f_dispatch_always_inline<9> and so on until
f_dispatch_always_inline<5> which is converted to switch.
And then all early passes are called for f_dispatch_always_inline<4> which
include einline and we end up with:

__attribute__((always_inline))
void f_dispatch_always_inline<4> (int i)
{
  <bb 2> :
  if (i_2(D) == 4)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  f<4> ();
  goto <bb 11>; [INV]

  <bb 4> :
  switch (i_2(D)) <default: <L9> [16.67%], case 5: <L3> [16.67%], case 6: <L4>
[16.67%], case 7: <L5> [16.67%], case 8: <L6> [16.67%], case 9: <L7> [16.67%]>

  <bb 5> :
<L3>:
  f<5> ();
  goto <bb 11>; [100.00%]

  <bb 6> :
<L4>:
  f<6> ();
  goto <bb 11>; [100.00%]

  <bb 7> :
<L5>:
  f<7> ();
  goto <bb 11>; [100.00%]

  <bb 8> :
<L6>:
  f<8> ();
  goto <bb 11>; [100.00%]

  <bb 9> :
<L7>:
  f<9> ();

  <bb 11> :
<L9>:
  return;

}

which is a mixture of if and switch statements.

So what we basically need is if-to-switch hybrid support for if-else chain
combined with switches.

  parent reply	other threads:[~2021-11-25 18:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25 14:55 [Bug c++/103429] New: " ed at edwardrosten dot com
2021-11-25 15:10 ` [Bug tree-optimization/103429] " rguenth at gcc dot gnu.org
2021-11-25 15:50 ` ed at edwardrosten dot com
2021-11-25 16:18 ` marxin at gcc dot gnu.org
2021-11-25 18:19 ` marxin at gcc dot gnu.org [this message]
2021-11-25 19:03 ` pinskia at gcc dot gnu.org
2021-11-26  8:23 ` marxin at gcc dot gnu.org
2023-04-03  9:03 ` marxin at gcc dot gnu.org
2023-04-26  6:55 ` rguenth at gcc dot gnu.org
2023-07-27  9:22 ` rguenth at gcc dot gnu.org
2024-05-21  9:10 ` jakub at gcc dot gnu.org

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=bug-103429-4-2baUbU5eKu@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).