public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "goldstein.w.n at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/106060] New: Inefficient constant broadcast on x86_64 Date: Thu, 23 Jun 2022 01:59:15 +0000 [thread overview] Message-ID: <bug-106060-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106060 Bug ID: 106060 Summary: Inefficient constant broadcast on x86_64 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: goldstein.w.n at gmail dot com Target Milestone: --- ``` #include <immintrin.h> __m256i shouldnt_have_movabs () { return _mm256_set1_epi8 (123); } __m256i should_be_cmpeq_abs () { return _mm256_set1_epi8 (1); } __m256i should_be_cmpeq_add () { return _mm256_set1_epi8 (-2); } ``` Compiled with: '-O3 -march=x86-64-v3' Results in: ``` Disassembly of section .text: 0000000000000000 <shouldnt_have_movabs>: 0: 48 b8 7b 7b 7b 7b 7b movabs $0x7b7b7b7b7b7b7b7b,%rax 7: 7b 7b 7b a: c4 e1 f9 6e c8 vmovq %rax,%xmm1 f: c4 e2 7d 59 c1 vpbroadcastq %xmm1,%ymm0 14: c3 retq 15: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) 1c: 00 00 00 00 0000000000000020 <should_be_cmpeq_abs>: 20: 48 b8 01 01 01 01 01 movabs $0x101010101010101,%rax 27: 01 01 01 2a: c4 e1 f9 6e c8 vmovq %rax,%xmm1 2f: c4 e2 7d 59 c1 vpbroadcastq %xmm1,%ymm0 34: c3 retq 35: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) 3c: 00 00 00 00 0000000000000040 <should_be_cmpeq_add>: 40: 48 b8 fe fe fe fe fe movabs $0xfefefefefefefefe,%rax 47: fe fe fe 4a: c4 e1 f9 6e c8 vmovq %rax,%xmm1 4f: c4 e2 7d 59 c1 vpbroadcastq %xmm1,%ymm0 54: c3 retq ``` Compiled with: '-O3 -march=x86-64-v4' Results in: ``` 0000000000000000 <shouldnt_have_movabs>: 0: 48 b8 7b 7b 7b 7b 7b movabs $0x7b7b7b7b7b7b7b7b,%rax 7: 7b 7b 7b a: 62 f2 fd 28 7c c0 vpbroadcastq %rax,%ymm0 10: c3 retq 11: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) 18: 00 00 00 00 1c: 0f 1f 40 00 nopl 0x0(%rax) 0000000000000020 <should_be_cmpeq_abs>: 20: 48 b8 01 01 01 01 01 movabs $0x101010101010101,%rax 27: 01 01 01 2a: 62 f2 fd 28 7c c0 vpbroadcastq %rax,%ymm0 30: c3 retq 31: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) 38: 00 00 00 00 3c: 0f 1f 40 00 nopl 0x0(%rax) 0000000000000040 <should_be_cmpeq_add>: 40: 48 b8 fe fe fe fe fe movabs $0xfefefefefefefefe,%rax 47: fe fe fe 4a: 62 f2 fd 28 7c c0 vpbroadcastq %rax,%ymm0 50: c3 retq ``` All functions / targets are inoptimal. Generating 1/2 can be done without any lane-cross broadcast. Generating constants like 123 shouldn't first be constant broadcast into an imm64. That makes it require an 10-byte `movabs` and wastes spaces.
next reply other threads:[~2022-06-23 1:59 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-23 1:59 goldstein.w.n at gmail dot com [this message] 2022-06-23 7:05 ` [Bug target/106060] " crazylht at gmail dot com 2022-06-23 15:46 ` hjl.tools at gmail dot com 2023-05-17 23:15 ` pinskia at gcc dot gnu.org 2023-05-17 23:15 ` pinskia at gcc dot gnu.org 2024-01-14 11:57 ` roger at nextmovesoftware dot com 2024-02-16 9:41 ` roger at nextmovesoftware dot com 2024-05-07 6:19 ` cvs-commit at gcc dot gnu.org 2024-05-12 9:13 ` roger at nextmovesoftware 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-106060-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).