public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "denis.campredon at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/98028] New: __builtin_sub_overflow_p not folded to const when some constraints are known Date: Fri, 27 Nov 2020 10:50:50 +0000 [thread overview] Message-ID: <bug-98028-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98028 Bug ID: 98028 Summary: __builtin_sub_overflow_p not folded to const when some constraints are known Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: denis.campredon at gmail dot com Target Milestone: --- According to godbolt, f1 used to be optimised with gcc 7. The same problem can be seen with signed types (and maybe more conditions?). All the following functions should be only one instruction plus ret with O2 ----------------- unsigned f1(unsigned i, unsigned j) { if (j != i) __builtin_unreachable(); return __builtin_sub_overflow_p(i, j, (unsigned)0); } unsigned f2(unsigned i, unsigned j) { if (j > i) __builtin_unreachable(); return __builtin_sub_overflow_p(i, j, (unsigned)0); } unsigned f3(unsigned i, unsigned j) { if (j >= i) __builtin_unreachable(); return __builtin_sub_overflow_p(i, j, (unsigned)0); } unsigned f4(unsigned i, unsigned j) { if (j < i) __builtin_unreachable(); return __builtin_sub_overflow_p(i, j, (unsigned)0); } -----------------
next reply other threads:[~2020-11-27 10:50 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-27 10:50 denis.campredon at gmail dot com [this message] 2020-11-27 11:12 ` [Bug tree-optimization/98028] [8/9/10/11 Regression] " jakub at gcc dot gnu.org 2021-01-14 9:49 ` rguenth at gcc dot gnu.org 2021-01-14 14:23 ` amacleod at redhat dot com 2021-02-12 13:41 ` jakub at gcc dot gnu.org 2021-02-12 14:43 ` amacleod at redhat dot com 2021-05-14 9:54 ` [Bug tree-optimization/98028] [9/10/11/12 " jakub at gcc dot gnu.org 2021-06-01 8:19 ` rguenth at gcc dot gnu.org 2022-05-27 9:44 ` [Bug tree-optimization/98028] [10/11/12/13 " rguenth at gcc dot gnu.org 2022-06-28 10:42 ` jakub at gcc dot gnu.org 2023-07-07 10:38 ` [Bug tree-optimization/98028] [11/12/13/14 " 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-98028-4@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).