public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111801] New: [14 Regression] Missed Dead Code Elimination since r14-4141-gbf6b107e2a3
@ 2023-10-13 15:56 theodort at inf dot ethz.ch
  2023-10-13 15:58 ` [Bug tree-optimization/111801] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-10-13 15:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111801
           Summary: [14 Regression] Missed Dead Code Elimination since
                    r14-4141-gbf6b107e2a3
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: theodort at inf dot ethz.ch
  Target Milestone: ---

https://godbolt.org/z/47fbssWd3

Given the following code:

void foo(void);
static struct {
    signed a;
} b, c, *e = &b;
static struct {
    unsigned d;
} g = {109};
static int f;
static int *h;
static int **i = &h;
int main() {
    f = 1;
    if (b.a) f = 8;
    int *j = *i;
    if (j == &g == 0)
        if (!(((g.d) >= 109) && ((g.d) <= 109))) {
            __builtin_unreachable();
        }
    if (f)
        ;
    else {
        c = *e;
        foo();
    }
}

gcc-trunk -O2 does not eliminate the call to foo:

main:
        movl    $1, f(%rip)
        movl    b(%rip), %esi
        testl   %esi, %esi
        je      .L10
        movl    $8, f(%rip)
.L10:
        cmpq    $g, h(%rip)
        je      .L7
        movl    f(%rip), %ecx
        testl   %ecx, %ecx
        je      .L12
.L7:
        xorl    %eax, %eax
        ret
.L12:
        pushq   %rax
        call    foo
        xorl    %eax, %eax
        popq    %rdx
        ret

gcc-13.2.0 -O2 eliminates the call to foo:

main:
        movl    $1, f(%rip)
        movl    b(%rip), %eax
        testl   %eax, %eax
        je      .L2
        movl    $8, f(%rip)
.L2:
        xorl    %eax, %eax
        ret

Bisects to r14-4141-gbf6b107e2a3

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

* [Bug tree-optimization/111801] [14 Regression] Missed Dead Code Elimination since r14-4141-gbf6b107e2a3
  2023-10-13 15:56 [Bug tree-optimization/111801] New: [14 Regression] Missed Dead Code Elimination since r14-4141-gbf6b107e2a3 theodort at inf dot ethz.ch
@ 2023-10-13 15:58 ` pinskia at gcc dot gnu.org
  2023-10-13 16:11 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-13 15:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0
           Keywords|                            |missed-optimization

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

* [Bug tree-optimization/111801] [14 Regression] Missed Dead Code Elimination since r14-4141-gbf6b107e2a3
  2023-10-13 15:56 [Bug tree-optimization/111801] New: [14 Regression] Missed Dead Code Elimination since r14-4141-gbf6b107e2a3 theodort at inf dot ethz.ch
  2023-10-13 15:58 ` [Bug tree-optimization/111801] " pinskia at gcc dot gnu.org
@ 2023-10-13 16:11 ` pinskia at gcc dot gnu.org
  2024-03-07 21:04 ` law at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-13 16:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-10-13
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
What happens after the patch is `if (j == &g == 0)` still is kept around and we
decide to jump thread into that block and duplicate the `if (f)` there (I
think) and then there is a missing PRE (I think) where we could see that f is
stored and we load from f.

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

* [Bug tree-optimization/111801] [14 Regression] Missed Dead Code Elimination since r14-4141-gbf6b107e2a3
  2023-10-13 15:56 [Bug tree-optimization/111801] New: [14 Regression] Missed Dead Code Elimination since r14-4141-gbf6b107e2a3 theodort at inf dot ethz.ch
  2023-10-13 15:58 ` [Bug tree-optimization/111801] " pinskia at gcc dot gnu.org
  2023-10-13 16:11 ` pinskia at gcc dot gnu.org
@ 2024-03-07 21:04 ` law at gcc dot gnu.org
  2024-03-09  5:37 ` law at gcc dot gnu.org
  2024-05-07  7:42 ` [Bug tree-optimization/111801] [14/15 " rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-07 21:04 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
                 CC|                            |law at gcc dot gnu.org

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

* [Bug tree-optimization/111801] [14 Regression] Missed Dead Code Elimination since r14-4141-gbf6b107e2a3
  2023-10-13 15:56 [Bug tree-optimization/111801] New: [14 Regression] Missed Dead Code Elimination since r14-4141-gbf6b107e2a3 theodort at inf dot ethz.ch
                   ` (2 preceding siblings ...)
  2024-03-07 21:04 ` law at gcc dot gnu.org
@ 2024-03-09  5:37 ` law at gcc dot gnu.org
  2024-05-07  7:42 ` [Bug tree-optimization/111801] [14/15 " rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-09  5:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jeffrey A. Law <law at gcc dot gnu.org> ---

Interestingly enough this is picked up at -O3.  Looks like PRE does a better
job and the result is easier to discover the range for first operand of the
controlling conditional.

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

* [Bug tree-optimization/111801] [14/15 Regression] Missed Dead Code Elimination since r14-4141-gbf6b107e2a3
  2023-10-13 15:56 [Bug tree-optimization/111801] New: [14 Regression] Missed Dead Code Elimination since r14-4141-gbf6b107e2a3 theodort at inf dot ethz.ch
                   ` (3 preceding siblings ...)
  2024-03-09  5:37 ` law at gcc dot gnu.org
@ 2024-05-07  7:42 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-07  7:42 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|14.0                        |14.2

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 14.1 is being released, retargeting bugs to GCC 14.2.

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

end of thread, other threads:[~2024-05-07  7:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-13 15:56 [Bug tree-optimization/111801] New: [14 Regression] Missed Dead Code Elimination since r14-4141-gbf6b107e2a3 theodort at inf dot ethz.ch
2023-10-13 15:58 ` [Bug tree-optimization/111801] " pinskia at gcc dot gnu.org
2023-10-13 16:11 ` pinskia at gcc dot gnu.org
2024-03-07 21:04 ` law at gcc dot gnu.org
2024-03-09  5:37 ` law at gcc dot gnu.org
2024-05-07  7:42 ` [Bug tree-optimization/111801] [14/15 " rguenth 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).