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