From fab18cc4f7149a3b39d3b3055af03013f01ac554 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 23 Sep 2016 09:57:07 +0200 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. From-SVN: r240393 --- 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 d3ba1c29810..ecf6811457f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +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 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 2dcd5699a70..b1aa727a69f 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 6b6693efa94..80622c5805e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +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. 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 00000000000..a47f1e232b9 --- /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.30.2