convertvector.c
2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -target-cpu corei7-avx -emit-llvm %s -o - | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -target-cpu corei7-avx -emit-llvm -x c++ %s -o - | FileCheck %s
typedef double vector8double __attribute__((__vector_size__(64)));
typedef float vector8float __attribute__((__vector_size__(32)));
typedef long vector8long __attribute__((__vector_size__(64)));
typedef short vector8short __attribute__((__vector_size__(16)));
typedef unsigned long vector8ulong __attribute__((__vector_size__(64)));
typedef unsigned short vector8ushort __attribute__((__vector_size__(16)));
#ifdef __cplusplus
extern "C" {
#endif
vector8float flt_trunc(vector8double x) {
return __builtin_convertvector(x, vector8float);
// CHECK-LABEL: @flt_trunc
// CHECK: fptrunc <8 x double> %{{[^ ]}} to <8 x float>
}
vector8double flt_ext(vector8float x) {
return __builtin_convertvector(x, vector8double);
// CHECK-LABEL: @flt_ext
// CHECK: fpext <8 x float> %{{[^ ]}} to <8 x double>
}
vector8long flt_tosi(vector8float x) {
return __builtin_convertvector(x, vector8long);
// CHECK-LABEL: @flt_tosi
// CHECK: fptosi <8 x float> %{{[^ ]}} to <8 x i64>
}
vector8ulong flt_toui(vector8float x) {
return __builtin_convertvector(x, vector8ulong);
// CHECK-LABEL: @flt_toui
// CHECK: fptoui <8 x float> %{{[^ ]}} to <8 x i64>
}
vector8ulong fltd_toui(vector8double x) {
return __builtin_convertvector(x, vector8ulong);
// CHECK-LABEL: @fltd_toui
// CHECK: fptoui <8 x double> %{{[^ ]}} to <8 x i64>
}
vector8ulong int_zext(vector8ushort x) {
return __builtin_convertvector(x, vector8ulong);
// CHECK-LABEL: @int_zext
// CHECK: zext <8 x i16> %{{[^ ]}} to <8 x i64>
}
vector8long int_sext(vector8short x) {
return __builtin_convertvector(x, vector8long);
// CHECK-LABEL: @int_sext
// CHECK: sext <8 x i16> %{{[^ ]}} to <8 x i64>
}
vector8float int_tofp(vector8short x) {
return __builtin_convertvector(x, vector8float);
// CHECK-LABEL: @int_tofp
// CHECK: sitofp <8 x i16> %{{[^ ]}} to <8 x float>
}
vector8float uint_tofp(vector8ushort x) {
return __builtin_convertvector(x, vector8float);
// CHECK-LABEL: @uint_tofp
// CHECK: uitofp <8 x i16> %{{[^ ]}} to <8 x float>
}
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
template<typename T>
T int_toT(vector8long x) {
return __builtin_convertvector(x, T);
}
extern "C" {
vector8double int_toT_fp(vector8long x) {
// CHECK-LABEL: @int_toT_fp
// CHECK: sitofp <8 x i64> %{{[^ ]}} to <8 x double>
return int_toT<vector8double>(x);
}
}
#else
vector8double int_toT_fp(vector8long x) {
return __builtin_convertvector(x, vector8double);
}
#endif