public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/105832] New: Dead Code Elimination Regression at -O3 (trunk vs. 12.1.0)
@ 2022-06-03  9:59 theodort at inf dot ethz.ch
  2022-06-13 12:35 ` [Bug tree-optimization/105832] [13 Regression] " rguenth at gcc dot gnu.org
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: theodort at inf dot ethz.ch @ 2022-06-03  9:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105832
           Summary: Dead Code Elimination Regression at -O3 (trunk vs.
                    12.1.0)
           Product: gcc
           Version: 13.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: ---

cat case.c #2
void foo(void);

static struct {
    short a;
    char b;
} c;

static char d;

int main() {
    char g = c.b > 4U ? c.b : c.b << 2;
    for (int h = 0; h < 5; h++) {
        d = (g >= 2 || 1 >> g) ? g : g << 1;
        if (d && 1 == g)
            foo();
        c.a = 0;
    }
}

`gcc-1982fe2692b6c3b7f969ffc4edac59f9d4359e91 (trunk) -O3` can not eliminate
`foo` but `gcc-releases/gcc-12.1.0 -O3` can.

`gcc-1982fe2692b6c3b7f969ffc4edac59f9d4359e91 (trunk) -O3 -S -o /dev/stdout
case.c`
--------- OUTPUT ---------
main:
.LFB0:
        .cfi_startproc
        movsbl  c+2(%rip), %edx
        movl    %edx, %eax
        sall    $2, %edx
        cmpb    $5, %al
        cmovb   %edx, %eax
        cmpb    $1, %al
        jle     .L3
.L13:
        xorl    %eax, %eax
        movw    %ax, c(%rip)
        xorl    %eax, %eax
        ret
.L3:
        movsbl  %al, %edx
        addl    %edx, %edx
        testb   %al, %al
        cmove   %eax, %edx
        testb   %dl, %dl
        je      .L13
        subb    $1, %al
        jne     .L13
        pushq   %rbx
        .cfi_def_cfa_offset 16
        .cfi_offset 3, -16
        movl    $5, %ebx
.L6:
        call    foo
        movw    $0, c(%rip)
        subl    $1, %ebx
        jne     .L6
        xorl    %eax, %eax
        popq    %rbx
        .cfi_def_cfa_offset 8
        ret
---------- END OUTPUT ---------


`gcc-releases/gcc-12.1.0 -O3 -S -o /dev/stdout case.c`
--------- OUTPUT ---------
main:
.LFB0:
        .cfi_startproc
        xorl    %eax, %eax
        movw    %ax, c(%rip)
        xorl    %eax, %eax
        ret
---------- END OUTPUT ---------


Bisects to:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a1c9f779f75283427316b5c670c1e01ff8ce9ced

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

end of thread, other threads:[~2023-09-05 20:59 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-03  9:59 [Bug tree-optimization/105832] New: Dead Code Elimination Regression at -O3 (trunk vs. 12.1.0) theodort at inf dot ethz.ch
2022-06-13 12:35 ` [Bug tree-optimization/105832] [13 Regression] " rguenth at gcc dot gnu.org
2022-06-14 11:14 ` rguenth at gcc dot gnu.org
2022-06-14 11:50 ` rguenth at gcc dot gnu.org
2022-12-20 14:03 ` rguenth at gcc dot gnu.org
2022-12-22 12:03 ` marxin at gcc dot gnu.org
2022-12-22 12:56 ` rguenth at gcc dot gnu.org
2022-12-22 14:48 ` marxin at gcc dot gnu.org
2023-02-21 14:27 ` rguenth at gcc dot gnu.org
2023-04-08 14:43 ` law at gcc dot gnu.org
2023-04-26  6:56 ` [Bug tree-optimization/105832] [13/14 " rguenth at gcc dot gnu.org
2023-07-12 18:00 ` pinskia at gcc dot gnu.org
2023-07-12 18:29 ` law at gcc dot gnu.org
2023-07-27  9:23 ` rguenth at gcc dot gnu.org
2023-08-07  8:40 ` pinskia at gcc dot gnu.org
2023-09-03  5:42 ` pinskia at gcc dot gnu.org
2023-09-03  6:31 ` pinskia at gcc dot gnu.org
2023-09-03 16:27 ` pinskia at gcc dot gnu.org
2023-09-05 20:57 ` cvs-commit at gcc dot gnu.org
2023-09-05 20:59 ` 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).