public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "theodort at inf dot ethz.ch" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/103388] New: [12 Regression] missed optimization for dead code elimination at -O3 (vs. -O2)
Date: Tue, 23 Nov 2021 18:21:17 +0000	[thread overview]
Message-ID: <bug-103388-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 103388
           Summary: [12 Regression] missed optimization for dead code
                    elimination at -O3 (vs. -O2)
           Product: gcc
           Version: 12.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
void foo(void);
void bar(void);

static int b, d, e, *c, *f = &d, *h = &b;

int main() {
  int **i = &c;
  if (e) {
    e = *f;
    bar();
    if (!(((i && d) + *h >= 1 ^ d & b) <= 4 | d))
      foo();
  }
}

trunk cannot eliminate the call to foo but 11.2.0 can:

gcc-11.2.0 -O3 -S -o /dev/stdout case.c
main:
.LFB0:
        .cfi_startproc
        movl    e(%rip), %ecx
        testl   %ecx, %ecx
        jne     .L8
        xorl    %eax, %eax
        ret
.L8:
        pushq   %rax
        .cfi_def_cfa_offset 16
        movl    d(%rip), %eax
        movl    %eax, e(%rip)
        call    bar
        xorl    %eax, %eax
        popq    %rdx
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc
.LFE0:

gcc-trunk -O3 -S -o /dev/stdout case.c
main:
.LFB0:
        .cfi_startproc
        movl    e(%rip), %esi
        testl   %esi, %esi
        jne     .L10
        xorl    %eax, %eax
        ret
.L10:
        pushq   %rcx
        .cfi_def_cfa_offset 16
        movl    d(%rip), %eax
        movl    %eax, e(%rip)
        call    bar
        movl    d(%rip), %edx
        movl    b(%rip), %eax
        cmpl    $1, %edx
        movl    %eax, %ecx
        sbbl    $-1, %ecx
        testl   %ecx, %ecx
        setg    %cl
        andl    %edx, %eax
        movzbl  %cl, %ecx
        xorl    %ecx, %eax
        cmpl    $4, %eax
        setle   %al
        movzbl  %al, %eax
        orl     %edx, %eax
        je      .L11
.L3:
        xorl    %eax, %eax
        popq    %rdx
        .cfi_remember_state
        .cfi_def_cfa_offset 8
        ret
.L11:
        .cfi_restore_state
        call    foo
        jmp     .L3
        .cfi_endproc
.LFE0:

gcc-trunk -v
Using built-in specs.
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.0 20211123 (experimental) (GCC)

Started with
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=4b3a325f07acebf47e82de227ce1d5ba62f5bcae

             reply	other threads:[~2021-11-23 18:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-23 18:21 theodort at inf dot ethz.ch [this message]
2021-11-23 19:19 ` [Bug tree-optimization/103388] " aldyh at gcc dot gnu.org
2021-11-23 19:31 ` aldyh at gcc dot gnu.org
2021-11-23 23:18 ` law at gcc dot gnu.org
2021-11-24  8:50 ` [Bug tree-optimization/103388] [12 Regression] missed optimization for dead code elimination at -O3 (trunk vs 11.2.0) rguenth at gcc dot gnu.org
2022-01-18 14:24 ` rguenth at gcc dot gnu.org
2022-01-18 15:28 ` law at gcc dot gnu.org
2022-05-06  8:31 ` [Bug tree-optimization/103388] [12/13 " jakub at gcc dot gnu.org
2022-07-26 13:09 ` rguenth at gcc dot gnu.org
2023-05-08 12:23 ` [Bug tree-optimization/103388] [12/13/14 " rguenth at gcc dot gnu.org
2024-06-04 18:23 ` [Bug tree-optimization/103388] [12/13/14/15 " cvs-commit at gcc dot gnu.org
2024-06-04 18:34 ` simartin at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103388-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).