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

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

            Bug ID: 111294
           Summary: [14 Regression] Missed Dead Code Elimination since
                    r14-573-g69f1a8af45d
           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/7GTzj8Ea1

Given the following code:

void foo(void);
static short a;
static int b, c, d;
static int *e, *f = &d;
static int **g = &e;
static unsigned char h;
static short(i)(short j, int k) { return j > k ?: j; }
static char l() {
    if (a) return b;
    return c;
}
int main() {
    b = 0;
    for (; b < 5; ++b)
        ;
    h = l();
    if (a ^ 3 >= i(h, 11))
        a = 0;
    else {
        *g = f;
        if (e == &d & b) {
            __builtin_unreachable();
        } else
            foo();
        ;
    }
}

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

main:
        movswl  a(%rip), %eax
        xorl    %edx, %edx
        movl    $5, b(%rip)
        testw   %ax, %ax
        je      .L2
        movl    $5, %edx
.L2:
        cmpl    $3, %edx
        setle   %dl
        movzbl  %dl, %edx
        cmpl    %edx, %eax
        je      .L3
        movw    $0, a(%rip)
        xorl    %eax, %eax
        ret
.L3:
        pushq   %rax
        movq    $d, e(%rip)
        call    foo
        xorl    %eax, %eax
        popq    %rdx
        ret

gcc-13.2.0 -Os eliminates the call to foo:

main:
        movl    $5, b(%rip)
        xorl    %eax, %eax
        movw    $0, a(%rip)
        ret

Bisects to r14-573-g69f1a8af45d

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

end of thread, other threads:[~2023-09-18  8:57 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-05 15:05 [Bug tree-optimization/111294] New: [14 Regression] Missed Dead Code Elimination since r14-573-g69f1a8af45d theodort at inf dot ethz.ch
2023-09-05 15:43 ` [Bug tree-optimization/111294] " pinskia at gcc dot gnu.org
2023-09-05 15:47 ` pinskia at gcc dot gnu.org
2023-09-05 16:03 ` pinskia at gcc dot gnu.org
2023-09-05 16:32 ` pinskia at gcc dot gnu.org
2023-09-05 21:02 ` pinskia at gcc dot gnu.org
2023-09-12 11:08 ` rguenth at gcc dot gnu.org
2023-09-13 13:35 ` rguenth at gcc dot gnu.org
2023-09-13 15:51 ` pinskia at gcc dot gnu.org
2023-09-14  7:12 ` rguenth at gcc dot gnu.org
2023-09-14  7:12 ` rguenth at gcc dot gnu.org
2023-09-14  7:32 ` rguenth at gcc dot gnu.org
2023-09-14 11:17 ` cvs-commit at gcc dot gnu.org
2023-09-18  8:56 ` cvs-commit at gcc dot gnu.org
2023-09-18  8:57 ` 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).