Skip to content

Commit

Permalink
[Headers] Add tests for _mm256_insert_epi64 and fix its definition
Browse files Browse the repository at this point in the history
Summary:
The definition for _mm256_insert_epi64 was taking an int, which would get
truncated before being inserted in the vector.

Original patch by Joshua Magee!

Reviewers: bruno, craig.topper

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D7179

llvm-svn: 229811
  • Loading branch information
filcab committed Feb 19, 2015
1 parent 2d38959 commit 54a2ba8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/Headers/avxintrin.h
Expand Up @@ -514,7 +514,7 @@ _mm256_insert_epi8(__m256i __a, int __b, int const __imm)

#ifdef __x86_64__
static __inline __m256i __attribute__((__always_inline__, __nodebug__))
_mm256_insert_epi64(__m256i __a, int __b, int const __imm)
_mm256_insert_epi64(__m256i __a, long __b, int const __imm)
{
__v4di __c = (__v4di)__a;
__c[__imm & 3] = __b;
Expand Down
24 changes: 24 additions & 0 deletions clang/test/CodeGen/avx-builtins.c
Expand Up @@ -123,3 +123,27 @@ __m256 test_256_blend_ps(__m256 __a, __m256 __b) {
// CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> <i32 8, i32 1, i32 10, i32 3, i32 12, i32 13, i32 6, i32 7>
return _mm256_blend_ps(__a, __b, 0x35);
}

__m256i test_256_insert_epi8(__m256i __a) {
// CHECK-LABEL: @test_256_insert_epi8
// CHECK: insertelement <32 x i8> {{.*}}, i8 {{.*}}, i32 {{.*}}
return _mm256_insert_epi8(__a, 42, 3);
}

__m256i test_256_insert_epi16(__m256i __a) {
// CHECK-LABEL: @test_256_insert_epi16
// CHECK: insertelement <16 x i16> {{.*}}, i16 {{.*}}, i32 {{.*}}
return _mm256_insert_epi16(__a, 42, 3);
}

__m256i test_256_insert_epi32(__m256i __a) {
// CHECK-LABEL: @test_256_insert_epi32
// CHECK: insertelement <8 x i32> {{.*}}, i32 {{.*}}, i32 {{.*}}
return _mm256_insert_epi32(__a, 42, 3);
}

__m256i test_256_insert_epi64(__m256i __a) {
// CHECK-LABEL: @test_256_insert_epi64
// CHECK: insertelement <4 x i64> {{.*}}, i64 {{.*}}, i32 {{.*}}
return _mm256_insert_epi64(__a, 42, 3);
}

0 comments on commit 54a2ba8

Please sign in to comment.