Bug 47840

Summary: [4.4/4.5/4.6 Regression] incorrect _mm256_insert_epi{32,64} implementations
Product: gcc Reporter: Matthias Kretz <kretz>
Component: targetAssignee: Uroš Bizjak <ubizjak>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 4.6.0   
Target Milestone: 4.4.6   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2011-02-21 19:45:17

Description Matthias Kretz 2011-02-21 18:31:05 UTC
see avxintrin.h:
_mm256_insert_epi32 and _mm256_insert_epi64 use _mm_insert_epi16 internally

if __OPTIMIZE__ is not defined they use _mm_insert_epi32/64 internally - as I would have expected.

I also checked 4.5 and 4.4, and it seems the bug was not noticed in any branch yet.
Comment 1 Uroš Bizjak 2011-02-21 19:45:17 UTC
A typo, following patch should fix it:

Index: avxintrin.h
===================================================================
--- avxintrin.h	(revision 170367)
+++ avxintrin.h	(working copy)
@@ -737,7 +737,7 @@
 _mm256_insert_epi32 (__m256i __X, int __D, int const __N)
 {
   __m128i __Y = _mm256_extractf128_si256 (__X, __N >> 2);
-  __Y = _mm_insert_epi16 (__Y, __D, __N % 4);
+  __Y = _mm_insert_epi32 (__Y, __D, __N % 4);
   return _mm256_insertf128_si256 (__X, __Y, __N >> 2);
 }
 
@@ -762,7 +762,7 @@
 _mm256_insert_epi64 (__m256i __X, int __D, int const __N)
 {
   __m128i __Y = _mm256_extractf128_si256 (__X, __N >> 1);
-  __Y = _mm_insert_epi16 (__Y, __D, __N % 2);
+  __Y = _mm_insert_epi64 (__Y, __D, __N % 2);
   return _mm256_insertf128_si256 (__X, __Y, __N >> 1);
 }
 #endif
Comment 2 uros 2011-02-21 19:59:55 UTC
Author: uros
Date: Mon Feb 21 19:59:52 2011
New Revision: 170371

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170371
Log:
	PR target/47840
	* config/i386/avxintrin.h (_mm256_insert_epi32): Use _mm_insert_epi32.
	(_mm256_insert_epi64): Use _mm_insert_epi64.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/avxintrin.h
Comment 3 uros 2011-02-21 20:02:08 UTC
Author: uros
Date: Mon Feb 21 20:02:02 2011
New Revision: 170372

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170372
Log:
	PR target/47840
	* config/i386/avxintrin.h (_mm256_insert_epi32): Use _mm_insert_epi32.
	(_mm256_insert_epi64): Use _mm_insert_epi64.


Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/config/i386/avxintrin.h
Comment 4 uros 2011-02-21 20:05:02 UTC
Author: uros
Date: Mon Feb 21 20:04:57 2011
New Revision: 170373

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170373
Log:
	PR target/47840
	* config/i386/avxintrin.h (_mm256_insert_epi32): Use _mm_insert_epi32.
	(_mm256_insert_epi64): Use _mm_insert_epi64.


Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/config/i386/avxintrin.h
Comment 5 Uroš Bizjak 2011-02-21 20:06:03 UTC
Fixed.