This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/4] Support crc32 as a i386 target optimization node


gcc/ChangeLog:

2016-07-18  Martin Liska  <mliska@suse.cz>

	* config/i386/i386.c (ix86_valid_target_attribute_inner_p):
	Handle crc32.

gcc/testsuite/ChangeLog:

2016-07-18  Martin Liska  <mliska@suse.cz>

	* gcc.target/i386/crc32-5.c: New test.
---
 gcc/config/i386/i386.c                  |  1 +
 gcc/testsuite/gcc.target/i386/crc32-5.c | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/i386/crc32-5.c

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index c838790..493b7e6 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -6437,6 +6437,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/gcc.target/i386/crc32-5.c b/gcc/testsuite/gcc.target/i386/crc32-5.c
new file mode 100644
index 0000000..a47f1e2
--- /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.8.4



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]