On Fri, Jun 27, 2025 at 08:11:29AM +0200, Uros Bizjak wrote: > On Fri, Jun 27, 2025 at 7:27 AM Andi Kleen <a...@linux.intel.com> wrote: > > > > Uros Bizjak <ubiz...@gmail.com> writes: > > > > > Introduce crc_rev<mode>si4 expanders to generate CRC32 instruction when > > > using > > > __builtin_rev_crc32_data* builtins with 0x1EDC6F41 poylnomial and -mcrc32. > > > > > > PR target/120719 > > > > > > gcc/ChangeLog: > > > > > > * config/i386/i386.md (crc_rev<SWI124:mode>si4): New expander. > > > > > > gcc/testsuite/ChangeLog: > > > > > > * gcc.target/i386/crc-builtin-crc32.c: New test. > > > > > > Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. > > > > This is missing enabling the test cases crc-crc32c* for the CRC pattern > > matching pass, which are currently only on aarch64/loongarch. > > > > So we're not sure if it actually works for that. > > Included are target-dependent tests that result in crc32 instructions. > Generic tests are performed elsewhere (please see > gcc.dg/crc-builtin-target{32,64}.c).
These do not test the CRC pattern matching pass, which are only covered by non i386 target specific tests currently. But your new pattern will turn it on, so it needs to be tested. You need something like this (untested) Also there were some other issues with this when I looked into it (the middle end seemed to generate the wrong mode in some of the cases and one of the tests were broken). But anyways that's the minimum. diff --git a/gcc/testsuite/gcc.target/i386/crc-crc32c-data16.c b/gcc/testsuite/gcc.target/i386/crc-crc32c-data16.c new file mode 100644 index 000000000000..0a08003e7ac1 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/crc-crc32c-data16.c @@ -0,0 +1,10 @@ +/* { dg-do run } */ +/* { dg-options "-mcrc32 -O2 -fdump-rtl-dfinish -fdump-tree-crc" } */ +/* { dg-skip-if "" { *-*-* } { "-flto"} } */ + +#include "../aarch64/crc-crc32c-data16.c" + +/* { dg-final { scan-tree-dump "calculates CRC!" "crc"} } */ +/* { dg-final { scan-tree-dump-times "Couldn't generate faster CRC code." 0 "crc"} } */ +/* { dg-final { scan-rtl-dump "UNSPEC_CRC32" "dfinish"} } */ +/* { dg-final { scan-assembler "crc32w" } } */ diff --git a/gcc/testsuite/gcc.target/i386/crc-crc32c-data32.c b/gcc/testsuite/gcc.target/i386/crc-crc32c-data32.c new file mode 100644 index 000000000000..cd8fe8b2bb49 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/crc-crc32c-data32.c @@ -0,0 +1,10 @@ +/* { dg-do run } */ +/* { dg-options "-mcrc32 -O2 -fdump-rtl-dfinish -fdump-tree-crc" } */ +/* { dg-skip-if "" { *-*-* } { "-flto"} } */ + +#include "../aarch64/crc-crc32c-data32.c" + +/* { dg-final { scan-tree-dump "calculates CRC!" "crc"} } */ +/* { dg-final { scan-tree-dump-times "Couldn't generate faster CRC code." 0 "crc"} } */ +/* { dg-final { scan-rtl-dump "UNSPEC_CRC32" "dfinish"} } */ +/* { dg-final { scan-assembler "crc32l" } } */ diff --git a/gcc/testsuite/gcc.target/i386/crc-crc32c-data8.c b/gcc/testsuite/gcc.target/i386/crc-crc32c-data8.c new file mode 100644 index 000000000000..3acbea7d987e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/crc-crc32c-data8.c @@ -0,0 +1,10 @@ +/* { dg-do run } */ +/* { dg-options "-mcrc32 -O2 -fdump-rtl-dfinish -fdump-tree-crc" } */ +/* { dg-skip-if "" { *-*-* } { "-flto"} } */ + +#include "../aarch64/crc-crc32c-data8.c" + +/* { dg-final { scan-tree-dump "calculates CRC!" "crc"} } */ +/* { dg-final { scan-tree-dump-times "Couldn't generate faster CRC code." 0 "crc"} } */ +/* { dg-final { scan-rtl-dump "UNSPEC_CRC32" "dfinish"} } */ +/* { dg-final { scan-assembler "crc32b" } } */