1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -target-cpu corei7-avx -emit-llvm %s -o - | FileCheck %s
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -target-cpu corei7-avx -emit-llvm -x c++ %s -o - | FileCheck %s
3*f4a2713aSLionel Sambuc
4*f4a2713aSLionel Sambuc typedef double vector8double __attribute__((__vector_size__(64)));
5*f4a2713aSLionel Sambuc typedef float vector8float __attribute__((__vector_size__(32)));
6*f4a2713aSLionel Sambuc typedef long vector8long __attribute__((__vector_size__(64)));
7*f4a2713aSLionel Sambuc typedef short vector8short __attribute__((__vector_size__(16)));
8*f4a2713aSLionel Sambuc typedef unsigned long vector8ulong __attribute__((__vector_size__(64)));
9*f4a2713aSLionel Sambuc typedef unsigned short vector8ushort __attribute__((__vector_size__(16)));
10*f4a2713aSLionel Sambuc
11*f4a2713aSLionel Sambuc #ifdef __cplusplus
12*f4a2713aSLionel Sambuc #define BOOL bool
13*f4a2713aSLionel Sambuc #else
14*f4a2713aSLionel Sambuc #define BOOL _Bool
15*f4a2713aSLionel Sambuc #endif
16*f4a2713aSLionel Sambuc
17*f4a2713aSLionel Sambuc typedef BOOL vector8bool __attribute__((__ext_vector_type__(8)));
18*f4a2713aSLionel Sambuc
19*f4a2713aSLionel Sambuc #ifdef __cplusplus
20*f4a2713aSLionel Sambuc extern "C" {
21*f4a2713aSLionel Sambuc #endif
22*f4a2713aSLionel Sambuc
flt_trunc(vector8double x)23*f4a2713aSLionel Sambuc vector8float flt_trunc(vector8double x) {
24*f4a2713aSLionel Sambuc return __builtin_convertvector(x, vector8float);
25*f4a2713aSLionel Sambuc // CHECK-LABEL: @flt_trunc
26*f4a2713aSLionel Sambuc // CHECK: fptrunc <8 x double> %{{[^ ]}} to <8 x float>
27*f4a2713aSLionel Sambuc }
28*f4a2713aSLionel Sambuc
flt_ext(vector8float x)29*f4a2713aSLionel Sambuc vector8double flt_ext(vector8float x) {
30*f4a2713aSLionel Sambuc return __builtin_convertvector(x, vector8double);
31*f4a2713aSLionel Sambuc // CHECK-LABEL: @flt_ext
32*f4a2713aSLionel Sambuc // CHECK: fpext <8 x float> %{{[^ ]}} to <8 x double>
33*f4a2713aSLionel Sambuc }
34*f4a2713aSLionel Sambuc
flt_tobool(vector8float x)35*f4a2713aSLionel Sambuc vector8bool flt_tobool(vector8float x) {
36*f4a2713aSLionel Sambuc return __builtin_convertvector(x, vector8bool);
37*f4a2713aSLionel Sambuc // CHECK-LABEL: @flt_tobool
38*f4a2713aSLionel Sambuc // CHECK-NOT: fptoui <8 x float> %{{[^ ]}} to <8 x i1>
39*f4a2713aSLionel Sambuc // CHECK: fcmp une <8 x float> %{{[^ ]}}, zeroinitializer
40*f4a2713aSLionel Sambuc }
41*f4a2713aSLionel Sambuc
flt_tosi(vector8float x)42*f4a2713aSLionel Sambuc vector8long flt_tosi(vector8float x) {
43*f4a2713aSLionel Sambuc return __builtin_convertvector(x, vector8long);
44*f4a2713aSLionel Sambuc // CHECK-LABEL: @flt_tosi
45*f4a2713aSLionel Sambuc // CHECK: fptosi <8 x float> %{{[^ ]}} to <8 x i64>
46*f4a2713aSLionel Sambuc }
47*f4a2713aSLionel Sambuc
flt_toui(vector8float x)48*f4a2713aSLionel Sambuc vector8ulong flt_toui(vector8float x) {
49*f4a2713aSLionel Sambuc return __builtin_convertvector(x, vector8ulong);
50*f4a2713aSLionel Sambuc // CHECK-LABEL: @flt_toui
51*f4a2713aSLionel Sambuc // CHECK: fptoui <8 x float> %{{[^ ]}} to <8 x i64>
52*f4a2713aSLionel Sambuc }
53*f4a2713aSLionel Sambuc
fltd_toui(vector8double x)54*f4a2713aSLionel Sambuc vector8ulong fltd_toui(vector8double x) {
55*f4a2713aSLionel Sambuc return __builtin_convertvector(x, vector8ulong);
56*f4a2713aSLionel Sambuc // CHECK-LABEL: @fltd_toui
57*f4a2713aSLionel Sambuc // CHECK: fptoui <8 x double> %{{[^ ]}} to <8 x i64>
58*f4a2713aSLionel Sambuc }
59*f4a2713aSLionel Sambuc
int_zext(vector8ushort x)60*f4a2713aSLionel Sambuc vector8ulong int_zext(vector8ushort x) {
61*f4a2713aSLionel Sambuc return __builtin_convertvector(x, vector8ulong);
62*f4a2713aSLionel Sambuc // CHECK-LABEL: @int_zext
63*f4a2713aSLionel Sambuc // CHECK: zext <8 x i16> %{{[^ ]}} to <8 x i64>
64*f4a2713aSLionel Sambuc }
65*f4a2713aSLionel Sambuc
int_sext(vector8short x)66*f4a2713aSLionel Sambuc vector8long int_sext(vector8short x) {
67*f4a2713aSLionel Sambuc return __builtin_convertvector(x, vector8long);
68*f4a2713aSLionel Sambuc // CHECK-LABEL: @int_sext
69*f4a2713aSLionel Sambuc // CHECK: sext <8 x i16> %{{[^ ]}} to <8 x i64>
70*f4a2713aSLionel Sambuc }
71*f4a2713aSLionel Sambuc
int_tobool(vector8short x)72*f4a2713aSLionel Sambuc vector8bool int_tobool(vector8short x) {
73*f4a2713aSLionel Sambuc return __builtin_convertvector(x, vector8bool);
74*f4a2713aSLionel Sambuc // CHECK-LABEL: @int_tobool
75*f4a2713aSLionel Sambuc // CHECK-NOT: trunc <8 x i16> %{{[^ ]}} to <8 x i1>
76*f4a2713aSLionel Sambuc // CHECK: icmp ne <8 x i16> %{{[^ ]}}, zeroinitializer
77*f4a2713aSLionel Sambuc }
78*f4a2713aSLionel Sambuc
int_tofp(vector8short x)79*f4a2713aSLionel Sambuc vector8float int_tofp(vector8short x) {
80*f4a2713aSLionel Sambuc return __builtin_convertvector(x, vector8float);
81*f4a2713aSLionel Sambuc // CHECK-LABEL: @int_tofp
82*f4a2713aSLionel Sambuc // CHECK: sitofp <8 x i16> %{{[^ ]}} to <8 x float>
83*f4a2713aSLionel Sambuc }
84*f4a2713aSLionel Sambuc
uint_tofp(vector8ushort x)85*f4a2713aSLionel Sambuc vector8float uint_tofp(vector8ushort x) {
86*f4a2713aSLionel Sambuc return __builtin_convertvector(x, vector8float);
87*f4a2713aSLionel Sambuc // CHECK-LABEL: @uint_tofp
88*f4a2713aSLionel Sambuc // CHECK: uitofp <8 x i16> %{{[^ ]}} to <8 x float>
89*f4a2713aSLionel Sambuc }
90*f4a2713aSLionel Sambuc
91*f4a2713aSLionel Sambuc #ifdef __cplusplus
92*f4a2713aSLionel Sambuc }
93*f4a2713aSLionel Sambuc #endif
94*f4a2713aSLionel Sambuc
95*f4a2713aSLionel Sambuc
96*f4a2713aSLionel Sambuc #ifdef __cplusplus
97*f4a2713aSLionel Sambuc template<typename T>
int_toT(vector8long x)98*f4a2713aSLionel Sambuc T int_toT(vector8long x) {
99*f4a2713aSLionel Sambuc return __builtin_convertvector(x, T);
100*f4a2713aSLionel Sambuc }
101*f4a2713aSLionel Sambuc
102*f4a2713aSLionel Sambuc extern "C" {
int_toT_fp(vector8long x)103*f4a2713aSLionel Sambuc vector8double int_toT_fp(vector8long x) {
104*f4a2713aSLionel Sambuc // CHECK-LABEL: @int_toT_fp
105*f4a2713aSLionel Sambuc // CHECK: sitofp <8 x i64> %{{[^ ]}} to <8 x double>
106*f4a2713aSLionel Sambuc return int_toT<vector8double>(x);
107*f4a2713aSLionel Sambuc }
108*f4a2713aSLionel Sambuc }
109*f4a2713aSLionel Sambuc #else
int_toT_fp(vector8long x)110*f4a2713aSLionel Sambuc vector8double int_toT_fp(vector8long x) {
111*f4a2713aSLionel Sambuc return __builtin_convertvector(x, vector8double);
112*f4a2713aSLionel Sambuc }
113*f4a2713aSLionel Sambuc #endif
114*f4a2713aSLionel Sambuc
115