Skip to content
Snippets Groups Projects
Commit bb6144be authored by Manman Ren's avatar Manman Ren
Browse files

_mm_extract_epi16: use "& 7" when index is out of bound.

This is in line with implementation of _mm_extract_pi16.
rdar://15250497


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193187 91177308-0d34-0410-b5e6-96231b3b80d8
parent e233eea6
No related branches found
No related tags found
No related merge requests found
...@@ -1266,7 +1266,7 @@ static __inline__ int __attribute__((__always_inline__, __nodebug__)) ...@@ -1266,7 +1266,7 @@ static __inline__ int __attribute__((__always_inline__, __nodebug__))
_mm_extract_epi16(__m128i __a, int __imm) _mm_extract_epi16(__m128i __a, int __imm)
{ {
__v8hi __b = (__v8hi)__a; __v8hi __b = (__v8hi)__a;
return (unsigned short)__b[__imm]; return (unsigned short)__b[__imm & 7];
} }
static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
......
...@@ -206,3 +206,10 @@ void test_stream_si128(__m128i x, void *y) { ...@@ -206,3 +206,10 @@ void test_stream_si128(__m128i x, void *y) {
// CHECK: store {{.*}} <2 x i64>* {{.*}}, align 16, !nontemporal // CHECK: store {{.*}} <2 x i64>* {{.*}}, align 16, !nontemporal
_mm_stream_si128(y, x); _mm_stream_si128(y, x);
} }
void test_extract_epi16(__m128i __a) {
// CHECK-LABEL: define void @test_extract_epi16
// CHECK: [[x:%.*]] = and i32 %{{.*}}, 7
// CHECK: extractelement <8 x i16> %{{.*}}, i32 [[x]]
_mm_extract_epi16(__a, 8);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment