public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/58686] vect_get_loop_niters() fails for some loops
Date: Sun, 13 Oct 2013 08:22:00 -0000 [thread overview]
Message-ID: <bug-58686-4-yq5kbMr1Sj@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-58686-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58686
--- Comment #3 from rguenther at suse dot de <rguenther at suse dot de> ---
congh at google dot com <gcc-bugzilla@gcc.gnu.org> wrote:
>http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58686
>
>--- Comment #2 from Cong Hou <congh at google dot com> ---
>I think this issue is more like a missed optimization.
>
>If the iteration number can be calculated as a constant value at
>compile time,
>then the function assert_loop_rolls_lt() won't be called due to an
>early exit
>(specifically in the function number_of_iterations_lt() at the call to
>number_of_iterations_lt_to_ne()). That is why I could not craft a
>testcase
>showing miscompile.
>
>A better test case is shown below:
>
>
>#define N 4
>void foo(int* a, unsigned int i)
>{
> int j = 0;
> do
> {
> a[j++] = 0;
> i -= 4;
> }
> while (i >= N);
>}
>
>
>Compile it with -O3 and the produced result is using __builtin_memset()
>as the
>niter can be calculated. But if the value of N is replaced by others
>like 3 or
>5, GCC won't optimize this loop into __builtin_memset() any more.
Yeah, the issue in general is finding a condition that ensures the loop will
terminate and a formula that computes the number of iterations if that holds
true. In case of wrapping arithmetic this is non-trivial and likely not all
cases are implemented.
Richard.
next prev parent reply other threads:[~2013-10-13 8:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-11 1:10 [Bug tree-optimization/58686] New: [BUG] vect_get_loop_niters() cound not get the correct result " congh at google dot com
2013-10-11 7:51 ` [Bug tree-optimization/58686] vect_get_loop_niters() fails " rguenth at gcc dot gnu.org
2013-10-12 0:21 ` congh at google dot com
2013-10-13 8:22 ` rguenther at suse dot de [this message]
2021-12-12 10:21 ` pinskia at gcc dot gnu.org
2021-12-12 10:21 ` 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-58686-4-yq5kbMr1Sj@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).