aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJiang Haochen <haochen.jiang@intel.com>2021-12-21 16:12:02 +0800
committerHongyu Wang <hongyu.wang@intel.com>2021-12-21 16:30:16 +0800
commitd22907975b2abb79ba07eb2f54b64a9c952100ed (patch)
treed489d6dc5e44e999e2ba93035ded8b925263bcc3 /gcc
parent6fad101f3063d722e3348d07dc93cf737f8709e4 (diff)
downloadgcc-d22907975b2abb79ba07eb2f54b64a9c952100ed.zip
gcc-d22907975b2abb79ba07eb2f54b64a9c952100ed.tar.gz
gcc-d22907975b2abb79ba07eb2f54b64a9c952100ed.tar.bz2
i386: Add missing BMI intrinsic to align with clang
gcc/ChangeLog: * config/i386/bmiintrin.h (_tzcnt_u16): New intrinsic. (_andn_u32): Ditto. (_andn_u64): Ditto. gcc/testsuite/ChangeLog: * gcc.target/i386/bmi-1.c: Add test for new intrinsic. * gcc.target/i386/bmi-2.c: Ditto. * gcc.target/i386/bmi-3.c: Ditto.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/i386/bmiintrin.h18
-rw-r--r--gcc/testsuite/gcc.target/i386/bmi-1.c8
-rw-r--r--gcc/testsuite/gcc.target/i386/bmi-2.c8
-rw-r--r--gcc/testsuite/gcc.target/i386/bmi-3.c8
4 files changed, 39 insertions, 3 deletions
diff --git a/gcc/config/i386/bmiintrin.h b/gcc/config/i386/bmiintrin.h
index 439d81c..92450a6 100644
--- a/gcc/config/i386/bmiintrin.h
+++ b/gcc/config/i386/bmiintrin.h
@@ -40,6 +40,12 @@ __tzcnt_u16 (unsigned short __X)
return __builtin_ia32_tzcnt_u16 (__X);
}
+extern __inline unsigned short __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_tzcnt_u16 (unsigned short __X)
+{
+ return __builtin_ia32_tzcnt_u16 (__X);
+}
+
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__andn_u32 (unsigned int __X, unsigned int __Y)
{
@@ -47,6 +53,12 @@ __andn_u32 (unsigned int __X, unsigned int __Y)
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_andn_u32 (unsigned int __X, unsigned int __Y)
+{
+ return __andn_u32 (__X, __Y);
+}
+
+extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__bextr_u32 (unsigned int __X, unsigned int __Y)
{
return __builtin_ia32_bextr_u32 (__X, __Y);
@@ -115,6 +127,12 @@ __andn_u64 (unsigned long long __X, unsigned long long __Y)
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_andn_u64 (unsigned long long __X, unsigned long long __Y)
+{
+ return __andn_u64 (__X, __Y);
+}
+
+extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__bextr_u64 (unsigned long long __X, unsigned long long __Y)
{
return __builtin_ia32_bextr_u64 (__X, __Y);
diff --git a/gcc/testsuite/gcc.target/i386/bmi-1.c b/gcc/testsuite/gcc.target/i386/bmi-1.c
index 738705e..141adaa 100644
--- a/gcc/testsuite/gcc.target/i386/bmi-1.c
+++ b/gcc/testsuite/gcc.target/i386/bmi-1.c
@@ -1,6 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fno-ipa-icf -mbmi " } */
-/* { dg-final { scan-assembler "andn\[^\\n]*eax" } } */
+/* { dg-final { scan-assembler-times "andn\[^\\n]*eax" 2 } } */
/* { dg-final { scan-assembler-times "bextr\[ \\t]+\[^\\n]*eax" 2 } } */
/* { dg-final { scan-assembler-times "blsi\[^\\n]*eax" 2 } } */
/* { dg-final { scan-assembler-times "blsmsk\[^\\n]*eax" 2 } } */
@@ -16,6 +16,12 @@ func_andn32 (unsigned int X, unsigned int Y)
}
unsigned int
+func_andn32_2 (unsigned int X, unsigned int Y)
+{
+ return _andn_u32(X, Y);
+}
+
+unsigned int
func_bextr32 (unsigned int X, unsigned int Y)
{
return __bextr_u32(X, Y);
diff --git a/gcc/testsuite/gcc.target/i386/bmi-2.c b/gcc/testsuite/gcc.target/i386/bmi-2.c
index 6b8595e..3f9052a 100644
--- a/gcc/testsuite/gcc.target/i386/bmi-2.c
+++ b/gcc/testsuite/gcc.target/i386/bmi-2.c
@@ -1,6 +1,6 @@
/* { dg-do compile { target { ! ia32 } } } */
/* { dg-options "-O2 -fno-ipa-icf -mbmi " } */
-/* { dg-final { scan-assembler "andn\[^\\n]*rax" } } */
+/* { dg-final { scan-assembler-times "andn\[^\\n]*rax" 2 } } */
/* { dg-final { scan-assembler-times "bextr\[ \\t]+\[^\\n]*rax" 2 } } */
/* { dg-final { scan-assembler-times "blsi\[^\\n]*rax" 2 } } */
/* { dg-final { scan-assembler-times "blsmsk\[^\\n]*rax" 2 } } */
@@ -16,6 +16,12 @@ func_andn64 (unsigned long long X, unsigned long long Y)
}
unsigned long long
+func_andn64_2 (unsigned long long X, unsigned long long Y)
+{
+ return _andn_u64 (X, Y);
+}
+
+unsigned long long
func_bextr64 (unsigned long long X, unsigned long long Y)
{
return __bextr_u64 (X, Y);
diff --git a/gcc/testsuite/gcc.target/i386/bmi-3.c b/gcc/testsuite/gcc.target/i386/bmi-3.c
index ddc5e0f..0b91bc2 100644
--- a/gcc/testsuite/gcc.target/i386/bmi-3.c
+++ b/gcc/testsuite/gcc.target/i386/bmi-3.c
@@ -1,6 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O2 -mbmi " } */
-/* { dg-final { scan-assembler "tzcntw\[^\\n]*(%|)ax" } } */
+/* { dg-final { scan-assembler-times "tzcntw\[^\\n]*%?ax" 2 } } */
#include <x86intrin.h>
@@ -9,3 +9,9 @@ func_tzcnt16 (unsigned short X)
{
return __tzcnt_u16(X);
}
+
+unsigned short
+func_tzcnt16_2 (unsigned short X)
+{
+ return _tzcnt_u16(X);
+}