public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110450] New: [14 Regression] Dead Code Elimination Regression at -O2 since r14-261-g0ef3756adf0
@ 2023-06-28 10:21 theodort at inf dot ethz.ch
  2023-06-29  6:52 ` [Bug tree-optimization/110450] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-06-28 10:21 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110450
           Summary: [14 Regression] Dead Code Elimination Regression at
                    -O2 since r14-261-g0ef3756adf0
           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/KqcYxfevj

Given the following code:

void foo(void);
static int a = 1;
static int *b = &a, *c = &a;
static short d, e;
static char f = 11;
static char(g)(char h, int i) { return h << i; }
int main() {
    if (f) *c = g(0 >= a, 3);
    e = *c;
    d = e % f;
    if (d) {
        __builtin_unreachable();
    } else if (*b)
        foo();
    ;
}

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

main:
        movl    a(%rip), %eax
        xorl    %edx, %edx
        testl   %eax, %eax
        setle   %dl
        leal    0(,%rdx,8), %edx
        movl    %edx, a(%rip)
        jle     .L8
        xorl    %eax, %eax
        ret
.L8:
        pushq   %rax
        call    foo
        xorl    %eax, %eax
        popq    %rdx
        ret

gcc-13.1.0 -O2 eliminates the call to foo:

main:
        movl    a(%rip), %edx
        xorl    %eax, %eax
        testl   %edx, %edx
        setle   %al
        leal    0(,%rax,8), %eax
        movl    %eax, a(%rip)
        xorl    %eax, %eax
        ret

Bisects to r14-261-g0ef3756adf0

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

end of thread, other threads:[~2024-01-13  4:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-28 10:21 [Bug tree-optimization/110450] New: [14 Regression] Dead Code Elimination Regression at -O2 since r14-261-g0ef3756adf0 theodort at inf dot ethz.ch
2023-06-29  6:52 ` [Bug tree-optimization/110450] " rguenth at gcc dot gnu.org
2023-07-01 20:51 ` pinskia at gcc dot gnu.org
2023-11-24  4:01 ` pinskia at gcc dot gnu.org
2024-01-10 15:13 ` jamborm at gcc dot gnu.org
2024-01-11  0:56 ` pinskia at gcc dot gnu.org
2024-01-13  4:39 ` cvs-commit at gcc dot gnu.org
2024-01-13  4:40 ` 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).