public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Alexander Monakov <amonakov@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2448] i386: avoid zero extension for crc32q Date: Mon, 5 Sep 2022 18:02:20 +0000 (GMT) [thread overview] Message-ID: <20220905180220.E6860385AC1B@sourceware.org> (raw) https://gcc.gnu.org/g:810d9815249451f477d4cbc67b8e4a0819c37faa commit r13-2448-g810d9815249451f477d4cbc67b8e4a0819c37faa Author: Alexander Monakov <amonakov@ispras.ru> Date: Tue Aug 23 18:42:24 2022 +0300 i386: avoid zero extension for crc32q The crc32q instruction takes 64-bit operands, but ignores high 32 bits of the destination operand, and zero-extends the result from 32 bits. Let's model this in the RTL pattern to avoid zero-extension when the _mm_crc32_u64 intrinsic is used with a 32-bit type. PR target/106453 gcc/ChangeLog: * config/i386/i386.md (sse4_2_crc32di): Model that only low 32 bits of operand 0 are consumed, and the result is zero-extended to 64 bits. gcc/testsuite/ChangeLog: * gcc.target/i386/pr106453.c: New test. Diff: --- gcc/config/i386/i386.md | 9 +++++---- gcc/testsuite/gcc.target/i386/pr106453.c | 13 +++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 1aef1af594d..1be9b669909 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -23823,10 +23823,11 @@ (define_insn "sse4_2_crc32di" [(set (match_operand:DI 0 "register_operand" "=r") - (unspec:DI - [(match_operand:DI 1 "register_operand" "0") - (match_operand:DI 2 "nonimmediate_operand" "rm")] - UNSPEC_CRC32))] + (zero_extend:DI + (unspec:SI + [(match_operand:SI 1 "register_operand" "0") + (match_operand:DI 2 "nonimmediate_operand" "rm")] + UNSPEC_CRC32)))] "TARGET_64BIT && TARGET_CRC32" "crc32{q}\t{%2, %0|%0, %2}" [(set_attr "type" "sselog1") diff --git a/gcc/testsuite/gcc.target/i386/pr106453.c b/gcc/testsuite/gcc.target/i386/pr106453.c new file mode 100644 index 00000000000..bd2e7282cf6 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr106453.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mcrc32 -dp" } */ +/* { dg-final { scan-assembler-not "zero_extendsidi" } } */ + +#include <immintrin.h> +#include <stdint.h> + +uint32_t f(uint32_t c, uint64_t *p, size_t n) +{ + for (size_t i = 0; i < n; i++) + c = _mm_crc32_u64(c, p[i]); + return c; +}
reply other threads:[~2022-09-05 18:02 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220905180220.E6860385AC1B@sourceware.org \ --to=amonakov@gcc.gnu.org \ --cc=gcc-cvs@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).