diff mbox

[i386,9/8,AVX512] Add forgotten kmovw insn, built-in and test.

Message ID 20131231102251.GB127397@msticlxl7.ims.intel.com
State New
Headers show

Commit Message

Ilya Tocar Dec. 31, 2013, 10:22 a.m. UTC
> RA figured out that operation with general registers results in less
> moves (you already have x1 in general reg). This is exaclty the reason
> why I think unspecs are not needed. It is the job of the compiler to
> choose most appropriate approach, and its behavior should be adjusted
> with appropriate cost functions.
> 
> I guess that if you load x from memory, RA will allocate mask
> registers all the way to add insn.

I tried loading from memory and result is the same. Without unspec this
intrinsic is just return __A and is completely useless. As for RA
choosing best approach, big concern was generating k<logic> for normal
instructions, so current implementation of masks is conservative and RA
chooses gpr alternatives. So i think, that kmov intrinsic with unspec
has it's uses as a hint to complier. If you are against this approach
here is version without unspec.

---
 gcc/config/i386/avx512fintrin.h | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Uros Bizjak Dec. 31, 2013, 11:08 a.m. UTC | #1
On Tue, Dec 31, 2013 at 11:22 AM, Ilya Tocar <tocarip.intel@gmail.com> wrote:
>> RA figured out that operation with general registers results in less
>> moves (you already have x1 in general reg). This is exaclty the reason
>> why I think unspecs are not needed. It is the job of the compiler to
>> choose most appropriate approach, and its behavior should be adjusted
>> with appropriate cost functions.
>>
>> I guess that if you load x from memory, RA will allocate mask
>> registers all the way to add insn.
>
> I tried loading from memory and result is the same. Without unspec this
> intrinsic is just return __A and is completely useless. As for RA
> choosing best approach, big concern was generating k<logic> for normal
> instructions, so current implementation of masks is conservative and RA
> chooses gpr alternatives. So i think, that kmov intrinsic with unspec
> has it's uses as a hint to complier. If you are against this approach
> here is version without unspec.

No, this explanation sounds reasonable.

I was trying to take parallels with MMX insns, where we were able to
avoid DImode MMX moves by penalizing various moves between register
sets. However, apart from DImode shifts, MMX didn't have equivalent
logical or arithmetic DImode operations.

When _mm512_kmov is used, user clearly wants to use mask registers and
operations on mask registers.

Based on these facts, I think that the lesser evil is to use UNSPEC
moves. So, your original patch is OK.

Thanks,
Uros.
diff mbox

Patch

diff --git a/gcc/config/i386/avx512fintrin.h b/gcc/config/i386/avx512fintrin.h
index 0a43b1e..e0e74cf 100644
--- a/gcc/config/i386/avx512fintrin.h
+++ b/gcc/config/i386/avx512fintrin.h
@@ -14826,6 +14826,13 @@  _mm_maskz_fnmsub_ss (__mmask8 __U, __m128 __W, __m128 __A, __m128 __B)
 						  _MM_FROUND_CUR_DIRECTION);
 }
 
+extern __inline __mmask16
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_kmov (__mmask16 __A)
+{
+  return __A;
+}
+
 #ifdef __DISABLE_AVX512F__
 #undef __DISABLE_AVX512F__
 #pragma GCC pop_options