Re: [FFmpeg-devel] [PATCH] avutil/intmath: use bzhi gcc builtin in av_mod_uintp2()

2015-06-27 Thread James Almer
On 26/06/15 8:14 PM, James Almer wrote:
> Signed-off-by: James Almer 
> ---
> Now making sure it's not used with ICC.

Pushed the original. Oked by Cehoyos who confirmed ICC never reaches this code
to begin with.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avutil/intmath: use bzhi gcc builtin in av_mod_uintp2()

2015-06-26 Thread James Almer
Signed-off-by: James Almer 
---
Now making sure it's not used with ICC.

 libavutil/x86/intmath.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavutil/x86/intmath.h b/libavutil/x86/intmath.h
index c42fa83..8127e10 100644
--- a/libavutil/x86/intmath.h
+++ b/libavutil/x86/intmath.h
@@ -39,6 +39,12 @@
 
 #if defined(__BMI2__)
 
+#if AV_GCC_VERSION_AT_LEAST(5,1) && !defined(__INTEL_COMPILER)
+#define av_mod_uintp2 __builtin_ia32_bzhi_si
+#else
+/* GCC releases before 5.1.0 have a broken bzhi builtin, so for those we
+ * implement it using inline assembly
+ */
 #define av_mod_uintp2 av_mod_uintp2_bmi2
 static av_always_inline av_const unsigned av_mod_uintp2_bmi2(unsigned a, 
unsigned p)
 {
@@ -50,6 +56,7 @@ static av_always_inline av_const unsigned 
av_mod_uintp2_bmi2(unsigned a, unsigne
 return x;
 }
 }
+#endif /* AV_GCC_VERSION_AT_LEAST */
 
 #endif /* __BMI2__ */
 
-- 
2.4.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avutil/intmath: use bzhi gcc builtin in av_mod_uintp2()

2015-06-26 Thread James Almer
On 26/06/15 4:56 PM, Carl Eugen Hoyos wrote:
> On Friday 26 June 2015 09:52:31 pm James Almer wrote:
> 
>> +#if AV_GCC_VERSION_AT_LEAST(5,1)
>> +#define av_mod_uintp2 __builtin_ia32_bzhi_si
> 
> Since there are compilers != gcc that define GCC 
> (for example icc), this needs a configure check imo.

Does it define __GNUC__ with a value >=5 like I'm checking above? And
if it defines __GNUC__, shouldn't it support the relevant builtins or
defines?

> 
> What is the advantage over the inline version?

The bzhi instruction sets the ZF flag among others, but GCC apparently
doesn't take it into consideration when it's used inside the __asm__()
block, so something like "if (av_mod_uintp2(foo, bar))" will result in
a bzhi instruction followed by a test instruction.
This doesn't happen if you use the builtin.

> 
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avutil/intmath: use bzhi gcc builtin in av_mod_uintp2()

2015-06-26 Thread Carl Eugen Hoyos
On Friday 26 June 2015 09:52:31 pm James Almer wrote:

> +#if AV_GCC_VERSION_AT_LEAST(5,1)
> +#define av_mod_uintp2 __builtin_ia32_bzhi_si

Since there are compilers != gcc that define GCC 
(for example icc), this needs a configure check imo.

What is the advantage over the inline version?

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avutil/intmath: use bzhi gcc builtin in av_mod_uintp2()

2015-06-26 Thread James Almer
Signed-off-by: James Almer 
---
 libavutil/x86/intmath.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavutil/x86/intmath.h b/libavutil/x86/intmath.h
index c42fa83..85f15a4 100644
--- a/libavutil/x86/intmath.h
+++ b/libavutil/x86/intmath.h
@@ -39,6 +39,12 @@
 
 #if defined(__BMI2__)
 
+#if AV_GCC_VERSION_AT_LEAST(5,1)
+#define av_mod_uintp2 __builtin_ia32_bzhi_si
+#else
+/* GCC releases before 5.1.0 have a broken bzhi builtin, so for those we
+ * implement it using inline assembly
+ */
 #define av_mod_uintp2 av_mod_uintp2_bmi2
 static av_always_inline av_const unsigned av_mod_uintp2_bmi2(unsigned a, 
unsigned p)
 {
@@ -50,6 +56,7 @@ static av_always_inline av_const unsigned 
av_mod_uintp2_bmi2(unsigned a, unsigne
 return x;
 }
 }
+#endif /* AV_GCC_VERSION_AT_LEAST */
 
 #endif /* __BMI2__ */
 
-- 
2.4.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel