public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/106811] GENERIC and GIMPLE IL undefined behavior needs documenting Date: Mon, 07 Nov 2022 18:17:06 +0000 [thread overview] Message-ID: <bug-106811-4-0jAE6u8uvG@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-106811-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106811 --- Comment #4 from rguenther at suse dot de <rguenther at suse dot de> --- > Am 07.11.2022 um 19:07 schrieb nunoplopes at sapo dot pt <gcc-bugzilla@gcc.gnu.org>: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106811 > > --- Comment #3 from Nuno Lopes <nunoplopes at sapo dot pt> --- >>> I suggest adopting the concept of poison that LLVM has. It allows operations to >>> have undefined behavior, while still allow them to be moved freely. >>> I have some slides that may serve as an introduction to the topic: >>> https://web.ist.utl.pt/nuno.lopes/pres/ub-vmcai19.pdf >>> >>> Happy to discuss further. >> >> I've seen this before but I don't really see how that manages to avoid >> issues when making conditional undefined behavior invoking stmts >> unconditional. > > It's like a NaN in the sense that you can invoke e.g. arithmetic operations. > You can do 2 + poison. That's poison. > > But you can't do 2 / poison. That's undefined behavior (UB), since poison could > be a zero at run time. > > So poison enables free movement of instructions that don't trigger UB. For > instructions that may trigger UB, like division, memory accesses, function > calls, etc, you still need to be careful as usual when moving those around. > > But the point is that poison explains the correctness of the optimizations that > gcc is already doing today, like hoisting arithmetic operations. You can't > their semantics be full UB on e.g. signed overflow as otherwise you couldn't > hoist them without proving that overflows can't happen. The point is they are and we are rewriting them to defined overflow when hoisting. Or in case of division avoid hoisting (because the way to make them defined is to make them unsigned) > > -- > You are receiving this mail because: > You reported the bug.
next prev parent reply other threads:[~2022-11-07 18:17 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-02 6:49 [Bug middle-end/106811] New: " rguenth at gcc dot gnu.org 2022-11-02 9:59 ` [Bug middle-end/106811] " nunoplopes at sapo dot pt 2022-11-05 14:22 ` rguenther at suse dot de 2022-11-07 18:07 ` nunoplopes at sapo dot pt 2022-11-07 18:17 ` rguenther at suse dot de [this message] 2023-09-15 10:22 ` rguenth 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-106811-4-0jAE6u8uvG@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: linkBe 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).