public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "crazylht at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/108707] New: suboptimal allocation with same memory op for many different instructions. Date: Wed, 08 Feb 2023 03:11:30 +0000 [thread overview] Message-ID: <bug-108707-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108707 Bug ID: 108707 Summary: suboptimal allocation with same memory op for many different instructions. Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: crazylht at gmail dot com Target Milestone: --- #include<immintrin.h> void foo (__m512* pv, float* __restrict ps, int n, __m512* pdest, __m512* p1, __m512* p2, __m512* p3) { __m512 a = _mm512_setzero_ps (); __m512 b = a; __m512 c = a; for (int i = 0; i != n ;i++) { a = _mm512_fmadd_ps (p1[i], pv[i], a); b = _mm512_fmadd_ps (p2[i], pv[i], b); c = _mm512_fmadd_ps (p3[i], pv[i], c); } pdest[0] = a; pdest[1] = b; pdest[2] = c; } g++ -O2 -mavx512f -S got .L3: vmovaps (%r8,%rax), %zmm3 vmovaps (%r9,%rax), %zmm4 vmovaps (%rsi,%rax), %zmm5 vfmadd231ps (%rdi,%rax), %zmm3, %zmm2 vfmadd231ps (%rdi,%rax), %zmm4, %zmm1 vfmadd231ps (%rdi,%rax), %zmm5, %zmm0 addq $64, %rax cmpq %rax, %rdx jne .L3 It would be better to load (%rdi, %rax) into a zmm then .L3: vmovaps (%rdi,%rax), %zmm0 vfmadd231ps (%r8,%rax), %zmm0, %zmm3 vfmadd231ps (%r9,%rax), %zmm0, %zmm2 vfmadd231ps (%rsi,%rax), %zmm0, %zmm1 addq $64, %rax cmpq %rax, %rdx jne .L3
next reply other threads:[~2023-02-08 3:11 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-08 3:11 crazylht at gmail dot com [this message] 2023-02-08 3:15 ` [Bug rtl-optimization/108707] " crazylht at gmail dot com 2023-02-09 13:38 ` rguenth at gcc dot gnu.org 2023-03-09 5:58 ` crazylht at gmail dot com 2023-03-09 5:59 ` crazylht at gmail dot com 2023-03-09 5:59 ` crazylht at gmail dot com 2023-03-09 6:00 ` crazylht at gmail dot com 2023-04-23 1:57 ` cvs-commit at gcc dot gnu.org 2023-11-01 5:29 ` crazylht at gmail 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-108707-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).