public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "652023330028 at smail dot nju.edu.cn" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/114145] New: Missed optimization of loop deletion
Date: Wed, 28 Feb 2024 09:22:55 +0000	[thread overview]
Message-ID: <bug-114145-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 114145
           Summary: Missed optimization of loop deletion
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 652023330028 at smail dot nju.edu.cn
  Target Milestone: ---

Hello, we noticed that in the code below, looping is not necessary, but gcc
seems to have missed this optimization.

https://godbolt.org/z/sYqzh8M3c
int a, b;
void func(int c){
    for(int i=0;i<700;i++){
        b=c;
        c=a;
    }
}

GCC -O3:
func(int):
        mov     edx, DWORD PTR a[rip]
        mov     eax, 700
        jmp     .L2
.L3:
        sub     eax, 3
        mov     edi, edx
.L2:
        cmp     eax, 1
        jne     .L3
        mov     DWORD PTR b[rip], edi
        ret

Expected code (Clang):
func(int):                               # @func(int)
        mov     eax, dword ptr [rip + a]
        mov     dword ptr [rip + b], eax
        ret

Thank you very much for your time and effort! We look forward to hearing from
you.

             reply	other threads:[~2024-02-28  9:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28  9:22 652023330028 at smail dot nju.edu.cn [this message]
2024-02-28 10:31 ` [Bug tree-optimization/114145] " rguenth 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-114145-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).