Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / vector-splat-conversion.cpp
blob08b2fa8e96cb442cda1228e7769d9b042e74172f
1 // RUN: %clang_cc1 %s -triple arm64-apple-ios8.1.0 -std=c++11 -emit-llvm -o - | FileCheck %s
3 typedef __attribute__((__ext_vector_type__(8))) float vector_float8;
5 typedef vector_float8 float8;
7 // CHECK-LABEL: define{{.*}} void @_Z23MandelbrotPolyCalcSIMD8v
8 void MandelbrotPolyCalcSIMD8() {
9 constexpr float8 v4 = 4.0; // value to compare against abs(z)^2, to see if bounded
10 float8 vABS;
11 auto vLT = vABS < v4;
12 // CHECK: store <8 x float>
13 // CHECK: [[ZERO:%.*]] = load <8 x float>, ptr [[VARBS:%.*]]
14 // CHECK: [[CMP:%.*]] = fcmp olt <8 x float> [[ZERO]]
15 // CHECK: [[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i32>
16 // CHECK: store <8 x i32> [[SEXT]], ptr [[VLT:%.*]]
19 typedef __attribute__((__ext_vector_type__(4))) int int4;
20 typedef __attribute__((__ext_vector_type__(4))) float float4;
21 typedef __attribute__((__ext_vector_type__(4))) __int128 bigint4;
23 // CHECK-LABEL: define{{.*}} void @_Z14BoolConversionv
24 void BoolConversion() {
25 // CHECK: store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
26 int4 intsT = (int4)true;
27 // CHECK: store <4 x i32> zeroinitializer
28 int4 intsF = (int4)false;
29 // CHECK: store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>
30 float4 floatsT = (float4)true;
31 // CHECK: store <4 x float> zeroinitializer
32 float4 floatsF = (float4)false;
33 // CHECK: store <4 x i128> <i128 -1, i128 -1, i128 -1, i128 -1>
34 bigint4 bigintsT = (bigint4)true;
35 // CHECK: store <4 x i128> zeroinitializer
36 bigint4 bigintsF = (bigint4)false;
38 // CHECK: store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
39 constexpr int4 cIntsT = (int4)true;
40 // CHECK: store <4 x i32> zeroinitializer
41 constexpr int4 cIntsF = (int4)false;
42 // CHECK: store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>
43 constexpr float4 cFloatsT = (float4)true;
44 // CHECK: store <4 x float> zeroinitializer
45 constexpr float4 cFloatsF = (float4)false;
46 // CHECK: store <4 x i128> <i128 -1, i128 -1, i128 -1, i128 -1>
47 constexpr bigint4 cBigintsT = (bigint4)true;
48 // CHECK: store <4 x i128> zeroinitializer
49 constexpr bigint4 cBigintsF = (bigint4)false;
52 typedef __attribute__((vector_size(8))) int gcc_int_2;
53 gcc_int_2 FloatToIntConversion(gcc_int_2 Int2, float f) {
54 return Int2 + f;
55 // CHECK: %[[LOAD_INT:.+]] = load <2 x i32>
56 // CHECK: %[[LOAD:.+]] = load float, ptr
57 // CHECK: %[[CONV:.+]] = fptosi float %[[LOAD]] to i32
58 // CHECK: %[[INSERT:.+]] = insertelement <2 x i32> poison, i32 %[[CONV]], i64 0
59 // CHECK: %[[SPLAT:.+]] = shufflevector <2 x i32> %[[INSERT]], <2 x i32> poison, <2 x i32> zeroinitializer
60 // CHECK: add <2 x i32> %[[LOAD_INT]], %[[SPLAT]]