From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>,
Aldy Hernandez <aldyh@redhat.com>,
gcc-patches@gcc.gnu.org, richard.sandiford@arm.com
Subject: Re: [RFC] > WIDE_INT_MAX_PREC support in wide_int and widest_int
Date: Fri, 29 Sep 2023 12:58:34 +0200 [thread overview]
Message-ID: <ZRat2iW/RHr8fZBM@tucnak> (raw)
In-Reply-To: <mptttrdp901.fsf@arm.com>
On Fri, Sep 29, 2023 at 11:30:06AM +0100, Richard Sandiford wrote:
> Yeah, think I agree with this. widest_int really combined two things:
>
> (a) a way of storing any integer IL value without loss of precision
>
> (b) a way of attaching sign information
>
> Arithmetic on widest_int is dubious, because it wraps at an essentially
> arbitrary point.
Yeah, but some more sensible than others. Logical ops make sense at any
precision, addition/subtraction might better have for widest_int a few bits
of extra maximum precision over wide_int maximum supported precision such
that overflows are caught, but say for multiplication that would be much
more. Of course, we already document that bswap/rotates don't make any
sense on widest_int, and as I wrote, e.g. lrshift or unsigned division
of values with MSB set are very questionable too.
> The approach in the patch looks good to me from a quick scan FWIW.
> Will try to review over the weekend.
For the actual patch I have another worry (but without the GTY widest_int
uses and slsr etc. addressed first it can't be easily verified).
wide_int_ref_storage has VAR_PRECISION like wide_int, while I've hacked up
get_binary_precision not to allocate uselessly for it a lot of memory,
I'm afraid any time we perform some operation on wide_int_refs created from
widest_int (so, they get in most cases reasonably small get_len () but
huge get_precision ()) we'd uselessly allocate 255 HOST_WIDE_INTs of memory
from heap. So maybe wide_int should also like widest_int in the patch
have u.val vs. u.valp decided based on estimated or later real get_len ()
rather than get_precision (). In the end, I think we should make sure that
unless _BitInt is seen in the sources, we don't really ever allocate any
heap memory in wide_int/widest_int. At least unless we change the number
of inline elements of the arrays for wide_int/widest_int, if we lower that
say to some hardcoded number of limbs on all arches (say 4 or 6 or 8, 9
x86-64 is kind of weird) that allocations happen only very rarely. Normal
128-bit precision math shouldn't trigger them certainly.
Jakub
next prev parent reply other threads:[~2023-09-29 10:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-28 14:34 [RFC] > WIDE_INT_MAX_PREC support in wide-int Jakub Jelinek
2023-08-29 9:49 ` Richard Biener
2023-08-29 10:42 ` Richard Sandiford
2023-08-29 15:09 ` Jakub Jelinek
2023-09-28 14:03 ` [RFC] > WIDE_INT_MAX_PREC support in wide_int and widest_int Jakub Jelinek
2023-09-28 15:53 ` Aldy Hernandez
2023-09-29 8:37 ` Jakub Jelinek
2023-09-29 12:04 ` Aldy Hernandez
2023-09-29 8:24 ` Jakub Jelinek
2023-09-29 9:25 ` Richard Biener
2023-09-29 9:49 ` Richard Biener
2023-09-29 10:30 ` Richard Sandiford
2023-09-29 10:58 ` Jakub Jelinek [this message]
2023-10-05 15:11 ` Jakub Jelinek
2023-10-06 17:41 ` Jakub Jelinek
2023-08-29 14:46 ` [RFC] > WIDE_INT_MAX_PREC support in wide-int Jakub Jelinek
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=ZRat2iW/RHr8fZBM@tucnak \
--to=jakub@redhat.com \
--cc=aldyh@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rguenther@suse.de \
--cc=richard.sandiford@arm.com \
/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).