public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dominiq at lps dot ens.fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/46186] Clang creates code running 1600 times faster than gcc's
Date: Tue, 26 Oct 2010 16:36:00 -0000 [thread overview]
Message-ID: <20101026163600.Z3jOmZhDhLvtEApaVs4q0chtHolbt5-_VFf_ORncfJk@z> (raw)
In-Reply-To: <bug-46186-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46186
--- Comment #13 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2010-10-26 16:36:05 UTC ---
> This multiplication transformation is incorrect if the loop wraps
> (unsigned always wraps; never overflows).
I think this is wrong: wrapping is nothing but a modulo 2^n operation (n=64
here) which "works" for additions and multiplications, so if there is wrapping,
the result is sum=(b*(b-1)-a*(a-1))/2 modulo 2^n, i.e. correctly wrapped.
On my Core2duo 2.53Ghz with -Ofast the run time is ~1.2s for elementary 2*10^9
loops or .6ns/loop or ~1.5 clock cycle per loop. For a perfect vectorization
and no loop overhead, I would expect a minimum of 0.5 clock cycle per loop. If
you get anything below this number, it means that the loop
for (; a < b; a++)
sum += a;
is replaced with sum=(b*(b-1)-a*(a-1))/2 (you can confirm it by checking that
the timing behaves as O(len) or not). Apparently clang does this (valid)
transformation while gcc don't for any options I have tried.
Note that If I write such a loop, it is because I am interested by the timing
of the loop, not by the result I know for more than 40 years!
next prev parent reply other threads:[~2010-10-26 16:36 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-26 14:27 [Bug c/46186] New: " jak@jak-linux.org
2010-10-26 14:30 ` [Bug c/46186] " jak@jak-linux.org
2010-10-26 14:31 ` paolo.carlini at oracle dot com
2010-10-26 14:33 ` jak@jak-linux.org
2010-10-26 14:47 ` redi at gcc dot gnu.org
2010-10-26 14:53 ` jak@jak-linux.org
2010-10-26 14:59 ` dominiq at lps dot ens.fr
2010-10-26 15:00 ` jak@jak-linux.org
2010-10-26 15:26 ` jak@jak-linux.org
2010-10-26 15:29 ` redi at gcc dot gnu.org
2010-10-26 15:37 ` jakub at gcc dot gnu.org
2010-10-26 15:43 ` paolo.carlini at oracle dot com
2010-10-26 15:56 ` pinskia at gmail dot com
[not found] ` <4cc6e60b.2811970a.71aa.016aSMTPIN_ADDED@mx.google.com>
2010-10-26 15:56 ` Andrew Pinski
2010-10-26 16:36 ` dominiq at lps dot ens.fr [this message]
2010-10-26 16:59 ` jakub at gcc dot gnu.org
2010-10-26 17:15 ` dominiq at lps dot ens.fr
2010-10-26 18:44 ` jakub at gcc dot gnu.org
2010-10-26 18:54 ` dominiq at lps dot ens.fr
2010-10-26 19:12 ` jakub at gcc dot gnu.org
2010-10-26 20:30 ` joseph at codesourcery dot com
2010-10-26 21:00 ` jakub at gcc dot gnu.org
2010-10-26 21:07 ` dominiq at lps dot ens.fr
2010-10-29 21:07 ` tg at mirbsd dot org
2010-10-29 21:44 ` [Bug tree-optimization/46186] " sebpop at gmail dot com
2010-10-29 21:59 ` joseph at codesourcery dot com
2014-02-16 13:13 ` jackie.rosen at hushmail dot com
2021-08-28 23:42 ` 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=20101026163600.Z3jOmZhDhLvtEApaVs4q0chtHolbt5-_VFf_ORncfJk@z \
--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).