public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amonakov at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/114480] g++: internal compiler error: Segmentation fault signal terminated program cc1plus
Date: Thu, 04 Apr 2024 18:41:46 +0000	[thread overview]
Message-ID: <bug-114480-4-ed0bUvn0xN@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114480-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114480

--- Comment #20 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
(note that if you uninclude the testcase and compile with -fno-exceptions it's
much faster)

On the smaller testcase from comment 14, prune_unused_phi_nodes invokes
gcc_qsort 53386 times. There are two distinct phases.

In the first phase, the count of struct dom_dfsnum to sort grows in a roughly
linear fashion up to 23437 on the 12294'th invocation. Hence this first phase
is quadratic in the overall number of processed dom_dfsnum-s.

In the second phase, it almost always sorts exactly 7 elements for the
remaining ~41000 invocations.

The number of pairwise comparisons performed by gcc_qsort is approximately
(n+1)*(log_2(n)-1), which results in 1.8e9 comparisons overall for the 53386
invocations. perf shows 10.9e9 cycles spent under gcc_qsort, i.e. 6 cycles per
comparison, which looks about right. It's possible to reduce that further by
switching from classic to bidirectional merge, and using cmovs instead of
bitwise arithmetic for branchless selects.

> I'll note the swapping of 8 bytes is a bit odd and it seems to be
> if-converted, thus always doing a write.

That is not a swap. That's the merge step of a mergesort, we are taking the
smaller element from the heads of two arrays and moving it to the tail of a
third array.

Basically there's quadratic behavior in tree-into-ssa, gcc_qsort shows
relatively higher on the profile because the log_2(n) factor becomes
noticeable.

Hope that helps!

  parent reply	other threads:[~2024-04-04 18:41 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26 11:40 [Bug c++/114480] New: " douglas.boffey at gmail dot com
2024-03-26 11:42 ` [Bug c++/114480] " douglas.boffey at gmail dot com
2024-03-26 11:46 ` pinskia at gcc dot gnu.org
2024-03-26 11:46 ` pinskia at gcc dot gnu.org
2024-03-26 11:51 ` douglas.boffey at gmail dot com
2024-03-26 12:05 ` pinskia at gcc dot gnu.org
2024-03-26 12:15 ` pinskia at gcc dot gnu.org
2024-03-26 12:26 ` pinskia at gcc dot gnu.org
2024-03-26 12:26 ` pinskia at gcc dot gnu.org
2024-03-26 12:31 ` douglas.boffey at gmail dot com
2024-03-26 12:41 ` redi at gcc dot gnu.org
2024-03-27  8:28 ` rguenth at gcc dot gnu.org
2024-03-27 19:49 ` vmakarov at gcc dot gnu.org
2024-03-28  8:17 ` cvs-commit at gcc dot gnu.org
2024-03-28  8:44 ` rguenth at gcc dot gnu.org
2024-03-28 10:12 ` rguenth at gcc dot gnu.org
2024-03-28 10:39 ` rguenth at gcc dot gnu.org
2024-04-02 13:28 ` rguenth at gcc dot gnu.org
2024-04-03  6:57 ` cvs-commit at gcc dot gnu.org
2024-04-03 11:47 ` rguenth at gcc dot gnu.org
2024-04-04  9:42 ` rguenth at gcc dot gnu.org
2024-04-04 18:41 ` amonakov at gcc dot gnu.org [this message]
2024-04-05 15:35 ` amonakov at gcc dot gnu.org
2024-04-08  9:46 ` rguenth at gcc dot gnu.org
2024-04-08  9:50 ` douglas.boffey at gmail dot com
2024-04-08  9:54 ` rguenther at suse dot de
2024-04-08 12:32 ` douglas.boffey at gmail dot com
2024-04-08 13:07 ` rguenther at suse dot de
2024-04-08 13:22 ` [Bug c++/114480] [12/13/14 Regression " rguenth at gcc dot gnu.org
2024-04-08 13:37 ` [Bug c++/114480] [12/13/14 Regression] " rguenth at gcc dot gnu.org
2024-04-09  7:51 ` rguenth at gcc dot gnu.org
2024-04-09 11:39 ` rguenth at gcc dot gnu.org
2024-05-14 13:41 ` [Bug c++/114480] [12/13/14/15 " rguenth at gcc dot gnu.org
2024-05-17 12:29 ` cvs-commit 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-114480-4-ed0bUvn0xN@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).