public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110891] New: [14 Regression] Dead Code Elimination Regression since r14-2674-gd0de3bf9175
@ 2023-08-03 16:01 theodort at inf dot ethz.ch
  2023-08-03 16:03 ` [Bug tree-optimization/110891] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-08-03 16:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110891
           Summary: [14 Regression] Dead Code Elimination Regression since
                    r14-2674-gd0de3bf9175
           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/njdE3xof4

Given the following code:

void foo(void);
static int a, c = 7, d, o, q;
static int *b = &a, *f, *j = &d, *n = &c, *ae;
static short e, m;
static short *i = &e;
static char r;
void __assert_fail(char *, char *, int, char *) __attribute__((__noreturn__));
static const short g();
static void h();
static int *k(int) {
    (*i)++;
    *j ^= *b;
    return &a;
}
static void l(unsigned p) {
    int *aa = &o;
    h();
    o = 5 ^ g() && p;
    if (f == &d || f == &c || f == &a)
        ;
    else {
        foo();
        __assert_fail("", "", 3, __PRETTY_FUNCTION__);
    }
    *aa ^= *n;
    if (*aa)
        if (!(((p) >= 0) && ((p) <= 0))) {
            __builtin_unreachable();
        }
    k(p);
}
static const short g() { return q; }
static void h() {
    unsigned ag = c;
    d = ag > r ? ag : 0;
    ae = k(c);
    f = ae;
    if (ae == &d || ae == &c || ae == &a)
        ;
    else
        __assert_fail("", "", 4, __PRETTY_FUNCTION__);
}
int main() {
    l(a);
    m || (*b |= 64);
    *b &= 5;
}

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

main:
        subq    $8, %rsp
        movl    c(%rip), %eax
        movl    %eax, d(%rip)
        call    k.isra.0
        cmpq    $c, %rax
        movq    %rax, f(%rip)
        sete    %cl
        cmpq    $a, %rax
        sete    %dil
        cmpq    $d, %rax
        sete    %dl
        orb     %cl, %dl
        jne     .L4
        testb   %dil, %dil
        je      .L15
.L4:
        cmpq    $d, %rax
        je      .L6
        testb   %cl, %cl
        jne     .L6
        testb   %dil, %dil
        je      .L16
.L6:
        call    k.isra.0
        andl    $5, a(%rip)
        xorl    %eax, %eax
        addq    $8, %rsp
        ret
.L16:
        call    foo
        movl    $.LC0, %esi
        movl    $__PRETTY_FUNCTION__.1, %ecx
        movl    $3, %edx
        movq    %rsi, %rdi
        call    __assert_fail
.L15:
        movl    $.LC0, %esi
        movl    $__PRETTY_FUNCTION__.0, %ecx
        movl    $4, %edx
        movq    %rsi, %rdi
        call    __assert_fail

gcc-13.2.0 -O2 eliminates the call to foo:

main:
        subq    $8, %rsp
        movl    c(%rip), %eax
        movl    %eax, d(%rip)
        call    k.isra.0
        cmpq    $c, %rax
        movq    %rax, f(%rip)
        sete    %dl
        cmpq    $d, %rax
        sete    %cl
        orb     %cl, %dl
        jne     .L4
        cmpq    $a, %rax
        jne     .L6
.L4:
        call    k.isra.0
        andl    $5, a(%rip)
        xorl    %eax, %eax
        addq    $8, %rsp
        ret
.L6:
        movl    $.LC0, %esi
        movl    $__PRETTY_FUNCTION__.0, %ecx
        movl    $4, %edx
        movq    %rsi, %rdi
        call    __assert_fail

Bisects to r14-2674-gd0de3bf9175

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

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

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-03 16:01 [Bug tree-optimization/110891] New: [14 Regression] Dead Code Elimination Regression since r14-2674-gd0de3bf9175 theodort at inf dot ethz.ch
2023-08-03 16:03 ` [Bug tree-optimization/110891] " pinskia at gcc dot gnu.org
2023-08-03 16:13 ` pinskia at gcc dot gnu.org
2023-08-04  7:59 ` rguenth at gcc dot gnu.org
2023-08-26  0:00 ` pinskia at gcc dot gnu.org
2023-08-26  0:06 ` pinskia at gcc dot gnu.org
2023-08-26  6:35 ` pinskia at gcc dot gnu.org
2023-08-26  6:35 ` pinskia at gcc dot gnu.org
2023-08-27 23:46 ` pinskia at gcc dot gnu.org
2023-08-28  6:53 ` rguenther at suse dot de
2024-03-07 23:26 ` law at gcc dot gnu.org
2024-03-09  7:01 ` law at gcc dot gnu.org
2024-05-07  7:41 ` [Bug tree-optimization/110891] [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).