public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "liuhongt at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/114556] New: weird loop unrolling when there's attribute aligned in side the loop Date: Tue, 02 Apr 2024 08:27:58 +0000 [thread overview] Message-ID: <bug-114556-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114556 Bug ID: 114556 Summary: weird loop unrolling when there's attribute aligned in side the loop Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: liuhongt at gcc dot gnu.org Target Milestone: --- v32qi zzzzz (void* pa, void* pb, void* pc) { v32qi __attribute__((aligned(64))) a; v32qi __attribute__((aligned(64))) b; v32qi __attribute__((aligned(64))) c; __builtin_memcpy (&a, pa, sizeof (a)); __builtin_memcpy (&b, pb, sizeof (a)); __builtin_memcpy (&c, pc, sizeof (a)); #pragma GCC unroll 8 for (int i = 0; i != 2048; i++) a += b; return a; } -O2 -mavx2, we have zzzzz: vmovdqu (%rsi), %ymm1 vpaddb (%rdi), %ymm1, %ymm0 movl $2041, %eax vpaddb %ymm0, %ymm1, %ymm0 vpaddb %ymm0, %ymm1, %ymm0 vpaddb %ymm0, %ymm1, %ymm0 vpaddb %ymm0, %ymm1, %ymm0 vpaddb %ymm0, %ymm1, %ymm0 vpaddb %ymm0, %ymm1, %ymm0 jmp .L2 .L3: vpaddb %ymm0, %ymm1, %ymm0 subl $8, %eax vpaddb %ymm0, %ymm1, %ymm0 vpaddb %ymm0, %ymm1, %ymm0 vpaddb %ymm0, %ymm1, %ymm0 vpaddb %ymm0, %ymm1, %ymm0 vpaddb %ymm0, %ymm1, %ymm0 vpaddb %ymm0, %ymm1, %ymm0 .L2: vpaddb %ymm0, %ymm1, %ymm0 cmpl $1, %eax jne .L3 ret But shouldn't it better with zzzzz: vmovdqu (%rsi), %ymm1 vmovdqu (%rdi), %ymm0 movl $2048, %eax .L2: vpaddb %ymm1, %ymm0, %ymm0 vpaddb %ymm1, %ymm0, %ymm0 vpaddb %ymm1, %ymm0, %ymm0 vpaddb %ymm1, %ymm0, %ymm0 vpaddb %ymm1, %ymm0, %ymm0 vpaddb %ymm1, %ymm0, %ymm0 vpaddb %ymm1, %ymm0, %ymm0 vpaddb %ymm1, %ymm0, %ymm0 subl $8, %eax jne .L2 ret
next reply other threads:[~2024-04-02 8:27 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-04-02 8:27 liuhongt at gcc dot gnu.org [this message] 2024-04-03 0:35 ` [Bug middle-end/114556] weird loop unrolling when there's attribute aligned inside " pinskia at gcc dot gnu.org 2024-04-03 0:40 ` pinskia 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-114556-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).