public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111456] New: [14 Regression] Dead Code Elimination Regression since r14-3719-gb34f3736356
@ 2023-09-18  9:45 theodort at inf dot ethz.ch
  2023-09-18 10:41 ` [Bug tree-optimization/111456] " rguenth at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-09-18  9:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111456
           Summary: [14 Regression] Dead Code Elimination Regression since
                    r14-3719-gb34f3736356
           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/jqqP5baY8

Given the following code:

void foo(void);
static int i;
static int *j = &i;
static char l;
static void(a)(char) {}
static short(b)(short c, short d) { return c - d; }
static short(e)(short f, int g) {
    return f < 0 || g < 0 || g >= 32 ? f : f >> g;
}
static short(h)(short f, int g) { return g >= 2 ?: f >> g; }
static char k(char m, short n) {
    short o;
    int *p = &i;
    if (!(((m) >= 1) && ((m) <= 1))) {
        __builtin_unreachable();
    }
    o = e(i, i);
    if (h(1, o))
        ;
    else {
        m = 0;
        for (; m >= -20; m = b(m, 9))
            if (a(i), n) {
                if (*p)
                    ;
                else
                    foo();
                ;
            } else
                return l;
    }
    return i;
}
int main() { k(0 <= 0 > *j, i); }

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

main:
        movl    i(%rip), %eax
        testw   %ax, %ax
        js      .L6
        testl   %eax, %eax
        jne     .L6
.L9:
        xorl    %eax, %eax
        ret
        .p2align 4,,10
        .p2align 3
.L6:
        movswl  %ax, %edx
        cmpw    $1, %ax
        jg      .L9
        testl   %edx, %edx
        je      .L9
        pushq   %rbx
        movl    $3, %ebx
.L5:
        cmpl    $0, i(%rip)
        je      .L13
.L4:
        subb    $1, %bl
        jne     .L5
        xorl    %eax, %eax
        popq    %rbx
        ret
.L13:
        call    foo
        jmp     .L4

gcc-13.2.0 -O2 eliminates the call to foo:

main:
        xorl    %eax, %eax
        ret

Bisects to r14-3719-gb34f3736356

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

end of thread, other threads:[~2023-09-26 15:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-18  9:45 [Bug tree-optimization/111456] New: [14 Regression] Dead Code Elimination Regression since r14-3719-gb34f3736356 theodort at inf dot ethz.ch
2023-09-18 10:41 ` [Bug tree-optimization/111456] " rguenth at gcc dot gnu.org
2023-09-18 14:48 ` pinskia at gcc dot gnu.org
2023-09-18 23:34 ` pinskia at gcc dot gnu.org
2023-09-19  0:52 ` pinskia at gcc dot gnu.org
2023-09-19  2:46 ` pinskia at gcc dot gnu.org
2023-09-20 22:21 ` pinskia at gcc dot gnu.org
2023-09-21  2:44 ` pinskia at gcc dot gnu.org
2023-09-26 15:01 ` cvs-commit at gcc dot gnu.org
2023-09-26 15:02 ` 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).