public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106381] New: DCE depends on used programming language (C vs C++)
@ 2022-07-21 9:33 tmayerl at student dot ethz.ch
2023-05-18 17:23 ` [Bug tree-optimization/106381] " pinskia at gcc dot gnu.org
2023-05-19 6:48 ` xry111 at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: tmayerl at student dot ethz.ch @ 2022-07-21 9:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106381
Bug ID: 106381
Summary: DCE depends on used programming language (C vs C++)
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
used language (C vs C++).
GCC detects that the if expression in the following code snippet evaluates to
false and thus removes the dead code. The code is compiled as C++ code:
#include <stdio.h>
#include <stdbool.h>
static void __attribute__ ((noinline)) DCEMarker0_() {printf("DCE2.0");}
void f(unsigned s, unsigned c) {
if (((!s == !c) && c && !(s))) {
DCEMarker0_();
}
}
However, if the same code is compiled as C code, GCC cannot eliminate the dead
code anymore.
This can also be seen via the following Compiler Explorer link:
https://godbolt.org/z/a9ned9Exb
(Might be related to 106379 and 106380)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/106381] DCE depends on used programming language (C vs C++)
2022-07-21 9:33 [Bug c/106381] New: DCE depends on used programming language (C vs C++) tmayerl at student dot ethz.ch
@ 2023-05-18 17:23 ` pinskia at gcc dot gnu.org
2023-05-19 6:48 ` xry111 at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-18 17:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106381
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-05-18
Ever confirmed|0 |1
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually it is worse in GCC 13. Both the C and C++ front-ends produced IR does
not get optimized.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/106381] DCE depends on used programming language (C vs C++)
2022-07-21 9:33 [Bug c/106381] New: DCE depends on used programming language (C vs C++) tmayerl at student dot ethz.ch
2023-05-18 17:23 ` [Bug tree-optimization/106381] " pinskia at gcc dot gnu.org
@ 2023-05-19 6:48 ` xry111 at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-05-19 6:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106381
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xry111 at gcc dot gnu.org
--- Comment #2 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Even if we change "unsigned" to "bool", it still does not get optimized with
GCC 13.
So generally should we try to solve 2-SAT if a boolean expression is a 2-SAT
form?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-19 6:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-21 9:33 [Bug c/106381] New: DCE depends on used programming language (C vs C++) tmayerl at student dot ethz.ch
2023-05-18 17:23 ` [Bug tree-optimization/106381] " pinskia at gcc dot gnu.org
2023-05-19 6:48 ` xry111 at gcc dot gnu.org
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).