public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/96563] Failure to optimize loop with condition to simple arithmetic
Date: Thu, 19 Aug 2021 23:22:48 +0000 [thread overview]
Message-ID: <bug-96563-4-IlRfDs6e9x@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96563-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96563
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2020-08-11 00:00:00 |2021-8-19
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So I looked into this a little bit, clang is able to do it because it "unrolls"
the loop.
The reason why I say that is if you take:
int f(int x, int y)
{
int i = 0;
while (i <= y)
{
if (i == x)
return 8;
++i;
}
return 4;
}
No compiler is able to optimize this at all.
Which should get us: 4 + ((x <= y && x >= 0)*4).
Even changing the original 9 to 1000, clang does not do the optimization ....
>although of course it would be nice if it also worked for 99 instead of 9, where we are not going to unroll.
Yes it would but not even clang/LLVM does that :)
next prev parent reply other threads:[~2021-08-19 23:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-11 1:30 [Bug tree-optimization/96563] New: " gabravier at gmail dot com
2020-08-11 5:53 ` [Bug tree-optimization/96563] " glisse at gcc dot gnu.org
2021-08-19 23:22 ` pinskia at gcc dot gnu.org [this message]
2021-09-06 18:43 ` gabravier at gmail dot com
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-96563-4-IlRfDs6e9x@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).