public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "tmayerl at student dot ethz.ch" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106570] New: DCE sometimes fails with depending if statements Date: Tue, 09 Aug 2022 11:35:38 +0000 [thread overview] Message-ID: <bug-106570-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106570 Bug ID: 106570 Summary: DCE sometimes fails with depending if statements Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: tmayerl at student dot ethz.ch Target Milestone: --- Sometimes, DCE fails when multiple if statements are used. For example, GCC detects that the following if statements always evaluate to false and thus removes the dead code: #include <stdio.h> #include <stdbool.h> void DCEMarker0_(); void f(bool s, bool c) { if (!c == !s) { if (s && !c) { DCEMarker0_(); } } } In the next snippet, the if statements are used to set a variable. This variable is then used in the next if statement. However, GCC now fails to detect and eliminate the dead code: #include <stdio.h> #include <stdbool.h> void DCEMarker0_(); void f(bool s, bool c) { int intermediate_result = 0; if (!c == !s) { if (s && !c) { intermediate_result = 1; } } if (((!c == !s) && (s && !c)) || intermediate_result) { DCEMarker0_(); } } This is actually a regression: It works fine until GCC 11.3. This can also be seen via the following Compiler Explorer link: https://godbolt.org/z/n9dKMfqsd
next reply other threads:[~2022-08-09 11:35 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-08-09 11:35 tmayerl at student dot ethz.ch [this message] 2022-08-09 13:15 ` [Bug tree-optimization/106570] [12/13 Regression] DCE sometimes fails with depending if statements since r12-2305-g398572c1544d8b75 marxin at gcc dot gnu.org 2022-08-09 13:28 ` amacleod at redhat dot com 2022-08-09 13:48 ` rguenth at gcc dot gnu.org 2022-08-10 13:53 ` rguenth at gcc dot gnu.org 2023-03-11 17:07 ` pinskia at gcc dot gnu.org 2023-03-14 13:16 ` marxin at gcc dot gnu.org 2023-05-08 12:25 ` [Bug tree-optimization/106570] [12/13/14 " rguenth at gcc dot gnu.org 2023-07-13 18:38 ` pinskia 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-106570-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).