public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106380] New: DCE depends on datatype used (bool vs unsigned)
@ 2022-07-21  9:23 tmayerl at student dot ethz.ch
  2022-08-08 22:08 ` [Bug tree-optimization/106380] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: tmayerl at student dot ethz.ch @ 2022-07-21  9:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106380

            Bug ID: 106380
           Summary: DCE depends on datatype used (bool vs unsigned)
           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
datatype used (bool vs unsigned).

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 s, bool c) {
    if (((!s == !c) && c && !(s))) {
        DCEMarker0_();
    }
}

In the following snippet the datatype is switched to unsigned (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(unsigned s, unsigned c) {
    if (((!s == !c) && c && !(s))) {
        DCEMarker0_();
    }
}


This can also be seen via the following Compiler Explorer link: 
https://godbolt.org/z/aMcEvEaYa

(Might be related to 106379)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/106380] DCE depends on datatype used (bool vs unsigned)
  2022-07-21  9:23 [Bug c/106380] New: DCE depends on datatype used (bool vs unsigned) tmayerl at student dot ethz.ch
@ 2022-08-08 22:08 ` pinskia at gcc dot gnu.org
  2023-05-18 17:20 ` pinskia at gcc dot gnu.org
  2023-05-18 17:20 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-08 22:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106380

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu.org
           Severity|normal                      |enhancement

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/106380] DCE depends on datatype used (bool vs unsigned)
  2022-07-21  9:23 [Bug c/106380] New: DCE depends on datatype used (bool vs unsigned) tmayerl at student dot ethz.ch
  2022-08-08 22:08 ` [Bug tree-optimization/106380] " pinskia at gcc dot gnu.org
@ 2023-05-18 17:20 ` pinskia at gcc dot gnu.org
  2023-05-18 17:20 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-18 17:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106380

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-05-18
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Mine.

In this case if we fold:
  _1 = ~s_4(D);
  _2 = _1 & c_5(D);

to
s < c

Then the rest will be optimized by normally.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/106380] DCE depends on datatype used (bool vs unsigned)
  2022-07-21  9:23 [Bug c/106380] New: DCE depends on datatype used (bool vs unsigned) tmayerl at student dot ethz.ch
  2022-08-08 22:08 ` [Bug tree-optimization/106380] " pinskia at gcc dot gnu.org
  2023-05-18 17:20 ` pinskia at gcc dot gnu.org
@ 2023-05-18 17:20 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-18 17:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106380

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-18 17:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-21  9:23 [Bug c/106380] New: DCE depends on datatype used (bool vs unsigned) tmayerl at student dot ethz.ch
2022-08-08 22:08 ` [Bug tree-optimization/106380] " pinskia at gcc dot gnu.org
2023-05-18 17:20 ` pinskia at gcc dot gnu.org
2023-05-18 17:20 ` pinskia 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).