public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/98775] New: missing optimization opportunity on nbody
@ 2021-01-20 22:41 vanyacpp at gmail dot com
2021-01-20 22:42 ` [Bug tree-optimization/98775] " vanyacpp at gmail dot com
2021-01-21 8:04 ` rguenth at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: vanyacpp at gmail dot com @ 2021-01-20 22:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98775
Bug ID: 98775
Summary: missing optimization opportunity on nbody
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: vanyacpp at gmail dot com
Target Milestone: ---
Created attachment 50015
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50015&action=edit
nbody.cpp
On the attached sample (208 LOC), clang 11.0 generates the code that is almost
twice as fast as the one generated by GCC 10.2 (-O3 -ffast-math -flto).
$ ./nbody 50000000
4.0s for clang vs 7.5s for GCC.
A quick look at the generated code shows that clang aggressively unrolled all
inner loops. If I unroll all inner loops manually I get:
$ ./nbody-unrolled 50000000
3.7s for clang vs 6.3s for GCC.
17.6B instructions for clang vs 29.6B instructions for GCC.
While the first sample is a subject to unrolling heuristic, the second is about
optimizing the completely linear chunk of code with many floating point
multiplications and additions.
I tried reducing the sample further, but I only came up with PR98774.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/98775] missing optimization opportunity on nbody
2021-01-20 22:41 [Bug tree-optimization/98775] New: missing optimization opportunity on nbody vanyacpp at gmail dot com
@ 2021-01-20 22:42 ` vanyacpp at gmail dot com
2021-01-21 8:04 ` rguenth at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: vanyacpp at gmail dot com @ 2021-01-20 22:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98775
--- Comment #1 from Ivan Sorokin <vanyacpp at gmail dot com> ---
Created attachment 50016
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50016&action=edit
nbody-unrolled.cpp
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/98775] missing optimization opportunity on nbody
2021-01-20 22:41 [Bug tree-optimization/98775] New: missing optimization opportunity on nbody vanyacpp at gmail dot com
2021-01-20 22:42 ` [Bug tree-optimization/98775] " vanyacpp at gmail dot com
@ 2021-01-21 8:04 ` rguenth at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-21 8:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98775
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
A quick check comparing GCC 10 to GCC 11 shows an improvement from 3.5s to 2.7s
on a Zen2 machine (with -march=native).
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-21 8:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20 22:41 [Bug tree-optimization/98775] New: missing optimization opportunity on nbody vanyacpp at gmail dot com
2021-01-20 22:42 ` [Bug tree-optimization/98775] " vanyacpp at gmail dot com
2021-01-21 8:04 ` rguenth at gcc dot gnu.org
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).