public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "xxs_chy at outlook dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/115034] New: Missed optimization: reduntant store of identical value in the slot Date: Fri, 10 May 2024 14:34:44 +0000 [thread overview] Message-ID: <bug-115034-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115034 Bug ID: 115034 Summary: Missed optimization: reduntant store of identical value in the slot Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: xxs_chy at outlook dot com Target Milestone: --- Godbolt link: https://godbolt.org/z/fdxKaxGoj ``` int src(int* outl, bool c1, bool c2) { int a; *outl = 0; if (c1) if (c2) { dummy(); return 0; } else { a = 1; } else { // we don't need to assign a = 0 a = 0; } *outl = a; return 0; } ``` can be transformed into: ``` int tgt(int* outl, bool c1, bool c2) { int a; *outl = 0; if (c1) { if (c2) { dummy(); return 0; } else { a = 1; } } else { return 0; } *outl = 1; return 0; } ``` Because "*outl = 0" is known at the entry, the path "a = 0 -> *outl = 0" can be cut off. That is, we can move "*outl = 1" into the path where c1 is true.
next reply other threads:[~2024-05-10 14:34 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-10 14:34 xxs_chy at outlook dot com [this message] 2024-05-10 14:43 ` [Bug tree-optimization/115034] " pinskia at gcc dot gnu.org 2024-05-10 15:32 ` xxs_chy at outlook dot com 2024-05-13 9:33 ` 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-115034-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).