public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110768] New: [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2
@ 2023-07-21 13:59 theodort at inf dot ethz.ch
  2023-07-21 21:07 ` [Bug tree-optimization/110768] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-07-21 13:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110768
           Summary: [14 Regression] Dead Code Elimination Regression since
                    r14-2623-gc11a3aedec2
           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/GsTMz1G9c

Given the following code:

void foo(void);
static int a, b;
int main() {
    {
        short c = 45127;
        char d;
        b = 0;
        for (; b <= 3; b++) {
            if (b) continue;
            d = 0;
            for (; d <= 3; d++) {
                if (!(((c) >= -20409) && ((c) <= 1))) {
                    __builtin_unreachable();
                }
                if (~(0 == a) & 1) return b;
                c = 0;
                for (; c <= 0; c++) a = 3;
            }
        }
        foo();
    }
}

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

main:
        xorl    %r9d, %r9d
        movl    a(%rip), %eax
        xorl    %edx, %edx
        xorl    %esi, %esi
        movl    %r9d, b(%rip)
        xorl    %ecx, %ecx
.L2:
        cmpl    $4, %edx
        je      .L31
        testl   %edx, %edx
        jne     .L3
        testl   %eax, %eax
        je      .L4
.L24:
        testb   %sil, %sil
        je      .L5
        xorl    %r8d, %r8d
        movl    %r8d, b(%rip)
.L5:
        testb   %cl, %cl
        je      .L27
        movl    %eax, a(%rip)
        jmp     .L27
.L4:
        movl    $3, %eax
        movb    $1, %cl
        jmp     .L24
.L3:
        incl    %edx
        movb    $1, %sil
        jmp     .L2
.L31:
        pushq   %rdi
        testb   %sil, %sil
        je      .L9
        movl    $4, b(%rip)
.L9:
        testb   %cl, %cl
        je      .L10
        movl    %eax, a(%rip)
.L10:
        call    foo
        xorl    %eax, %eax
        popq    %rdx
        ret
.L27:
        xorl    %eax, %eax
        ret

gcc-13.1.0 -Os eliminates the call to foo:

main:
        xorl    %eax, %eax
        cmpl    $0, a(%rip)
        movl    %eax, b(%rip)
        jne     .L2
        movl    $3, a(%rip)
.L2:
        xorl    %eax, %eax
        ret

Bisects to r14-2623-gc11a3aedec2

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

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

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21 13:59 [Bug tree-optimization/110768] New: [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2 theodort at inf dot ethz.ch
2023-07-21 21:07 ` [Bug tree-optimization/110768] " pinskia at gcc dot gnu.org
2023-07-21 22:54 ` pinskia at gcc dot gnu.org
2023-08-25 23:34 ` pinskia at gcc dot gnu.org
2024-01-10 14:52 ` jamborm at gcc dot gnu.org
2024-01-11  1:01 ` pinskia at gcc dot gnu.org
2024-01-13  4:01 ` 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
2024-01-13  4:41 ` 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).