public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "theodoridisgr at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/102540] New: Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
Date: Thu, 30 Sep 2021 09:27:06 +0000	[thread overview]
Message-ID: <bug-102540-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 102540
           Summary: Dead Code Elimination Regression at -O3 (trunk vs
                    11.2.0)
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: theodoridisgr at gmail dot com
  Target Milestone: ---

cat test.c
static long a;
static unsigned b;
void foo(void);
int main() {
    long c, e;
    c = b = a;
    e = c ? 2 / (c + 1) : 0;
    if (e && !b)
        foo();
    a = 0;
}

11.2.0 at -O3 can eliminate the call to foo but trunk at -O3 cannot:

gcc-11 -v
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --disable-bootstrap
--enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (GCC)

gcc-11 test.c -S -O3
cat test.s
        .file   "test.c"
        .text
        .section        .text.startup,"ax",@progbits
        .p2align 4
        .globl  main
        .type   main, @function
main:
.LFB0:
        .cfi_startproc
        movq    $0, a(%rip)
        xorl    %eax, %eax
        ret
        .cfi_endproc
.LFE0:
        .size   main, .-main
        .local  a
        .comm   a,8,8
        .ident  "GCC: (GNU) 11.2.0"
        .section        .note.GNU-stack,"",@progbits


gcc-trunk -v
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --disable-bootstrap
--enable-languages=c,c++ 
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.0 20210930 (experimental) (GCC)

gcc-trunk test.c -S -O3
cat test.s
        .file   "test.c"
        .text
        .section        .text.startup,"ax",@progbits
        .p2align 4
        .globl  main
        .type   main, @function
main:
.LFB0:
        .cfi_startproc
        movq    a(%rip), %rcx
        movq    %rcx, %rsi
        andl    $4294967295, %esi
        je      .L13
        movl    $2, %eax
        addq    $1, %rsi
        cqto
        idivq   %rsi
        testb   $1, %al
        je      .L13
        testl   %ecx, %ecx
        je      .L17
.L13:
        movq    $0, a(%rip)
        xorl    %eax, %eax
        ret
.L17:
        pushq   %rax
        .cfi_def_cfa_offset 16
        call    foo
        xorl    %edx, %edx
        xorl    %eax, %eax
        movq    %rdx, a(%rip)
        popq    %rcx
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc
.LFE0:
        .size   main, .-main
        .local  a
        .comm   a,8,8
        .ident  "GCC: (GNU) 12.0.0 20210930 (experimental)"
        .section        .note.GNU-stack,"",@progbits

             reply	other threads:[~2021-09-30  9:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-30  9:27 theodoridisgr at gmail dot com [this message]
2021-09-30 10:05 ` [Bug tree-optimization/102540] [12 Regression] Dead Code Elimination Regression at -O3 since r12-476-gd846f225c25c5885 marxin at gcc dot gnu.org
2021-09-30 12:50 ` rguenth at gcc dot gnu.org
2021-09-30 17:39 ` aldyh at gcc dot gnu.org
2021-10-01 21:02 ` amacleod at redhat dot com
2021-10-04  6:36 ` rguenther at suse dot de
2021-10-04 17:15 ` amacleod at redhat dot com
2021-10-05  6:19 ` rguenther at suse dot de
2021-10-05 13:59 ` amacleod at redhat dot com
2022-01-20  9:44 ` rguenth at gcc dot gnu.org
2022-01-20 14:42 ` amacleod at redhat dot com
2022-05-06  8:31 ` [Bug tree-optimization/102540] [12/13 " jakub at gcc dot gnu.org
2022-07-26 13:26 ` rguenth at gcc dot gnu.org
2022-10-13 15:29 ` cvs-commit at gcc dot gnu.org
2022-10-13 17:03 ` amacleod at redhat dot com

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-102540-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).