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

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

            Bug ID: 111799
           Summary: [14 Regression] Missed Dead Code Elimination since
                    r14-2365-g2e406f0753e
           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/bqcvMcbqn

Given the following code:

void foo(void);
static struct d {
    short e;
} g = {205}, *h = &g;
static int i;
static int *j, *a = &i;
static int **k = &j;
static int ****l;
static int *****m;
static char(n)(char b, char c) { return b + c; }
static char(o)(char b, char c) { return b * c; }
static short(p)(short f) {
    if (!(((f) >= 1) && ((f) <= 65459))) {
        __builtin_unreachable();
    }
    return 0;
}
static int *q(short);
static void s(struct d) { *k = q(i); }
static int *q(short ad) {
    int b = *a;
    ad = -21;
    for (; ad; ad = n(ad, 7)) p((ad ^ b && *a) <= *a);
    return *k;
}
int main() {
    i = 0;
    for (;; i = 1) {
        q(3);
        char r = o(126 | 1, g.e);
        p(r);
        s(*h);
        if (i) break;
        m = &l;
    }
    if (m)
        ;
    else
        foo();
    ;
}

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

main:
        movl    $2, %esi
        xorl    %ecx, %ecx
        xorl    %r9d, %r9d
        movl    $8, %edi
        movl    $0, i(%rip)
        .p2align 4,,10
        .p2align 3
.L10:
        movl    $-21, %eax
.L2:
        testl   %ecx, %ecx
        je      .L29
        leal    7(%rax), %edx
        movsbw  %dl, %r8w
        testb   %dl, %dl
        je      .L23
.L5:
        movl    $8, %eax
        cmpb    $1, %dl
        je      .L2
        movl    %r8d, %eax
        leal    7(%rax), %edx
        movsbw  %dl, %r8w
        testb   %dl, %dl
        jne     .L5
        .p2align 4,,10
        .p2align 3
.L23:
        movl    $-21, %eax
        addb    $7, %al
        je      .L30
.L9:
        movsbl  %al, %edx
        cmpl    %edx, %ecx
        cmove   %edi, %eax
        cbtw
        addb    $7, %al
        jne     .L9
.L30:
        cmpl    $1, %esi
        je      .L31
        movl    $1, %esi
        movl    $1, %ecx
        movl    $1, %r9d
        jmp     .L10
        .p2align 4,,10
        .p2align 3
.L29:
        testb   $1, %al
        je      .L4
        leal    7(%rax), %edx
        movsbw  %dl, %ax
        testb   %dl, %dl
        je      .L23
.L4:
        leal    14(%rax), %edx
        movsbw  %dl, %ax
        testb   %dl, %dl
        jne     .L4
        jmp     .L23
        .p2align 4,,10
        .p2align 3
.L31:
        testb   %r9b, %r9b
        je      .L11
        movq    $l, m(%rip)
        movl    %ecx, i(%rip)
.L25:
        xorl    %eax, %eax
        ret
.L11:
        cmpq    $0, m(%rip)
        jne     .L25
        pushq   %rax
        call    foo
        xorl    %eax, %eax
        popq    %rdx
        ret

gcc-13.2.0 -O2 eliminates the call to foo:

main:
        movq    $l, m(%rip)
        xorl    %eax, %eax
        movl    $1, i(%rip)
        ret

Bisects to r14-2365-g2e406f0753e

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

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

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-13 15:46 [Bug tree-optimization/111799] New: [14 Regression] Missed Dead Code Elimination since r14-2365-g2e406f0753e theodort at inf dot ethz.ch
2023-10-13 15:48 ` [Bug tree-optimization/111799] " pinskia at gcc dot gnu.org
2023-10-13 15:50 ` pinskia at gcc dot gnu.org
2023-10-13 15:52 ` pinskia at gcc dot gnu.org
2023-10-16  4:08 ` pinskia at gcc dot gnu.org
2023-10-17 11:08 ` theodort at inf dot ethz.ch
2023-10-18 23:55 ` [Bug middle-end/111799] " pinskia at gcc dot gnu.org
2024-03-07 21:04 ` law at gcc dot gnu.org
2024-03-09  5:43 ` law at gcc dot gnu.org
2024-05-07  7:42 ` [Bug middle-end/111799] [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).