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/102927] Failure to optimize series of if-else to use array when possible
Date: Mon, 25 Oct 2021 12:06:08 +0000 [thread overview]
Message-ID: <bug-102927-4-HpF5SIdi3R@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102927-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102927
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
> As Richi said, we do the transformation to switch only if we can expand it
> by jump table, bit test or array access.
>
> You can expand this example with:
> --param case-values-threshold=4
and we end up with array access:
$ gcc -c pr102927.c -O2 --param case-values-threshold=4
-fdump-tree-optimized=/dev/stdout
;; Function foo (foo, funcdef_no=0, decl_uid=1943, cgraph_uid=1,
symbol_order=0)
Removing basic block 5
int foo (int i)
{
int _1;
unsigned int _3;
int _4;
<bb 2> [local count: 1073741824]:
_3 = (unsigned int) i_2(D);
if (_3 <= 3)
goto <bb 3>; [50.00%]
else
goto <bb 4>; [50.00%]
<bb 3> [local count: 536870913]:
_4 = CSWTCH.1[_3];
<bb 4> [local count: 1073741824]:
# _1 = PHI <42(2), _4(3)>
return _1;
}
next prev parent reply other threads:[~2021-10-25 12:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-25 11:41 [Bug tree-optimization/102927] New: " gabravier at gmail dot com
2021-10-25 12:00 ` [Bug tree-optimization/102927] " rguenth at gcc dot gnu.org
2021-10-25 12:02 ` marxin at gcc dot gnu.org
2021-10-25 12:06 ` marxin at gcc dot gnu.org [this message]
2021-10-25 12:06 ` marxin at gcc dot gnu.org
2021-10-25 12:20 ` gabravier at gmail dot com
2021-10-25 12:23 ` pinskia at gcc dot gnu.org
2021-10-25 12:24 ` marxin at gcc dot gnu.org
2021-10-25 12:25 ` pinskia 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-102927-4-HpF5SIdi3R@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).