public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "vsevolod.livinskiy at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109342] New: [13 Regression] Wrong code with -O2 Date: Thu, 30 Mar 2023 07:12:10 +0000 [thread overview] Message-ID: <bug-109342-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109342 Bug ID: 109342 Summary: [13 Regression] Wrong code with -O2 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vsevolod.livinskiy at gmail dot com Target Milestone: --- Link to the Compiler Explorer: https://godbolt.org/z/zKqcna3vn Reproducer: #include <stdio.h> unsigned long long int var_4 = 42; unsigned long long int var_14 = 10; unsigned char var_16 = 1; unsigned short var_18 = 0; short var_75; inline const int &foo(const int &b, const int &c) { return b < c ? c : b; } inline unsigned long long &bar(unsigned long long &b, unsigned long long &c) { return !c ? c : b; } void test(unsigned long long var_4, unsigned long long var_14, unsigned char var_16, unsigned short var_18) __attribute__((noipa)); void test(unsigned long long var_4, unsigned long long var_14, unsigned char var_16, unsigned short var_18) { for (bool h = 0; h < (bool)foo(var_16 ? -7 : 4, var_4 ? var_4 : var_18); h = 2) var_75 = bar(var_4, var_14); } int main() { test(var_4, var_14, var_16, var_18); printf("%hd\n", var_75); if (var_75 != 42) __builtin_abort(); } Error: >$ g++ -O0 small.cpp && ./a.out 42 >$ g++ -O2 small.cpp && ./a.out 0 Aborted (core dumped) gcc version 13.0.1 20230329 (3be4e43a6a0f429648ea188c8e110b74268fed27)
next reply other threads:[~2023-03-30 7:12 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-30 7:12 vsevolod.livinskiy at gmail dot com [this message] 2023-03-30 7:26 ` [Bug tree-optimization/109342] " rguenth at gcc dot gnu.org 2023-03-30 7:41 ` [Bug tree-optimization/109342] [13 Regression] Wrong code with -O2 since r13-5348-gc29d85359add80 marxin at gcc dot gnu.org 2023-03-30 7:45 ` rguenth at gcc dot gnu.org 2023-03-30 11:02 ` cvs-commit at gcc dot gnu.org 2023-03-30 11:02 ` 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-109342-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).