From 82a47693a8151a7c763e4a8ac1ce08133506af06 Mon Sep 17 00:00:00 2001 From: marxin Date: Fri, 23 Sep 2016 07:57:07 +0000 Subject: [PATCH] Support crc32 as a i386 target optimization node * config/i386/i386.c (ix86_valid_target_attribute_inner_p): Handle crc32. * gcc.target/i386/crc32-5.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240393 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/config/i386/i386.c | 1 + gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.target/i386/crc32-5.c | 25 +++++++++++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/crc32-5.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d3ba1c298104..ecf6811457f7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2016-09-23 Martin Liska + * config/i386/i386.c (ix86_valid_target_attribute_inner_p): + Handle crc32. + +2016-09-23 Martin Liska + PR target/71652 * config/i386/i386.c (ix86_option_override_internal): Change signature and return false when there's an error related to diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 2dcd5699a702..b1aa727a69f3 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -6526,6 +6526,7 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[], IX86_ATTR_ISA ("mmx", OPT_mmmx), IX86_ATTR_ISA ("pclmul", OPT_mpclmul), IX86_ATTR_ISA ("popcnt", OPT_mpopcnt), + IX86_ATTR_ISA ("crc32", OPT_mcrc32), IX86_ATTR_ISA ("sse", OPT_msse), IX86_ATTR_ISA ("sse2", OPT_msse2), IX86_ATTR_ISA ("sse3", OPT_msse3), diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6b6693efa943..80622c5805e9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2016-09-23 Martin Liska + * gcc.target/i386/crc32-5.c: New test. + +2016-09-23 Martin Liska + * gcc.target/i386/pr71652.c: New test. * gcc.target/i386/pr71652-2.c: New test. * gcc.target/i386/pr71652-3.c: New test. diff --git a/gcc/testsuite/gcc.target/i386/crc32-5.c b/gcc/testsuite/gcc.target/i386/crc32-5.c new file mode 100644 index 000000000000..a47f1e232b9b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/crc32-5.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler "crc32b\[^\\n\]*eax" } } */ +/* { dg-final { scan-assembler "crc32w\[^\\n\]*eax" } } */ +/* { dg-final { scan-assembler "crc32l\[^\\n\]*eax" } } */ + +#pragma GCC target ("crc32") + +unsigned int +crc32b (unsigned int x, unsigned char y) +{ + return __builtin_ia32_crc32qi (x, y); +} + +unsigned int +crc32w (unsigned int x, unsigned short y) +{ + return __builtin_ia32_crc32hi (x, y); +} + +unsigned int +crc32d (unsigned int x, unsigned int y) +{ + return __builtin_ia32_crc32si (x, y); +} -- 2.11.4.GIT