[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / vector.c
blobc20e32046305605cec19c078e8ca82f7c65e8ef1
1 // RUN: %clang_cc1 -ffreestanding -triple i386-apple-darwin9 -O1 -target-cpu corei7 -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
2 typedef short __v4hi __attribute__ ((__vector_size__ (8)));
4 void test1(void) {
5 __v4hi A = (__v4hi)0LL;
8 __v4hi x = {1,2,3};
9 __v4hi y = {1,2,3,4};
11 typedef int vty __attribute((vector_size(16)));
12 int test2(void) { vty b; return b[2LL]; }
14 // PR4339
15 typedef float vec4 __attribute__((vector_size(16)));
17 void test3 ( vec4* a, char b, float c ) {
18 (*a)[b] = c;
24 #include <mmintrin.h>
26 int test4(int argc, char *argv[]) {
27 int array[16] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
28 __m64 *p = (__m64 *)array;
30 __m64 accum = _mm_setzero_si64();
32 for (int i=0; i<8; ++i)
33 accum = _mm_add_pi32(p[i], accum);
35 __m64 accum2 = _mm_unpackhi_pi32(accum, accum);
36 accum = _mm_add_pi32(accum, accum2);
38 int result = _mm_cvtsi64_si32(accum);
39 _mm_empty();
41 return result;
44 #include <smmintrin.h>
46 unsigned long test_epi8(__m128i x) { return _mm_extract_epi8(x, 4); }
47 // CHECK: @test_epi8
48 // CHECK: extractelement <16 x i8> {{.*}}, {{i32|i64}} 4
49 // CHECK: zext i8 {{.*}} to i32
51 unsigned long test_epi16(__m128i x) { return _mm_extract_epi16(x, 3); }
53 // CHECK: @test_epi16
54 // CHECK: extractelement <8 x i16> {{.*}}, {{i32|i64}} 3
55 // CHECK: zext i16 {{.*}} to i32
57 void extractinttypes(void) {
58 extern int check_extract_result_int;
59 extern __typeof(_mm_extract_epi8(_mm_setzero_si128(), 3)) check_result_int;
60 extern __typeof(_mm_extract_epi16(_mm_setzero_si128(), 3)) check_result_int;
61 extern __typeof(_mm_extract_epi32(_mm_setzero_si128(), 3)) check_result_int;
64 // Test some logic around our lax vector comparison rules with integers.
66 typedef int vec_int1 __attribute__((vector_size(4)));
67 vec_int1 lax_vector_compare1(int x, vec_int1 y) {
68 y = x == y;
69 return y;
72 // CHECK: define{{.*}} i32 @lax_vector_compare1(i32 {{.*}}, i32 {{.*}})
73 // CHECK: icmp eq i32
75 typedef int vec_int2 __attribute__((vector_size(8)));
76 vec_int2 lax_vector_compare2(long long x, vec_int2 y) {
77 y = x == y;
78 return y;
81 // CHECK: define{{.*}} void @lax_vector_compare2(ptr {{.*sret.*}}, i64 {{.*}}, i64 {{.*}})
82 // CHECK: icmp eq <2 x i32>