r270330 - [X86][AVX] Ensure zero-extension of _mm256_extract_epi8 and _mm256_extract_epi16
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Sat May 21 14:14:38 PDT 2016
Author: rksimon
Date: Sat May 21 16:14:35 2016
New Revision: 270330
URL: http://llvm.org/viewvc/llvm-project?rev=270330&view=rev
Log:
[X86][AVX] Ensure zero-extension of _mm256_extract_epi8 and _mm256_extract_epi16
Ensure _mm256_extract_epi8 and _mm256_extract_epi16 zero extend their i8/i16 result to i32. This matches _mm_extract_epi8 and _mm_extract_epi16.
Fix for PR27594
Differential Revision: http://reviews.llvm.org/D20468
Modified:
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/test/CodeGen/avx-builtins.c
Modified: cfe/trunk/lib/Headers/avxintrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=270330&r1=270329&r2=270330&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/avxintrin.h (original)
+++ cfe/trunk/lib/Headers/avxintrin.h Sat May 21 16:14:35 2016
@@ -1875,13 +1875,13 @@ _mm256_extract_epi32(__m256i __a, const
/// \param __imm
/// An immediate integer operand with bits [3:0] determining which vector
/// element is extracted and returned.
-/// \returns A 32-bit integer containing the extracted 16 bits of extended
+/// \returns A 32-bit integer containing the extracted 16 bits of zero extended
/// packed data.
static __inline int __DEFAULT_FN_ATTRS
_mm256_extract_epi16(__m256i __a, const int __imm)
{
__v16hi __b = (__v16hi)__a;
- return __b[__imm & 15];
+ return (unsigned short)__b[__imm & 15];
}
/// \brief Takes a [32 x i8] vector and returns the vector element value
@@ -1897,13 +1897,13 @@ _mm256_extract_epi16(__m256i __a, const
/// \param __imm
/// An immediate integer operand with bits [4:0] determining which vector
/// element is extracted and returned.
-/// \returns A 32-bit integer containing the extracted 8 bits of extended packed
-/// data.
+/// \returns A 32-bit integer containing the extracted 8 bits of zero extended
+/// packed data.
static __inline int __DEFAULT_FN_ATTRS
_mm256_extract_epi8(__m256i __a, const int __imm)
{
__v32qi __b = (__v32qi)__a;
- return __b[__imm & 31];
+ return (unsigned char)__b[__imm & 31];
}
#ifdef __x86_64__
Modified: cfe/trunk/test/CodeGen/avx-builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-builtins.c?rev=270330&r1=270329&r2=270330&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/avx-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx-builtins.c Sat May 21 16:14:35 2016
@@ -314,21 +314,19 @@ __m256 test_mm256_dp_ps(__m256 A, __m256
return _mm256_dp_ps(A, B, 7);
}
-// FIXME: ZEXT instead of SEXT
int test_mm256_extract_epi8(__m256i A) {
// CHECK-LABEL: test_mm256_extract_epi8
// CHECK: and i32 %{{.*}}, 31
// CHECK: extractelement <32 x i8> %{{.*}}, i32 %{{.*}}
- // CHECK: ext i8 %{{.*}} to i32
+ // CHECK: zext i8 %{{.*}} to i32
return _mm256_extract_epi8(A, 32);
}
-// FIXME: ZEXT instead of SEXT
int test_mm256_extract_epi16(__m256i A) {
// CHECK-LABEL: test_mm256_extract_epi16
// CHECK: and i32 %{{.*}}, 15
// CHECK: extractelement <16 x i16> %{{.*}}, i32 %{{.*}}
- // CHECK: ext i16 %{{.*}} to i32
+ // CHECK: zext i16 %{{.*}} to i32
return _mm256_extract_epi16(A, 16);
}
More information about the cfe-commits
mailing list