public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114145] New: Missed optimization of loop deletion
@ 2024-02-28  9:22 652023330028 at smail dot nju.edu.cn
  2024-02-28 10:31 ` [Bug tree-optimization/114145] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: 652023330028 at smail dot nju.edu.cn @ 2024-02-28  9:22 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2024-02-28 10:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-28  9:22 [Bug tree-optimization/114145] New: Missed optimization of loop deletion 652023330028 at smail dot nju.edu.cn
2024-02-28 10:31 ` [Bug tree-optimization/114145] " 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).