Hal Finkel | 414a1bd | 2013-09-18 03:29:45 +0000 | [diff] [blame] | 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 | |
| 4 | typedef double vector8double __attribute__((__vector_size__(64))); |
| 5 | typedef float vector8float __attribute__((__vector_size__(32))); |
| 6 | typedef long vector8long __attribute__((__vector_size__(64))); |
| 7 | typedef short vector8short __attribute__((__vector_size__(16))); |
| 8 | typedef unsigned long vector8ulong __attribute__((__vector_size__(64))); |
| 9 | typedef unsigned short vector8ushort __attribute__((__vector_size__(16))); |
| 10 | |
| 11 | #ifdef __cplusplus |
| 12 | #define BOOL bool |
| 13 | #else |
| 14 | #define BOOL _Bool |
| 15 | #endif |
| 16 | |
| 17 | typedef BOOL vector8bool __attribute__((__ext_vector_type__(8))); |
| 18 | |
| 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
| 23 | vector8float 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 | |
| 29 | vector8double 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 | |
| 35 | vector8bool 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 | |
| 42 | vector8long 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 | |
| 48 | vector8ulong 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 | |
| 54 | vector8ulong 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 | |
| 60 | vector8ulong 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 | |
| 66 | vector8long 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 | |
| 72 | vector8bool 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 | |
| 79 | vector8float 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 | |
| 85 | vector8float 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 |
| 97 | template<typename T> |
| 98 | T int_toT(vector8long x) { |
| 99 | return __builtin_convertvector(x, T); |
| 100 | } |
| 101 | |
| 102 | extern "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 |
| 110 | vector8double int_toT_fp(vector8long x) { |
| 111 | return __builtin_convertvector(x, vector8double); |
| 112 | } |
| 113 | #endif |
| 114 | |