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/114823] New: Missed optimization of redundant loops Date: Tue, 23 Apr 2024 10:11:55 +0000 [thread overview] Message-ID: <bug-114823-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114823 Bug ID: 114823 Summary: Missed optimization of redundant loops 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, for the reduced code below, its second loop is redundant. There seems to be a missed optimization. https://godbolt.org/z/McqeYdnfY int a[1024]; int b[1024]; void func() { for (int i = 0; i < 1024; i+=1) { a[i] = b[i] * 2; } for (int i = 0; i < 1024; i+=1) { a[i] = b[i] * 2; } } GCC -O3: func: xor eax, eax .L2: movdqa xmm0, XMMWORD PTR b[rax] add rax, 16 pslld xmm0, 1 movaps XMMWORD PTR a[rax-16], xmm0 cmp rax, 4096 jne .L2 xor eax, eax .L3: movdqa xmm0, XMMWORD PTR b[rax] add rax, 16 pslld xmm0, 1 movaps XMMWORD PTR a[rax-16], xmm0 cmp rax, 4096 jne .L3 ret Expected code: func: xor eax, eax .L2: movdqa xmm0, XMMWORD PTR b[rax] add rax, 16 pslld xmm0, 1 movaps XMMWORD PTR a[rax-16], xmm0 cmp rax, 4096 jne .L2 ret Thank you very much for your time and effort! We look forward to hearing from you.
next reply other threads:[~2024-04-23 10:11 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-04-23 10:11 652023330028 at smail dot nju.edu.cn [this message] 2024-04-23 15:53 ` [Bug tree-optimization/114823] " 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-114823-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: linkBe 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).