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 c/106379] New: DCE depends on order Date: Thu, 21 Jul 2022 09:13:15 +0000 [thread overview] Message-ID: <bug-106379-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106379 Bug ID: 106379 Summary: DCE depends on order Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: tmayerl at student dot ethz.ch Target Milestone: --- In some cases, the compiler's ability to eliminate dead code depends on the order of the sub-expressions within the if. GCC detects that the if expression in the following code snippet evaluates to false and thus removes the dead code: #include <stdio.h> #include <stdbool.h> static void __attribute__ ((noinline)) DCEMarker0_() {printf("DCE2.0");} void f(bool c, bool s) { if (((!c == !s) && !(c) && s)) { DCEMarker0_(); } } In the following snippet the expressions are swapped (the semantics stay the same). However, GCC cannot eliminate the dead code anymore: #include <stdio.h> #include <stdbool.h> static void __attribute__ ((noinline)) DCEMarker0_() {printf("DCE2.0");} void f(bool c, bool s) { if ((!s == !c) && s && !(c)) { DCEMarker0_(); } } This can also be seen via the following Compiler Explorer link: https://godbolt.org/z/vTqhc46qY
next reply other threads:[~2022-07-21 9:13 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-21 9:13 tmayerl at student dot ethz.ch [this message] 2022-07-21 9:48 ` [Bug tree-optimization/106379] " rguenth at gcc dot gnu.org 2022-07-21 11:23 ` rguenth at gcc dot gnu.org 2022-07-21 11:24 ` cvs-commit at gcc dot gnu.org 2022-08-08 20:36 ` amacleod at redhat dot com 2023-05-18 17:26 ` pinskia at gcc dot gnu.org 2023-07-13 18:39 ` pinskia at gcc dot gnu.org 2023-09-17 5:46 ` 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-106379-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).