public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mareksz1958 at wp dot pl" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug other/105429] New: Unnecessary moves generated by the compiler. Date: Thu, 28 Apr 2022 20:02:46 +0000 [thread overview] Message-ID: <bug-105429-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105429 Bug ID: 105429 Summary: Unnecessary moves generated by the compiler. Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: mareksz1958 at wp dot pl Target Milestone: --- The following C code: >>> #include <nmmintrin.h> #include <stdint.h> uint32_t crc(uint32_t current, const uint8_t *buffer, size_t size) { for(size_t i = 0; i < size; i++) current = _mm_crc32_u64(current, buffer[i]); return current; } <<< Generates inefficient assembly on all optimisation presets due to the extra `mov eax, eax' - Os and O3 below: >>> crc: movl %edi, %eax xorl %ecx, %ecx .L2: cmpq %rdx, %rcx je .L5 movzbl (%rsi,%rcx), %edi movl %eax, %eax incq %rcx crc32q %rdi, %rax jmp .L2 .L5: ret crc: movl %edi, %eax testq %rdx, %rdx je .L6 leaq (%rsi,%rdx), %rcx .L3: movzbl (%rsi), %edx movl %eax, %eax addq $1, %rsi crc32q %rdx, %rax cmpq %rsi, %rcx jne .L3 .L6: ret <<< The problem seems to be present in all GCC versions I have access to. The redundant move greatly worsens the performance of the generated code. When `_mm_crc32_u64' is replaced by any other function, the problem seems to disappear.
next reply other threads:[~2022-04-28 20:02 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-28 20:02 mareksz1958 at wp dot pl [this message] 2022-04-28 20:04 ` [Bug target/105429] Unnecessary moves generated with _mm_crc32_u64 pinskia at gcc dot gnu.org 2022-04-29 12:30 ` ubizjak at gmail dot com 2022-04-29 12:38 ` kspalaiologos 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-105429-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).