• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -triple i386-apple-darwin9 -O1 -target-cpu core2 -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
2 typedef short __v4hi __attribute__ ((__vector_size__ (8)));
3 
test1()4 void test1() {
5   __v4hi A = (__v4hi)0LL;
6 }
7 
8 __v4hi x = {1,2,3};
9 __v4hi y = {1,2,3,4};
10 
11 typedef int vty __attribute((vector_size(16)));
test2()12 int test2() { vty b; return b[2LL]; }
13 
14 // PR4339
15 typedef float vec4 __attribute__((vector_size(16)));
16 
test3(vec4 * a,char b,float c)17 void test3 ( vec4* a, char b, float c ) {
18   (*a)[b] = c;
19 }
20 
21 
22 
23 // Don't include mm_malloc.h, it's system specific.
24 #define __MM_MALLOC_H
25 
26 #include <mmintrin.h>
27 
test4(int argc,char * argv[])28 int test4(int argc, char *argv[]) {
29   int array[16] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
30   __m64 *p = (__m64 *)array;
31 
32   __m64 accum = _mm_setzero_si64();
33 
34   for (int i=0; i<8; ++i)
35      accum = _mm_add_pi32(p[i], accum);
36 
37   __m64 accum2 = _mm_unpackhi_pi32(accum, accum);
38   accum = _mm_add_pi32(accum, accum2);
39 
40   int result = _mm_cvtsi64_si32(accum);
41   _mm_empty();
42 
43   return result;
44 }
45 
46 #include <smmintrin.h>
47 
test_epi8(__m128i x)48 unsigned long test_epi8(__m128i x) { return _mm_extract_epi8(x, 4); }
49 // CHECK: @test_epi8
50 // CHECK: extractelement <16 x i8> {{.*}}, i32 4
51 // CHECK: zext i8 {{.*}} to i32
52 
test_epi16(__m128i x)53 unsigned long test_epi16(__m128i x) { return _mm_extract_epi16(x, 3); }
54 
55 // CHECK: @test_epi16
56 // CHECK: extractelement <8 x i16> {{.*}}, i32 3
57 // CHECK: zext i16 {{.*}} to i32
58 
extractinttypes()59 void extractinttypes() {
60   extern int check_extract_result_int;
61   extern __typeof(_mm_extract_epi8(_mm_setzero_si128(), 3)) check_result_int;
62   extern __typeof(_mm_extract_epi16(_mm_setzero_si128(), 3)) check_result_int;
63   extern __typeof(_mm_extract_epi32(_mm_setzero_si128(), 3)) check_result_int;
64 }
65 
66 // Test some logic around our lax vector comparison rules with integers.
67 
68 typedef int vec_int1 __attribute__((vector_size(4)));
lax_vector_compare1(int x,vec_int1 y)69 vec_int1 lax_vector_compare1(int x, vec_int1 y) {
70   y = x == y;
71   return y;
72 }
73 
74 // CHECK: define i32 @lax_vector_compare1(i32 {{.*}}, i32 {{.*}})
75 // CHECK: icmp eq <1 x i32>
76 
77 typedef int vec_int2 __attribute__((vector_size(8)));
lax_vector_compare2(long long x,vec_int2 y)78 vec_int2 lax_vector_compare2(long long x, vec_int2 y) {
79   y = x == y;
80   return y;
81 }
82 
83 // CHECK: define void @lax_vector_compare2(<2 x i32>* {{.*sret.*}}, i64 {{.*}}, i64 {{.*}})
84 // CHECK: icmp eq <2 x i32>
85