public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110503] New: [13/14 Regression] Dead Code Elimination Regression at -O3 since  r13-322-g7f04b0d786e
@ 2023-06-30 16:34 theodort at inf dot ethz.ch
  2023-06-30 21:21 ` [Bug tree-optimization/110503] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-06-30 16:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110503
           Summary: [13/14 Regression] Dead Code Elimination Regression at
                    -O3 since  r13-322-g7f04b0d786e
           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/h3G76EEW5

Given the following code:

void foo(void);
static int f = 10, g, h;
static int *i = &g, *j = &f, *k = &h;
static char(a)(int b) {
    if (!(((b) >= 1) && ((b) <= 3))) {
        __builtin_unreachable();
    }
    return 0;
}
static char(c)(char d, char e) { return d % e; }
static void l() {
    char m, n;
    unsigned o;
    int *p = &g;
    o = -19;
    for (; o > 22; o = o + 8) {
        int *q = &g;
        g = 30;
        unsigned char d = 60, e = o;
        m = d / e;
        if ((0 || *q) & m == 0)
            ;
        else {
            foo();
            n = c(0 != p, *p);
            a(n);
            *q = 0;
        }
    }
    *i = a(3);
    *k = 0 != *j;
}
int main() {
    l();
    a(h);
}

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

main:
        pushq   %rbx
        movl    $-19, %ebx
        jmp     .L5
        .p2align 4,,10
        .p2align 3
.L8:
        call    foo
        addl    $8, %ebx
.L5:
        movl    $30, g(%rip)
        cmpb    $60, %bl
        jbe     .L8
        addl    $8, %ebx
        cmpl    $5, %ebx
        jne     .L5
        movl    f(%rip), %edx
        xorl    %eax, %eax
        popq    %rbx
        movl    $0, g(%rip)
        testl   %edx, %edx
        setne   %al
        movl    %eax, h(%rip)
        xorl    %eax, %eax
        ret

gcc-12.3.0 -O3 eliminates the call to foo:

main:
        movl    f(%rip), %edx
        xorl    %eax, %eax
        movl    $0, g(%rip)
        testl   %edx, %edx
        setne   %al
        movl    %eax, h(%rip)
        xorl    %eax, %eax
        ret

Bisects to r13-322-g7f04b0d786e

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

end of thread, other threads:[~2024-05-21  9:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-30 16:34 [Bug tree-optimization/110503] New: [13/14 Regression] Dead Code Elimination Regression at -O3 since r13-322-g7f04b0d786e theodort at inf dot ethz.ch
2023-06-30 21:21 ` [Bug tree-optimization/110503] " pinskia at gcc dot gnu.org
2023-06-30 21:42 ` pinskia at gcc dot gnu.org
2023-06-30 21:47 ` pinskia at gcc dot gnu.org
2023-06-30 22:29 ` pinskia at gcc dot gnu.org
2023-07-27  9:27 ` rguenth at gcc dot gnu.org
2023-08-07  9:08 ` pinskia at gcc dot gnu.org
2023-08-26  0:13 ` pinskia at gcc dot gnu.org
2024-03-08 15:28 ` law at gcc dot gnu.org
2024-03-09  7:16 ` law at gcc dot gnu.org
2024-05-21  9:16 ` [Bug tree-optimization/110503] [13/14/15 " jakub 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).