public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "david at westcontrol dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/110249] __builtin_unreachable helps optimisation at -O1 but not at -O2 Date: Wed, 14 Jun 2023 12:43:11 +0000 [thread overview] Message-ID: <bug-110249-4-Cc7ocBbroQ@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-110249-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110249 --- Comment #4 from David Brown <david at westcontrol dot com> --- Yes, __builtin_assume_aligned is the best way to write things in this particular case (and optimises fine for -O1 and -O2). It is also clearer in the source code (IMHO), as it shows the programmer's intention better. I am just a little concerned that optimisation hints provided by the programmer via __builtin_unreachable are getting lost at -O2. When the compiler knows that something cannot happen - whether by __builtin_unreachable or by other code analysis - it can often use that information to generate more efficient code. If that information can be used for better code at -O1, but is lost at -O2, then something is wrong in the way that information is collected or passed on inside the compiler. Any case of -O1 generating more efficient code than -O2 is a sign of a problem or limitation. So I am not particularly bothered about this one piece of code - I am reporting the issue because it might be an indication of a wider problem.
next prev parent reply other threads:[~2023-06-14 12:43 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-14 11:01 [Bug c/110249] New: " david at westcontrol dot com 2023-06-14 11:15 ` [Bug c/110249] " amonakov at gcc dot gnu.org 2023-06-14 11:38 ` david at westcontrol dot com 2023-06-14 12:16 ` rguenth at gcc dot gnu.org 2023-06-14 12:43 ` david at westcontrol dot com [this message] 2023-09-19 14:30 ` [Bug tree-optimization/110249] " cvs-commit at gcc dot gnu.org 2023-09-19 15: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-110249-4-Cc7ocBbroQ@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).