public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "aldyh at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/109695] [14 Regression] crash in gimple_ranger::range_of_expr since r14-377-gc92b8be9b52b7e
Date: Tue, 09 May 2023 12:00:20 +0000	[thread overview]
Message-ID: <bug-109695-4-p8ZgYqOxak@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109695-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #23 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
An update on the int_range_max memory bloat work.

As Andrew mentioned, having int_range<25> solves the problem, but is just
kicking the can down the road.  I ran some stats on what we actually need on a
bootstrap, and 99.7% of ranges fit in a 3 sub-range range, but we need more to
represent switches, etc.

There's no clear winner for choosing <N>, as the distribution for anything past
<3> is rather random.  What I did see was that at no point do we need more than
125 sub-ranges (on a set of .ii files from a boostrap).

I've implemented various alternatives using a dynamic approach similar to what
we do for auto_vec.  I played with allocating 2x as much as needed, and
allocating 10 or 20 more than needed, as well going from N to 255 in one go. 
All of it required some shuffling to make sure the penalty isn't much wrt
virtuals, etc, but I think the dynamic approach is the way to go.

The question is how much of a performance hit are we willing take in order to
reduce the memory footprint.  Memory to speed is a linear relationship here, so
we just have to pick a number we're happy with.

Here are some numbers for various sub-ranges (the sub-ranges grow automatically
in union, intersect, invert, and assignment, which are the methods that grow in
sub-ranges).

trunk (wide_ints <255>) =>  40912 bytes  
GCC 12 (trees <255>)    =>   4112 bytes
auto_int_range<2>       =>    432 bytes  (5.14% penalty for VRP)
auto_int_range<3>       =>    592 bytes  (4.01% penalty)
auto_int_range<8>       =>   1392 bytes  (2.68% penalty)
auto_int_range<10>      =>   1712 bytes  (2.14% penalty)

As you can see, even at N=10, we're still 24X smaller than trunk and 2.4X
smaller than GCC12 for a 2.14% performance drop.

I'm tempted to just pick a number and tweak this later as we have ultimate
flexibility here.  Plus, we can also revert to a very small N, and have passes
that care about switches use their own temporaries (auto_int_range<20> or
such).

Note that we got a 13.22% improvement for the wide_int+legacy work, so even the
absolute worst case of a 5.14% penalty would have us sitting on a net 8.76%
improvement over GCC12.

Bike shedding welcome ;-)

  parent reply	other threads:[~2023-05-09 12:00 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-02  9:57 [Bug c/109695] New: crash in gimple_ranger::range_of_expr dcb314 at hotmail dot com
2023-05-02 10:44 ` [Bug c/109695] " dcb314 at hotmail dot com
2023-05-02 11:06 ` dcb314 at hotmail dot com
2023-05-02 12:15 ` [Bug tree-optimization/109695] [14 Regression] " rguenth at gcc dot gnu.org
2023-05-02 13:43 ` aldyh at gcc dot gnu.org
2023-05-02 13:43 ` aldyh at gcc dot gnu.org
2023-05-02 14:35 ` aldyh at gcc dot gnu.org
2023-05-02 15:02 ` amacleod at redhat dot com
2023-05-02 16:52 ` aldyh at gcc dot gnu.org
2023-05-02 20:37 ` amacleod at redhat dot com
2023-05-03  8:02 ` mikael at gcc dot gnu.org
2023-05-03 10:54 ` marxin at gcc dot gnu.org
2023-05-03 12:13 ` [Bug tree-optimization/109695] [14 Regression] crash in gimple_ranger::range_of_expr since r14-377-gc92b8be9b52b7e jakub at gcc dot gnu.org
2023-05-03 12:14 ` jakub at gcc dot gnu.org
2023-05-03 12:20 ` jakub at gcc dot gnu.org
2023-05-03 13:02 ` aldyh at gcc dot gnu.org
2023-05-03 13:06 ` jakub at gcc dot gnu.org
2023-05-03 14:31 ` amacleod at redhat dot com
2023-05-04  5:51 ` aldyh at gcc dot gnu.org
2023-05-04  9:02 ` jakub at gcc dot gnu.org
2023-05-04  9:06 ` sjames at gcc dot gnu.org
2023-05-04  9:52 ` rguenther at suse dot de
2023-05-04 16:01 ` dcb314 at hotmail dot com
2023-05-04 16:14 ` dcb314 at hotmail dot com
2023-05-04 16:22 ` amacleod at redhat dot com
2023-05-09 12:00 ` aldyh at gcc dot gnu.org [this message]
2023-05-09 12:36 ` aldyh at gcc dot gnu.org
2023-05-09 13:01 ` rguenth at gcc dot gnu.org
2023-05-09 13:03 ` jakub at gcc dot gnu.org
2023-05-09 13:28 ` rguenther at suse dot de
2023-05-09 14:24 ` aldyh at gcc dot gnu.org
2023-05-09 14:35 ` jakub at gcc dot gnu.org
2023-05-09 15:02 ` aldyh at gcc dot gnu.org
2023-05-09 15:13 ` jakub at gcc dot gnu.org
2023-05-10  6:48 ` rguenther at suse dot de
2023-05-10 15:03 ` jakub at gcc dot gnu.org
2023-05-11  4:22 ` aldyh at gcc dot gnu.org
2023-05-11  4:31 ` aldyh at gcc dot gnu.org
2023-05-15 17:23 ` cvs-commit at gcc dot gnu.org
2023-05-23 21:49 ` amacleod at redhat dot com
2023-05-24  5:46 ` aldyh at gcc dot gnu.org
2023-05-24 12:41 ` cvs-commit at gcc dot gnu.org
2023-05-24 12:41 ` cvs-commit at gcc dot gnu.org
2023-05-24 12:41 ` cvs-commit at gcc dot gnu.org
2023-05-24 14:04 ` amacleod at redhat 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-109695-4-p8ZgYqOxak@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).