From: Richard Sandiford <richard.sandiford@arm.com>
To: Richard Biener <rguenther@suse.de>
Cc: Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH][RFC] middle-end/106811 - document GENERIC/GIMPLE undefined behavior
Date: Wed, 20 Sep 2023 15:56:54 +0100 [thread overview]
Message-ID: <mptfs38hozt.fsf@arm.com> (raw)
In-Reply-To: <nycvar.YFH.7.77.849.2309201343440.5561@jbgna.fhfr.qr> (Richard Biener's message of "Wed, 20 Sep 2023 13:45:49 +0000 (UTC)")
Richard Biener <rguenther@suse.de> writes:
> On Wed, 20 Sep 2023, Richard Sandiford wrote:
>
>> Thanks for doing this. Question below...
>>
>> Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
>> > The following attempts to provide a set of conditions GENERIC/GIMPLE
>> > considers invoking undefined behavior, leaning on the C standards
>> > Annex J, as to provide portability guidance to language frontend
>> > developers.
>> >
>> > I've both tried to remember cases we exploit undefined behavior
>> > and went over C2x Annex J to catch more stuff. I'd be grateful
>> > if people could point out obvious omissions or cases where the
>> > wording isn't clear. I plan to check/amend the individual operator
>> > documentations as well, but not everything fits there.
>> >
>> > I've put this into generic.texi because it applies to GENERIC as
>> > the frontend interface. All constraints apply to GIMPLE as well.
>> > I plan to add a section to gimple.texi as to how to deal with
>> > undefined behavior.
>> >
>> > As said, every comment is welcome.
>> >
>> > For testing I've built doc and inspected the resulting pdf.
>> >
>> > PR middle-end/106811
>> > * doc/generic.texi: Add portability section with
>> > subsection on undefined behavior.
>> > ---
>> > gcc/doc/generic.texi | 87 ++++++++++++++++++++++++++++++++++++++++++++
>> > 1 file changed, 87 insertions(+)
>> >
>> > diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi
>> > index 6534c354b7a..0969f881146 100644
>> > --- a/gcc/doc/generic.texi
>> > +++ b/gcc/doc/generic.texi
>> > @@ -43,6 +43,7 @@ seems inelegant.
>> > * Functions:: Function bodies, linkage, and other aspects.
>> > * Language-dependent trees:: Topics and trees specific to language front ends.
>> > * C and C++ Trees:: Trees specific to C and C++.
>> > +* Portability issues:: Portability summary for languages.
>> > @end menu
>> >
>> > @c ---------------------------------------------------------------------
>> > @@ -3733,3 +3734,89 @@ In either case, the expression is void.
>> >
>> >
>> > @end table
>> > +
>> > +
>> > +@node Portability issues
>> > +@section Portability issues
>> > +
>> > +This section summarizes portability issues when translating source languages
>> > +to GENERIC. Everything written here also applies to GIMPLE. This section
>> > +heavily relies on interpretation according to the C standard.
>> > +
>> > +@menu
>> > +* Undefined behavior:: Undefined behavior.
>> > +@end menu
>> > +
>> > +@node Undefined behavior
>> > +@subsection Undefined behavior
>> > +
>> > +The following is a list of circumstances that invoke undefined behavior.
>> > +
>> > +@itemize @bullet
>> > +@item
>> > +When the result of negation, addition, subtraction or division of two signed
>> > +integers or signed integer vectors not subject to @option{-fwrapv} cannot be
>> > +represented in the type.
>>
>> Couldn't tell: is the omission of multiplication deliberate?
>
> No. Fixed. Do you by chance remember/know anything about RTL 'div'
> and behavior on overflow (INT_MIN/-1), in particular with -fwrapv?
No, sorry. I thought SDIV was allowed (but not required) to trap
on overflow, but I don't know off-hand what effect -fwrapv has
on the way that we use it.
Richard
next prev parent reply other threads:[~2023-09-20 14:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-15 11:50 Richard Biener
2023-09-20 12:35 ` Richard Sandiford
2023-09-20 13:45 ` Richard Biener
2023-09-20 14:56 ` Richard Sandiford [this message]
2023-09-20 14:02 ` Alexander Monakov
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=mptfs38hozt.fsf@arm.com \
--to=richard.sandiford@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rguenther@suse.de \
/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).