public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/108419] New: [13 Regression] Dead Code Elimination Regression at -O2 since r13-440-g98e475a8f58
@ 2023-01-16 15:18 yann at ywg dot ch
  2023-01-17  1:58 ` [Bug tree-optimization/108419] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: yann at ywg dot ch @ 2023-01-16 15:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108419
           Summary: [13 Regression] Dead Code Elimination Regression at
                    -O2 since r13-440-g98e475a8f58
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yann at ywg dot ch
  Target Milestone: ---

Created attachment 54281
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54281&action=edit
case as file

cat case.c #1565
static int b = 6, c;
long d;
short h;
short i;
short j;
char k;
void foo();
short(a)(short l, short m) { return l + m; }
short f();
short g(unsigned short, int, char, long);
static signed char e() {
  unsigned n = -10;
  for (; n >= 14; n = a(n, 8)) {
    i = g(b, 0, c, b);
    j = f(i, b, d < j, 5, 7, 9, 5);
    k = 200 + n;
    h = k % 5;
    if (h)
      ;
    else
      foo();
  }
  return n;
}
int main() {
  b || e();
  b = 1;
}

`gcc-f99d7d669eaa2830eb5878df4da67e77ec791522 (trunk) -O2` can not eliminate
`foo` but `gcc-releases/gcc-12.2.0 -O2` can.

`gcc-f99d7d669eaa2830eb5878df4da67e77ec791522 (trunk) -O2 -S -o /dev/stdout
case.c`
--------- OUTPUT ---------
main:
.LFB2:
        .cfi_startproc
        movl    b(%rip), %esi
        testl   %esi, %esi
        je      .L12
        movl    $1, b(%rip)
        xorl    %eax, %eax
        ret
.L12:
        pushq   %r12
        .cfi_def_cfa_offset 16
        .cfi_offset 12, -16
        movl    $-10, %r12d
        pushq   %rbp
        .cfi_def_cfa_offset 24
        .cfi_offset 6, -24
        movl    $2, %ebp
        pushq   %rbx
        .cfi_def_cfa_offset 32
        .cfi_offset 3, -32
        movl    $5, %ebx
.L6:
        movslq  b(%rip), %rcx
        xorl    %edx, %edx
        xorl    %esi, %esi
        movzwl  %cx, %edi
        call    g
        movl    b(%rip), %esi
        movl    $5, %ecx
        movswq  j(%rip), %rdx
        movw    %ax, i(%rip)
        cmpq    d(%rip), %rdx
        movswl  %ax, %edi
        movl    $9, %r9d
        pushq   %rax
        .cfi_def_cfa_offset 40
        setg    %dl
        movl    $7, %r8d
        xorl    %eax, %eax
        pushq   $5
        .cfi_def_cfa_offset 48
        movzbl  %dl, %edx
        call    f
        movw    %ax, j(%rip)
        leal    -56(%r12), %eax
        movb    %al, k(%rip)
        cbtw
        idivb   %bl
        movl    %eax, %edx
        sarw    $8, %dx
        shrw    $8, %ax
        movw    %dx, h(%rip)
        popq    %rdx
        .cfi_def_cfa_offset 40
        popq    %rcx
        .cfi_def_cfa_offset 32
        je      .L13
.L5:
        addl    $8, %r12d
        subl    $1, %ebp
        movswl  %r12w, %r12d
        je      .L14
        movl    $1, %ebp
        jmp     .L6
.L14:
        movl    $1, b(%rip)
        popq    %rbx
        .cfi_remember_state
        .cfi_def_cfa_offset 24
        xorl    %eax, %eax
        popq    %rbp
        .cfi_def_cfa_offset 16
        popq    %r12
        .cfi_def_cfa_offset 8
        ret
.L13:
        .cfi_restore_state
        xorl    %eax, %eax
        call    foo
        jmp     .L5
---------- END OUTPUT ---------


`gcc-releases/gcc-12.2.0 -O2 -S -o /dev/stdout case.c`
--------- OUTPUT ---------
main:
.LFB2:
        .cfi_startproc
        movl    b(%rip), %r9d
        testl   %r9d, %r9d
        je      .L11
        movl    $1, b(%rip)
        xorl    %eax, %eax
        ret
.L11:
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movl    $-66, %ebp
        pushq   %rbx
        .cfi_def_cfa_offset 24
        .cfi_offset 3, -24
        movl    $5, %ebx
        pushq   %r8
        .cfi_def_cfa_offset 32
.L5:
        movslq  b(%rip), %rcx
        xorl    %edx, %edx
        xorl    %esi, %esi
        movzwl  %cx, %edi
        call    g
        movswq  j(%rip), %rdx
        cmpq    d(%rip), %rdx
        movl    $9, %r9d
        pushq   %rcx
        .cfi_def_cfa_offset 40
        setg    %dl
        movl    b(%rip), %esi
        movswl  %ax, %edi
        pushq   $5
        .cfi_def_cfa_offset 48
        movzbl  %dl, %edx
        movl    $7, %r8d
        movl    $5, %ecx
        movw    %ax, i(%rip)
        xorl    %eax, %eax
        call    f
        popq    %rsi
        .cfi_def_cfa_offset 40
        popq    %rdi
        .cfi_def_cfa_offset 32
        movb    %bpl, k(%rip)
        movw    %ax, j(%rip)
        movsbw  %bpl, %ax
        idivb   %bl
        sarw    $8, %ax
        movw    %ax, h(%rip)
        cmpb    $-58, %bpl
        je      .L12
        movl    $-58, %ebp
        jmp     .L5
.L12:
        movl    $1, b(%rip)
        xorl    %eax, %eax
        popq    %rdx
        .cfi_def_cfa_offset 24
        popq    %rbx
        .cfi_def_cfa_offset 16
        popq    %rbp
        .cfi_def_cfa_offset 8
        ret
---------- END OUTPUT ---------


Bisects to: r13-440-g98e475a8f58

commit 98e475a8f58ca3ba6e9bd5c9276efce4236f5d26
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Fri Mar 18 11:50:33 2022 -0400

    Fix return value in ranger_cache::get_global_range.

    The "is_current" status is returned by parameter, but was being returned by
the
    function as well instead of true if NAME had a global range, and FALSE
    if it did not.

            * gimple-range-cache.cc (ranger_cache::get_global_range): Return
the
            had_global value instead.

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

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

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-16 15:18 [Bug tree-optimization/108419] New: [13 Regression] Dead Code Elimination Regression at -O2 since r13-440-g98e475a8f58 yann at ywg dot ch
2023-01-17  1:58 ` [Bug tree-optimization/108419] " pinskia at gcc dot gnu.org
2023-01-17 13:26 ` marxin at gcc dot gnu.org
2023-02-21 13:09 ` rguenth at gcc dot gnu.org
2023-02-21 22:11 ` pinskia at gcc dot gnu.org
2023-03-17 17:34 ` jakub at gcc dot gnu.org
2023-03-17 18:17 ` amacleod at redhat dot com
2023-03-27 11:11 ` [Bug tree-optimization/108419] [13/14 " rguenth at gcc dot gnu.org
2024-05-07  7:40 ` [Bug tree-optimization/108419] [13/14/15/14 " 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).