public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/105973] Wrong branch prediction for if (COND) { if(x) noreturn1(); else noreturn2(); } Date: Wed, 15 Jun 2022 10:56:02 +0000 [thread overview] Message-ID: <bug-105973-4-VwK6txfLxs@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-105973-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105973 --- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- If the two noreturn functions are replaced with throwing exceptions, I get the behaviour I expect: if (n > (__PTRDIFF_MAX__ / sizeof(T))) { if (n > (__SIZE_MAX__ / sizeof(T))) throw 1; throw 2L; } This is correctly treated as unlikely. So the problem only seems to happen because of libstdc++'s convention of using named noreturn functions to throw exceptions (which is done to simplify -fno-exceptions cases). This probably doesn't affect much user code. It also seem that if I explicitly add the 'cold' attribute to those noreturn functions, I get the behaviour I expect. So maybe it's not worth spending any effort on this, and I should just change __attribute__((__noreturn__)) to __attribute__((__noreturn__,__cold)) for every function in libstdc++-v3/include/bits/functexcept.h
next prev parent reply other threads:[~2022-06-15 10:56 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-14 11:46 [Bug tree-optimization/105973] New: " redi at gcc dot gnu.org 2022-06-14 11:49 ` [Bug tree-optimization/105973] " redi at gcc dot gnu.org 2022-06-14 11:54 ` redi at gcc dot gnu.org 2022-06-15 9:07 ` rguenth at gcc dot gnu.org 2022-06-15 10:12 ` hubicka at kam dot mff.cuni.cz 2022-06-15 10:56 ` redi at gcc dot gnu.org [this message] 2022-06-16 14:08 ` marxin at gcc dot gnu.org 2022-06-17 18:40 ` hubicka at kam dot mff.cuni.cz 2023-01-11 10:27 ` marxin at gcc dot gnu.org 2023-03-16 14:04 ` marxin 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-105973-4-VwK6txfLxs@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).